Skip to content
Open
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
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ on:
env:
NODE_VERSION: 20
JAVA_VERSION: 21
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' &&
github.event.pull_request.base.sha || github.event.before }}
Comment thread
robingenz marked this conversation as resolved.

jobs:
build-android:
Expand Down Expand Up @@ -69,6 +70,12 @@ jobs:
- name: Install all CocoaPods dependencies
if: github.ref == 'refs/heads/main'
run: npm run ios:pod:install
- name: Install SPM dependencies of packages affected by changes
if: github.ref != 'refs/heads/main'
run: npm run affected:ios:spm:install
- name: Install all SPM dependencies
if: github.ref == 'refs/heads/main'
run: npm run ios:spm:install
- name: Build packages affected by changes
if: github.ref != 'refs/heads/main'
run: npm run affected:verify:ios
Expand Down Expand Up @@ -103,7 +110,7 @@ jobs:
lint:
name: Lint
runs-on: macos-15
needs: [build-android, build-ios, build-web]
needs: [ build-android, build-ios, build-web ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -124,7 +131,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
needs: [lint]
needs: [ lint ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
> [!WARNING]
> These plugins do **not** support Swift Package Manager (SPM) because the underlying [ML Kit SDKs do not support SPM](https://github.com/googlesamples/mlkit/issues/180#issuecomment-1298964099) (see [#186](https://github.com/capawesome-team/capacitor-mlkit/issues/186)).

<br />
<div align="center">
<img src="https://avatars.githubusercontent.com/u/105555861" width="128" height="128" />
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"docgen": "turbo run docgen",
"build": "turbo run build",
"ios:pod:install": "turbo run ios:pod:install --concurrency=1 --no-cache",
"ios:spm:install": "turbo run ios:spm:install --concurrency=1 --no-cache",
"affected:verify": "npm run affected:verify:android && npm run affected:verify:ios && npm run affected:verify:web",
"affected:verify:android": "turbo run verify:android --affected --concurrency=1 --no-cache --env-mode=loose",
"affected:verify:ios": "turbo run verify:ios --affected --concurrency=1 --no-cache --env-mode=loose",
Expand All @@ -24,6 +25,7 @@
"affected:docgen": "turbo run docgen --affected",
"affected:build": "turbo run build --affected",
"affected:ios:pod:install": "turbo run ios:pod:install --affected --concurrency=1 --no-cache",
"affected:ios:spm:install": "turbo run ios:spm:install --affected --concurrency=1 --no-cache",
"changeset": "changeset",
"release": "npm run build && changeset publish",
"release:preview": "pkg-pr-new publish './packages/*'",
Expand Down
6 changes: 6 additions & 0 deletions packages/barcode-scanning/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Pods
Podfile.lock
Build
xcuserdata
Package.resolved
/.build
/Packages
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

# macOS files
.DS_Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '15.0'
s.dependency 'Capacitor'
s.dependency 'GoogleMLKit/BarcodeScanning', '~> 8.0.0'
s.dependency 'GoogleMLKit/BarcodeScanning', '~> 9.0.0'
s.swift_version = '5.1'
s.static_framework = true
end
30 changes: 30 additions & 0 deletions packages/barcode-scanning/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "CapacitorMlkitBarcodeScanning",
platforms: [.iOS(.v15)],
products: [
.library(
name: "CapacitorMlkitBarcodeScanning",
targets: ["BarcodeScannerPlugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
.package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0"))
],
targets: [
.target(
name: "BarcodeScannerPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
.product(name: "MLKitBarcodeScanning", package: "google-mlkit-swiftpm")
],
path: "ios/Plugin"),
.testTarget(
name: "BarcodeScannerPluginTests",
dependencies: ["BarcodeScannerPlugin"],
path: "ios/PluginTests")
]
)
7 changes: 5 additions & 2 deletions packages/barcode-scanning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ npm install @capacitor-mlkit/barcode-scanning
npx cap sync
```

**Attention**: This plugin **only supports CocoaPods** for iOS dependency management. Swift Package Manager (SPM) is not supported for the ML Kit SDK, see [this comment](https://github.com/googlesamples/mlkit/issues/180#issuecomment-1298964099).

### Android

#### Permissions
Expand Down Expand Up @@ -110,6 +108,11 @@ Make sure to set the deployment target in your `ios/App/Podfile` to at least `15
platform :ios, '15.5'
```

#### Swift Package Manager

> [!WARNING]
> SPM support is **experimental**. The [ML Kit SDKs do not officially support SPM](https://github.com/googlesamples/mlkit/issues/180#issuecomment-1298964099), so this plugin resolves ML Kit via the unofficial [`d-date/google-mlkit-swiftpm`](https://github.com/d-date/google-mlkit-swiftpm) package. For production, CocoaPods is recommended.

### Usage Description

Add the `NSCameraUsageDescription` key to the `ios/App/App/Info.plist` file, which tells the user why the app needs to use the camera:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
2F98D68224C9AAE500613A4C /* BarcodeScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F98D68124C9AAE400613A4C /* BarcodeScanner.swift */; };
50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; };
50ADFF97201F53D600D50D53 /* BarcodeScannerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* BarcodeScannerTests.swift */; };
50ADFF99201F53D600D50D53 /* BarcodeScannerPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* BarcodeScannerPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; };
50ADFFA82020EE4F00D50D53 /* BarcodeScannerPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* BarcodeScannerPlugin.m */; };
50E1A94820377CB70090CE1A /* BarcodeScannerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* BarcodeScannerPlugin.swift */; };
7C39C34F29A0BB4600AE60BB /* ScanSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C39C34E29A0BB4600AE60BB /* ScanSettings.swift */; };
7C8E4B5E2998FE7B00A35D56 /* BarcodeScannerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C8E4B5D2998FE7B00A35D56 /* BarcodeScannerHelper.swift */; };
Expand All @@ -40,13 +38,11 @@
2F98D68124C9AAE400613A4C /* BarcodeScanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarcodeScanner.swift; sourceTree = "<group>"; };
3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF88201F53D600D50D53 /* Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF8B201F53D600D50D53 /* BarcodeScannerPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BarcodeScannerPlugin.h; sourceTree = "<group>"; };
50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF96201F53D600D50D53 /* BarcodeScannerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeScannerTests.swift; sourceTree = "<group>"; };
50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFFA72020EE4F00D50D53 /* BarcodeScannerPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BarcodeScannerPlugin.m; sourceTree = "<group>"; };
50E1A94720377CB70090CE1A /* BarcodeScannerPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarcodeScannerPlugin.swift; sourceTree = "<group>"; };
5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig"; sourceTree = "<group>"; };
7C39C34E29A0BB4600AE60BB /* ScanSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanSettings.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -112,8 +108,6 @@
7C9BA37B2B3350C600A5BED8 /* Protocols */,
50E1A94720377CB70090CE1A /* BarcodeScannerPlugin.swift */,
2F98D68124C9AAE400613A4C /* BarcodeScanner.swift */,
50ADFF8B201F53D600D50D53 /* BarcodeScannerPlugin.h */,
50ADFFA72020EE4F00D50D53 /* BarcodeScannerPlugin.m */,
50ADFF8C201F53D600D50D53 /* Info.plist */,
7C8E4B5D2998FE7B00A35D56 /* BarcodeScannerHelper.swift */,
7CD8CBAD299902D80039652D /* BarcodeScannerView.swift */,
Expand Down Expand Up @@ -194,7 +188,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
50ADFF99201F53D600D50D53 /* BarcodeScannerPlugin.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -379,7 +372,6 @@
50E1A94820377CB70090CE1A /* BarcodeScannerPlugin.swift in Sources */,
7C9BA3812B33511100A5BED8 /* GetMaxZoomRatioResult.swift in Sources */,
2F98D68224C9AAE500613A4C /* BarcodeScanner.swift in Sources */,
50ADFFA82020EE4F00D50D53 /* BarcodeScannerPlugin.m in Sources */,
7CD8CBAE299902D90039652D /* BarcodeScannerView.swift in Sources */,
7C9BA37D2B3350D300A5BED8 /* Result.swift in Sources */,
7C8E4B5E2998FE7B00A35D56 /* BarcodeScannerHelper.swift in Sources */,
Expand Down
10 changes: 0 additions & 10 deletions packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.h

This file was deleted.

26 changes: 0 additions & 26 deletions packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.m

This file was deleted.

25 changes: 24 additions & 1 deletion packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ import MLKitBarcodeScanning
* here: https://capacitorjs.com/docs/plugins/ios
*/
@objc(BarcodeScannerPlugin)
public class BarcodeScannerPlugin: CAPPlugin {
public class BarcodeScannerPlugin: CAPPlugin, CAPBridgedPlugin {
public let identifier = "BarcodeScannerPlugin"
public let jsName = "BarcodeScanner"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "startScan", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "stopScan", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "readBarcodesFromImage", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "scan", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "isSupported", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "enableTorch", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "disableTorch", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "toggleTorch", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "isTorchEnabled", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "isTorchAvailable", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setZoomRatio", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "getZoomRatio", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "getMinZoomRatio", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "getMaxZoomRatio", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "openSettings", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "isGoogleBarcodeScannerModuleAvailable", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "installGoogleBarcodeScannerModule", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise)
]
public let tag = "BarcodeScanner"
public let errorPathMissing = "path must be provided."
public let errorFileNotExist = "File does not exist."
Expand Down
2 changes: 1 addition & 1 deletion packages/barcode-scanning/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

target 'Plugin' do
capacitor_pods
pod 'GoogleMLKit/BarcodeScanning', '8.0.0'
pod 'GoogleMLKit/BarcodeScanning', '9.0.0'
end

target 'PluginTests' do
Expand Down
4 changes: 3 additions & 1 deletion packages/barcode-scanning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"android/build.gradle",
"dist/",
"ios/Plugin/",
"CapacitorMlkitBarcodeScanning.podspec"
"CapacitorMlkitBarcodeScanning.podspec",
"Package.swift"
],
"author": "Robin Genz <mail@robingenz.dev>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -53,6 +54,7 @@
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"ios:pod:install": "cd ios && pod install --repo-update && cd ..",
"ios:spm:install": "cd ios && swift package resolve && cd ..",
Comment thread
robingenz marked this conversation as resolved.
"prepublishOnly": "npm run build"
},
"devDependencies": {
Expand Down
28 changes: 28 additions & 0 deletions packages/document-scanner/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "CapacitorMlkitDocumentScanner",
platforms: [.iOS(.v15)],
products: [
.library(
name: "CapacitorMlkitDocumentScanner",
targets: ["DocumentScannerPlugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
],
targets: [
.target(
name: "DocumentScannerPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")
],
path: "ios/Plugin"),
.testTarget(
name: "DocumentScannerPluginTests",
dependencies: ["DocumentScannerPlugin"],
path: "ios/PluginTests")
]
)
4 changes: 3 additions & 1 deletion packages/document-scanner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"android/build.gradle",
"dist/",
"ios/Plugin/",
"CapacitorMlkitDocumentScanner.podspec"
"CapacitorMlkitDocumentScanner.podspec",
"Package.swift"
],
"author": "Robin Genz <mail@robingenz.dev>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -53,6 +54,7 @@
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"ios:pod:install": "cd ios && pod install --repo-update && cd ..",
"ios:spm:install": "cd ios && swift package resolve && cd ..",
Comment thread
robingenz marked this conversation as resolved.
"prepublishOnly": "npm run build"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/face-detection/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Pods
Podfile.lock
Build
xcuserdata
Package.resolved
/.build
/Packages
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

# macOS files
.DS_Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '15.0'
s.dependency 'Capacitor'
s.dependency 'GoogleMLKit/FaceDetection', '~> 8.0.0'
s.dependency 'GoogleMLKit/FaceDetection', '~> 9.0.0'
s.swift_version = '5.1'
s.static_framework = true
end
30 changes: 30 additions & 0 deletions packages/face-detection/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "CapacitorMlkitFaceDetection",
platforms: [.iOS(.v15)],
products: [
.library(
name: "CapacitorMlkitFaceDetection",
targets: ["FaceDetectionPlugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
.package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0"))
],
targets: [
.target(
name: "FaceDetectionPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
.product(name: "MLKitFaceDetection", package: "google-mlkit-swiftpm")
],
path: "ios/Plugin"),
.testTarget(
name: "FaceDetectionPluginTests",
dependencies: ["FaceDetectionPlugin"],
path: "ios/PluginTests")
]
)
Loading
Loading