Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions .github/workflows/build-native-libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: 'build-native-libs'

# Builds the C++ libraries the app links (OpenCV, tesseract + leptonica + libpng [+ libjpeg-turbo])
# for Android, iOS (device + simulator) and Mac Catalyst, selected by version number.
# See scripts/native-libs/README.md. Download the result with scripts/native-libs/fetch.sh.

on:
workflow_dispatch:
inputs:
opencv_version:
description: 'OpenCV version (must have an OPENCV_MOBILE_TAG_<ver> pin in scripts/native-libs/versions.env, or exist as an opencv-mobile release)'
required: true
default: '4.13.0'
type: string
tesseract_version:
description: 'Tesseract version (needs TESSERACT_<ver>_* dependency pins in scripts/native-libs/versions.env)'
required: true
default: '5.5.1'
type: string
platforms:
description: 'Platforms to build'
required: true
default: all
type: choice
options:
- all
- android
- ios
- catalyst
variant:
description: 'Tesseract variant: release (optimized, stripped), debug (-O1 -g, not stripped, same file names) or both. OpenCV has no debug variant.'
required: true
default: release
type: choice
options:
- release
- debug
- both
opencv_from_source:
description: 'Rebuild OpenCV from the opencv-mobile sources instead of repackaging the prebuilt opencv-mobile binaries'
required: true
default: false
type: boolean
release:
description: 'Attach the archives to the GitHub release native-libs-<opencv>-<tesseract>'
required: true
default: false
type: boolean

permissions:
contents: read

concurrency:
group: build-native-libs-${{ inputs.opencv_version }}-${{ inputs.tesseract_version }}
cancel-in-progress: false

env:
OPENCV_VERSION: ${{ inputs.opencv_version }}
TESSERACT_VERSION: ${{ inputs.tesseract_version }}
ARTIFACT_SUFFIX: opencv${{ inputs.opencv_version }}-tesseract${{ inputs.tesseract_version }}
OPENCV_FROM_SOURCE: ${{ inputs.opencv_from_source && '1' || '0' }}

jobs:
android:
name: Android
if: inputs.platforms == 'all' || inputs.platforms == 'android'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
variant: ${{ fromJSON(inputs.variant == 'both' && '["release","debug"]' || format('["{0}"]', inputs.variant)) }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4

- name: Install pinned Android NDK
run: |
source scripts/native-libs/versions.env
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "ndk;$NATIVE_LIBS_NDK_VERSION" >/dev/null
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NATIVE_LIBS_NDK_VERSION" >> "$GITHUB_ENV"

- name: Cache build output
id: cache
uses: actions/cache@v4
with:
path: build/native-libs/out/android${{ matrix.variant == 'debug' && '-debug' || '' }}
key: native-libs-android${{ matrix.variant == 'debug' && '-debug' || '' }}-${{ env.ARTIFACT_SUFFIX }}-src${{ inputs.opencv_from_source }}-${{ hashFiles('scripts/native-libs/**') }}

- name: Cache downloads
uses: actions/cache@v4
with:
path: build/native-libs/downloads
key: native-libs-downloads-${{ env.ARTIFACT_SUFFIX }}-${{ hashFiles('scripts/native-libs/versions.env') }}

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
run: scripts/native-libs/build.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" android --variant ${{ matrix.variant }}

- name: Package (cache hit)
if: steps.cache.outputs.cache-hit == 'true'
run: scripts/native-libs/package.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" android --variant ${{ matrix.variant }}

- uses: actions/upload-artifact@v4
with:
name: native-libs-android-${{ env.ARTIFACT_SUFFIX }}${{ matrix.variant == 'debug' && '-debug' || '' }}
path: build/native-libs/out/native-libs-android-*.tar.gz*
if-no-files-found: error

ios:
name: iOS (device + simulator) + OpenCV xcframework
if: inputs.platforms == 'all' || inputs.platforms == 'ios'
runs-on: macos-15
strategy:
fail-fast: false
matrix:
variant: ${{ fromJSON(inputs.variant == 'both' && '["release","debug"]' || format('["{0}"]', inputs.variant)) }}
timeout-minutes: 180
steps:
- uses: actions/checkout@v4

- name: Cache build output
id: cache
uses: actions/cache@v4
with:
path: build/native-libs/out/ios${{ matrix.variant == 'debug' && '-debug' || '' }}
key: native-libs-ios${{ matrix.variant == 'debug' && '-debug' || '' }}-${{ env.ARTIFACT_SUFFIX }}-src${{ inputs.opencv_from_source }}-${{ hashFiles('scripts/native-libs/**') }}

- name: Cache downloads
uses: actions/cache@v4
with:
path: build/native-libs/downloads
key: native-libs-downloads-${{ env.ARTIFACT_SUFFIX }}-${{ hashFiles('scripts/native-libs/versions.env') }}

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
run: scripts/native-libs/build.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" ios --variant ${{ matrix.variant }}

- name: Package (cache hit)
if: steps.cache.outputs.cache-hit == 'true'
run: scripts/native-libs/package.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" ios --variant ${{ matrix.variant }}

- uses: actions/upload-artifact@v4
with:
name: native-libs-ios-${{ env.ARTIFACT_SUFFIX }}${{ matrix.variant == 'debug' && '-debug' || '' }}
path: build/native-libs/out/native-libs-ios-*.tar.gz*
if-no-files-found: error

catalyst:
name: Mac Catalyst
if: inputs.platforms == 'all' || inputs.platforms == 'catalyst'
runs-on: macos-15
strategy:
fail-fast: false
matrix:
variant: ${{ fromJSON(inputs.variant == 'both' && '["release","debug"]' || format('["{0}"]', inputs.variant)) }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4

- name: Cache build output
id: cache
uses: actions/cache@v4
with:
path: build/native-libs/out/catalyst${{ matrix.variant == 'debug' && '-debug' || '' }}
key: native-libs-catalyst${{ matrix.variant == 'debug' && '-debug' || '' }}-${{ env.ARTIFACT_SUFFIX }}-${{ hashFiles('scripts/native-libs/**') }}

- name: Cache downloads
uses: actions/cache@v4
with:
path: build/native-libs/downloads
key: native-libs-downloads-${{ env.ARTIFACT_SUFFIX }}-${{ hashFiles('scripts/native-libs/versions.env') }}

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
run: scripts/native-libs/build.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" catalyst --variant ${{ matrix.variant }}

- name: Package (cache hit)
if: steps.cache.outputs.cache-hit == 'true'
run: scripts/native-libs/package.sh "$OPENCV_VERSION" "$TESSERACT_VERSION" catalyst --variant ${{ matrix.variant }}

- uses: actions/upload-artifact@v4
with:
name: native-libs-catalyst-${{ env.ARTIFACT_SUFFIX }}${{ matrix.variant == 'debug' && '-debug' || '' }}
path: build/native-libs/out/native-libs-catalyst-*.tar.gz*
if-no-files-found: error

release:
name: Attach to GitHub release
if: ${{ !cancelled() && !failure() && inputs.release }}
needs: [android, ios, catalyst]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: native-libs-*-${{ env.ARTIFACT_SUFFIX }}*
path: assets
merge-multiple: true

- name: Create or update the release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="native-libs-${OPENCV_VERSION}-${TESSERACT_VERSION}"
ls -la assets
if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create "$tag" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \
--title "Native libs: OpenCV ${OPENCV_VERSION} + Tesseract ${TESSERACT_VERSION}" \
--notes "Prebuilt OpenCV ${OPENCV_VERSION} and Tesseract ${TESSERACT_VERSION} static libraries (Android, iOS, Mac Catalyst); *-debug archives hold tesseract with symbols (extract over the release one). Install with scripts/native-libs/fetch.sh ${OPENCV_VERSION} ${TESSERACT_VERSION} all [--variant both]. Built by the build-native-libs workflow, run ${GITHUB_RUN_ID}." \
--prerelease
fi
gh release upload "$tag" assets/* --repo "$GITHUB_REPOSITORY" --clobber
2 changes: 1 addition & 1 deletion App_Resources/cardwallet/Android/before-plugins.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ext {
androidXRecyclerViewVersion = "1.4.0"
androidxViewPager2Version = "1.1.0"
androidXSwipeRefreshLayoutViewVersion = "1.2.0"
androidXMaterial = "1.13.0"
androidXMaterial = "1.14.0"
androidXBrowser = "1.10.0"
androidXPreferenceVersion = "1.2.1"
androidXSplashscreenVersion = "1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion App_Resources/cardwallet/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiresFullScreen</key>
<true/>
<false/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>location-services</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ext {
androidXRecyclerViewVersion = "1.4.0"
androidxViewPager2Version = "1.1.0"
androidXSwipeRefreshLayoutViewVersion = "1.2.0"
androidXMaterial = "1.13.0"
androidXMaterial = "1.14.0"
androidXBrowser = "1.10.0"
androidXPreferenceVersion = "1.2.1"
androidXSplashscreenVersion = "1.2.0"
Expand Down
18 changes: 18 additions & 0 deletions App_Resources/documentscanner/Catalyst/app.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions App_Resources/documentscanner/Catalyst/build.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Overrides App_Resources/documentscanner/iOS/build.xcconfig for Mac Catalyst builds
IPHONEOS_DEPLOYMENT_TARGET = 16.0
21 changes: 20 additions & 1 deletion App_Resources/documentscanner/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiresFullScreen</key>
<true/>
<false/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>location-services</string>
Expand Down Expand Up @@ -63,5 +63,24 @@
<string>12.0</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
<string>UIWindowSceneSessionRoleApplication</string>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
7 changes: 4 additions & 3 deletions App_Resources/documentscanner/iOS/Podfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
plugin 'cocoapods-acknowledgements'
# pod "MSColorPicker"
platform :ios, '14.0'
platform :ios, '17.0'
pod 'SSZipArchive'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "x86_64"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '17.0'
config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-'
config.build_settings['SWIFT_VERSION'] = '5.1'
config.build_settings['DEVELOPMENT_TEAM'] = '3UUB5NM43K'
config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'
Expand Down
3 changes: 2 additions & 1 deletion App_Resources/documentscanner/iOS/build.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 3UUB5NM43K
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
SWIFT_VERSION=5.1
IPHONEOS_DEPLOYMENT_TARGET = 14.0
IPHONEOS_DEPLOYMENT_TARGET = 17.0
EXCLUDED_ARCHS[sdk=iphonesimulator*] = x86_64
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ I use dotenv plugin for zsh which automatically loads the `.env` file
### 3rd parties

This app also uses opencv and tesseract. I did not include the libraries in git because there are huge and would make the github repo too big.
There are 2 ways to install them:
There are 3 ways to install them:

- reproducible, selected by version (Android, iOS and Mac Catalyst): `scripts/native-libs/fetch.sh <opencv_version> <tesseract_version> all` downloads a build of the `build-native-libs` workflow, or build locally with `scripts/native-libs/build.sh`. See [scripts/native-libs/README.md](scripts/native-libs/README.md)
- download from [here](https://github.com/ossappscollective/OSS-DocumentScanner/releases/tag/dev_resources) and uncompress them at the root
- build them yourself:

Expand Down
2 changes: 1 addition & 1 deletion app/android/camera_scan_activity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppUtilsAndroid } from '@akylas/nativescript-app-utils';
import { showBottomSheet } from '@nativescript-community/ui-material-bottomsheet/svelte';
import { showBottomSheet } from '@nativescript-community/ui-bottomsheet/svelte';
import {
AndroidActivityBackPressedEventData,
AndroidActivityCallbacks,
Expand Down
2 changes: 1 addition & 1 deletion app/app.android.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './app.common';
checkbox {
margin-right: -16;
margin-right: 0;
}
12 changes: 6 additions & 6 deletions app/app.common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
font-family: $mdiFontFamily;
}

mdtextfield,
mdtextview {
textfield,
textview {
stroke-color: var(--colorOutline);
placeholder-color: var(--colorOutline);
color: var(--colorOnBackground);
Expand All @@ -64,8 +64,8 @@ checkbox {
fill-color: var(--colorPrimary);
}

mdbutton[variant='flat'],
mdbutton[variant='contained'] {
button[variant='flat'],
button[variant='contained'] {
background-color: var(--colorPrimary);
color: var(--colorOnPrimary);
}
Expand All @@ -86,7 +86,7 @@ htmllabel {
// white-space: normal;
}

// mdtextfield {
// textfield {
// color: black;
// // background-color: white;
// // placeholder-color: black;
Expand Down Expand Up @@ -152,7 +152,7 @@ frame {
label,
canvaslabel,
htmllabel,
mdtextfield,
textfield,
.actionBarTitle,
.actionBarSubtitle {
&:black,
Expand Down
Loading
Loading