From 2c24a0f8d1f91564e21e5b1680195fda70efbb22 Mon Sep 17 00:00:00 2001 From: Robin Genz Date: Fri, 17 Apr 2026 07:44:45 +0200 Subject: [PATCH 1/3] feat: add Swift Package Manager (SPM) support --- .github/workflows/ci.yml | 13 ++++++-- README.md | 3 -- package.json | 2 ++ packages/barcode-scanning/.gitignore | 6 ++++ packages/barcode-scanning/Package.swift | 30 +++++++++++++++++++ .../ios/Plugin.xcodeproj/project.pbxproj | 8 ----- .../ios/Plugin/BarcodeScannerPlugin.h | 10 ------- .../ios/Plugin/BarcodeScannerPlugin.m | 26 ---------------- .../ios/Plugin/BarcodeScannerPlugin.swift | 25 +++++++++++++++- packages/barcode-scanning/package.json | 4 ++- packages/document-scanner/Package.swift | 28 +++++++++++++++++ packages/document-scanner/package.json | 4 ++- packages/face-detection/.gitignore | 6 ++++ packages/face-detection/Package.swift | 30 +++++++++++++++++++ .../ios/Plugin.xcodeproj/project.pbxproj | 8 ----- .../ios/Plugin/FaceDetectionPlugin.h | 10 ------- .../ios/Plugin/FaceDetectionPlugin.m | 8 ----- .../ios/Plugin/FaceDetectionPlugin.swift | 7 ++++- packages/face-detection/package.json | 4 ++- packages/face-mesh-detection/.gitignore | 6 ++++ packages/face-mesh-detection/Package.swift | 28 +++++++++++++++++ .../ios/Plugin.xcodeproj/project.pbxproj | 8 ----- .../ios/Plugin/FaceMeshDetectionPlugin.h | 10 ------- .../ios/Plugin/FaceMeshDetectionPlugin.m | 8 ----- .../ios/Plugin/FaceMeshDetectionPlugin.swift | 7 ++++- packages/face-mesh-detection/package.json | 4 ++- packages/selfie-segmentation/.gitignore | 6 ++++ packages/selfie-segmentation/Package.swift | 30 +++++++++++++++++++ .../ios/Plugin.xcodeproj/project.pbxproj | 8 ----- .../ios/Plugin/SelfieSegmentationPlugin.h | 10 ------- .../ios/Plugin/SelfieSegmentationPlugin.m | 8 ----- .../ios/Plugin/SelfieSegmentationPlugin.swift | 7 ++++- packages/selfie-segmentation/package.json | 4 ++- packages/subject-segmentation/Package.swift | 28 +++++++++++++++++ .../ios/Plugin/SubjectSegmentationPlugin.m | 10 ------- .../Plugin/SubjectSegmentationPlugin.swift | 9 +++++- packages/subject-segmentation/package.json | 4 ++- packages/translation/.gitignore | 6 ++++ packages/translation/Package.swift | 30 +++++++++++++++++++ .../ios/Plugin.xcodeproj/project.pbxproj | 8 ----- .../ios/Plugin/TranslationPlugin.h | 10 ------- .../ios/Plugin/TranslationPlugin.m | 11 ------- .../ios/Plugin/TranslationPlugin.swift | 10 ++++++- packages/translation/package.json | 4 ++- turbo.json | 3 +- 45 files changed, 328 insertions(+), 181 deletions(-) create mode 100644 packages/barcode-scanning/Package.swift delete mode 100644 packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.h delete mode 100644 packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.m create mode 100644 packages/document-scanner/Package.swift create mode 100644 packages/face-detection/Package.swift delete mode 100644 packages/face-detection/ios/Plugin/FaceDetectionPlugin.h delete mode 100644 packages/face-detection/ios/Plugin/FaceDetectionPlugin.m create mode 100644 packages/face-mesh-detection/Package.swift delete mode 100644 packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.h delete mode 100644 packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.m create mode 100644 packages/selfie-segmentation/Package.swift delete mode 100644 packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.h delete mode 100644 packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.m create mode 100644 packages/subject-segmentation/Package.swift delete mode 100644 packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.m create mode 100644 packages/translation/Package.swift delete mode 100644 packages/translation/ios/Plugin/TranslationPlugin.h delete mode 100644 packages/translation/ios/Plugin/TranslationPlugin.m diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 662d4f8e..9d5e1c48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} jobs: build-android: @@ -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 @@ -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 @@ -124,7 +131,7 @@ jobs: release: name: Release runs-on: ubuntu-latest - needs: [lint] + needs: [ lint ] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/README.md b/README.md index 9bc72d99..9d0abc8e 100644 --- a/README.md +++ b/README.md @@ -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)). -
diff --git a/package.json b/package.json index bb66514f..49cea75e 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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/*'", diff --git a/packages/barcode-scanning/.gitignore b/packages/barcode-scanning/.gitignore index 70ccbf71..d1730919 100644 --- a/packages/barcode-scanning/.gitignore +++ b/packages/barcode-scanning/.gitignore @@ -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 diff --git a/packages/barcode-scanning/Package.swift b/packages/barcode-scanning/Package.swift new file mode 100644 index 00000000..66ea8c4a --- /dev/null +++ b/packages/barcode-scanning/Package.swift @@ -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: "8.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") + ] +) diff --git a/packages/barcode-scanning/ios/Plugin.xcodeproj/project.pbxproj b/packages/barcode-scanning/ios/Plugin.xcodeproj/project.pbxproj index ad0abb0b..fc0097cd 100644 --- a/packages/barcode-scanning/ios/Plugin.xcodeproj/project.pbxproj +++ b/packages/barcode-scanning/ios/Plugin.xcodeproj/project.pbxproj @@ -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 */; }; @@ -40,13 +38,11 @@ 2F98D68124C9AAE400613A4C /* BarcodeScanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarcodeScanner.swift; sourceTree = ""; }; 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 = ""; }; 50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 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 = ""; }; 50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 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 = ""; }; 50E1A94720377CB70090CE1A /* BarcodeScannerPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarcodeScannerPlugin.swift; sourceTree = ""; }; 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 = ""; }; 7C39C34E29A0BB4600AE60BB /* ScanSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanSettings.swift; sourceTree = ""; }; @@ -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 */, @@ -194,7 +188,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 50ADFF99201F53D600D50D53 /* BarcodeScannerPlugin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -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 */, diff --git a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.h b/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.h deleted file mode 100644 index f2bd9e0b..00000000 --- a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -//! Project version number for Plugin. -FOUNDATION_EXPORT double PluginVersionNumber; - -//! Project version string for Plugin. -FOUNDATION_EXPORT const unsigned char PluginVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - diff --git a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.m b/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.m deleted file mode 100644 index 5c5a1e13..00000000 --- a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.m +++ /dev/null @@ -1,26 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(BarcodeScannerPlugin, "BarcodeScanner", - CAP_PLUGIN_METHOD(startScan, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(stopScan, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(readBarcodesFromImage, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(scan, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(isSupported, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(enableTorch, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(disableTorch, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(toggleTorch, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(isTorchEnabled, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(isTorchAvailable, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setZoomRatio, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(getZoomRatio, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(getMinZoomRatio, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(getMaxZoomRatio, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(openSettings, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(isGoogleBarcodeScannerModuleAvailable, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(installGoogleBarcodeScannerModule, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(checkPermissions, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(requestPermissions, CAPPluginReturnPromise); -) diff --git a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.swift b/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.swift index 4a4e7fdb..e3c28c7b 100644 --- a/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.swift +++ b/packages/barcode-scanning/ios/Plugin/BarcodeScannerPlugin.swift @@ -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." diff --git a/packages/barcode-scanning/package.json b/packages/barcode-scanning/package.json index 2ef10bbd..fbcfa84e 100644 --- a/packages/barcode-scanning/package.json +++ b/packages/barcode-scanning/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitBarcodeScanning.podspec" + "CapacitorMlkitBarcodeScanning.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/document-scanner/Package.swift b/packages/document-scanner/Package.swift new file mode 100644 index 00000000..ac31fde5 --- /dev/null +++ b/packages/document-scanner/Package.swift @@ -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") + ] +) diff --git a/packages/document-scanner/package.json b/packages/document-scanner/package.json index 2c6ca6b5..8c3b65a2 100644 --- a/packages/document-scanner/package.json +++ b/packages/document-scanner/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitDocumentScanner.podspec" + "CapacitorMlkitDocumentScanner.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/face-detection/.gitignore b/packages/face-detection/.gitignore index 70ccbf71..d1730919 100644 --- a/packages/face-detection/.gitignore +++ b/packages/face-detection/.gitignore @@ -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 diff --git a/packages/face-detection/Package.swift b/packages/face-detection/Package.swift new file mode 100644 index 00000000..3c142016 --- /dev/null +++ b/packages/face-detection/Package.swift @@ -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: "8.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") + ] +) diff --git a/packages/face-detection/ios/Plugin.xcodeproj/project.pbxproj b/packages/face-detection/ios/Plugin.xcodeproj/project.pbxproj index b0a4a123..f1371a99 100644 --- a/packages/face-detection/ios/Plugin.xcodeproj/project.pbxproj +++ b/packages/face-detection/ios/Plugin.xcodeproj/project.pbxproj @@ -12,9 +12,7 @@ 2F98D68224C9AAE500613A4C /* FaceDetection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F98D68124C9AAE400613A4C /* FaceDetection.swift */; }; 50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; }; 50ADFF97201F53D600D50D53 /* FaceDetectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* FaceDetectionTests.swift */; }; - 50ADFF99201F53D600D50D53 /* FaceDetectionPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* FaceDetectionPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; }; - 50ADFFA82020EE4F00D50D53 /* FaceDetectionPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* FaceDetectionPlugin.m */; }; 50E1A94820377CB70090CE1A /* FaceDetectionPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* FaceDetectionPlugin.swift */; }; 7CCB321B2A694ABD007D3E86 /* ProcessImageOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CCB321A2A694ABD007D3E86 /* ProcessImageOptions.swift */; }; 7CCB321D2A694AC8007D3E86 /* ProcessImageResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CCB321C2A694AC8007D3E86 /* ProcessImageResult.swift */; }; @@ -34,13 +32,11 @@ 2F98D68124C9AAE400613A4C /* FaceDetection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceDetection.swift; sourceTree = ""; }; 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 /* FaceDetectionPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FaceDetectionPlugin.h; sourceTree = ""; }; 50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50ADFF96201F53D600D50D53 /* FaceDetectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceDetectionTests.swift; sourceTree = ""; }; 50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 50ADFFA72020EE4F00D50D53 /* FaceDetectionPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FaceDetectionPlugin.m; sourceTree = ""; }; 50E1A94720377CB70090CE1A /* FaceDetectionPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceDetectionPlugin.swift; sourceTree = ""; }; 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 = ""; }; 7CCB321A2A694ABD007D3E86 /* ProcessImageOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessImageOptions.swift; sourceTree = ""; }; @@ -99,8 +95,6 @@ 7CCB32192A694A9B007D3E86 /* Classes */, 50E1A94720377CB70090CE1A /* FaceDetectionPlugin.swift */, 2F98D68124C9AAE400613A4C /* FaceDetection.swift */, - 50ADFF8B201F53D600D50D53 /* FaceDetectionPlugin.h */, - 50ADFFA72020EE4F00D50D53 /* FaceDetectionPlugin.m */, 50ADFF8C201F53D600D50D53 /* Info.plist */, ); path = Plugin; @@ -152,7 +146,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 50ADFF99201F53D600D50D53 /* FaceDetectionPlugin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -374,7 +367,6 @@ 50E1A94820377CB70090CE1A /* FaceDetectionPlugin.swift in Sources */, 2F98D68224C9AAE500613A4C /* FaceDetection.swift in Sources */, 7CCB321B2A694ABD007D3E86 /* ProcessImageOptions.swift in Sources */, - 50ADFFA82020EE4F00D50D53 /* FaceDetectionPlugin.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.h b/packages/face-detection/ios/Plugin/FaceDetectionPlugin.h deleted file mode 100644 index f2bd9e0b..00000000 --- a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -//! Project version number for Plugin. -FOUNDATION_EXPORT double PluginVersionNumber; - -//! Project version string for Plugin. -FOUNDATION_EXPORT const unsigned char PluginVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - diff --git a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.m b/packages/face-detection/ios/Plugin/FaceDetectionPlugin.m deleted file mode 100644 index 65d4cb8f..00000000 --- a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.m +++ /dev/null @@ -1,8 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(FaceDetectionPlugin, "FaceDetection", - CAP_PLUGIN_METHOD(processImage, CAPPluginReturnPromise); -) diff --git a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.swift b/packages/face-detection/ios/Plugin/FaceDetectionPlugin.swift index e9b70131..9b5f6486 100644 --- a/packages/face-detection/ios/Plugin/FaceDetectionPlugin.swift +++ b/packages/face-detection/ios/Plugin/FaceDetectionPlugin.swift @@ -8,7 +8,12 @@ import MLKitFaceDetection * here: https://capacitorjs.com/docs/plugins/ios */ @objc(FaceDetectionPlugin) -public class FaceDetectionPlugin: CAPPlugin { +public class FaceDetectionPlugin: CAPPlugin, CAPBridgedPlugin { + public let identifier = "FaceDetectionPlugin" + public let jsName = "FaceDetection" + public let pluginMethods: [CAPPluginMethod] = [ + CAPPluginMethod(name: "processImage", returnType: CAPPluginReturnPromise) + ] public let tag = "FaceDetection" public let errorPathMissing = "path must be provided." public let errorLoadImageFailed = "image could not be loaded." diff --git a/packages/face-detection/package.json b/packages/face-detection/package.json index 3dbd1d8b..9cb04cb9 100644 --- a/packages/face-detection/package.json +++ b/packages/face-detection/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitFaceDetection.podspec" + "CapacitorMlkitFaceDetection.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/face-mesh-detection/.gitignore b/packages/face-mesh-detection/.gitignore index 70ccbf71..d1730919 100644 --- a/packages/face-mesh-detection/.gitignore +++ b/packages/face-mesh-detection/.gitignore @@ -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 diff --git a/packages/face-mesh-detection/Package.swift b/packages/face-mesh-detection/Package.swift new file mode 100644 index 00000000..129a881b --- /dev/null +++ b/packages/face-mesh-detection/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "CapacitorMlkitFaceMeshDetection", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapacitorMlkitFaceMeshDetection", + targets: ["FaceMeshDetectionPlugin"]) + ], + dependencies: [ + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0") + ], + targets: [ + .target( + name: "FaceMeshDetectionPlugin", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm") + ], + path: "ios/Plugin"), + .testTarget( + name: "FaceMeshDetectionPluginTests", + dependencies: ["FaceMeshDetectionPlugin"], + path: "ios/PluginTests") + ] +) diff --git a/packages/face-mesh-detection/ios/Plugin.xcodeproj/project.pbxproj b/packages/face-mesh-detection/ios/Plugin.xcodeproj/project.pbxproj index 5e18e5a0..c962940a 100644 --- a/packages/face-mesh-detection/ios/Plugin.xcodeproj/project.pbxproj +++ b/packages/face-mesh-detection/ios/Plugin.xcodeproj/project.pbxproj @@ -12,9 +12,7 @@ 2F98D68224C9AAE500613A4C /* FaceMeshDetection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F98D68124C9AAE400613A4C /* FaceMeshDetection.swift */; }; 50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; }; 50ADFF97201F53D600D50D53 /* FaceMeshDetectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* FaceMeshDetectionTests.swift */; }; - 50ADFF99201F53D600D50D53 /* FaceMeshDetectionPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* FaceMeshDetectionPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; }; - 50ADFFA82020EE4F00D50D53 /* FaceMeshDetectionPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* FaceMeshDetectionPlugin.m */; }; 50E1A94820377CB70090CE1A /* FaceMeshDetectionPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* FaceMeshDetectionPlugin.swift */; }; /* End PBXBuildFile section */ @@ -32,13 +30,11 @@ 2F98D68124C9AAE400613A4C /* FaceMeshDetection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceMeshDetection.swift; sourceTree = ""; }; 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 /* FaceMeshDetectionPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FaceMeshDetectionPlugin.h; sourceTree = ""; }; 50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50ADFF96201F53D600D50D53 /* FaceMeshDetectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceMeshDetectionTests.swift; sourceTree = ""; }; 50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 50ADFFA72020EE4F00D50D53 /* FaceMeshDetectionPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FaceMeshDetectionPlugin.m; sourceTree = ""; }; 50E1A94720377CB70090CE1A /* FaceMeshDetectionPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaceMeshDetectionPlugin.swift; sourceTree = ""; }; 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 = ""; }; 91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.release.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig"; sourceTree = ""; }; @@ -94,8 +90,6 @@ children = ( 50E1A94720377CB70090CE1A /* FaceMeshDetectionPlugin.swift */, 2F98D68124C9AAE400613A4C /* FaceMeshDetection.swift */, - 50ADFF8B201F53D600D50D53 /* FaceMeshDetectionPlugin.h */, - 50ADFFA72020EE4F00D50D53 /* FaceMeshDetectionPlugin.m */, 50ADFF8C201F53D600D50D53 /* Info.plist */, ); path = Plugin; @@ -138,7 +132,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 50ADFF99201F53D600D50D53 /* FaceMeshDetectionPlugin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -308,7 +301,6 @@ files = ( 50E1A94820377CB70090CE1A /* FaceMeshDetectionPlugin.swift in Sources */, 2F98D68224C9AAE500613A4C /* FaceMeshDetection.swift in Sources */, - 50ADFFA82020EE4F00D50D53 /* FaceMeshDetectionPlugin.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.h b/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.h deleted file mode 100644 index f2bd9e0b..00000000 --- a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -//! Project version number for Plugin. -FOUNDATION_EXPORT double PluginVersionNumber; - -//! Project version string for Plugin. -FOUNDATION_EXPORT const unsigned char PluginVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - diff --git a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.m b/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.m deleted file mode 100644 index 94425584..00000000 --- a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.m +++ /dev/null @@ -1,8 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(FaceMeshDetectionPlugin, "FaceMeshDetection", - CAP_PLUGIN_METHOD(processImage, CAPPluginReturnPromise); -) diff --git a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.swift b/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.swift index d384db94..9f0d453f 100644 --- a/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.swift +++ b/packages/face-mesh-detection/ios/Plugin/FaceMeshDetectionPlugin.swift @@ -6,7 +6,12 @@ import Capacitor * here: https://capacitorjs.com/docs/plugins/ios */ @objc(FaceMeshDetectionPlugin) -public class FaceMeshDetectionPlugin: CAPPlugin { +public class FaceMeshDetectionPlugin: CAPPlugin, CAPBridgedPlugin { + public let identifier = "FaceMeshDetectionPlugin" + public let jsName = "FaceMeshDetection" + public let pluginMethods: [CAPPluginMethod] = [ + CAPPluginMethod(name: "processImage", returnType: CAPPluginReturnPromise) + ] private let implementation = FaceMeshDetection() @objc func processImage(_ call: CAPPluginCall) { diff --git a/packages/face-mesh-detection/package.json b/packages/face-mesh-detection/package.json index 47593f55..fa0a45fd 100644 --- a/packages/face-mesh-detection/package.json +++ b/packages/face-mesh-detection/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitFaceMeshDetection.podspec" + "CapacitorMlkitFaceMeshDetection.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/selfie-segmentation/.gitignore b/packages/selfie-segmentation/.gitignore index 70ccbf71..d1730919 100644 --- a/packages/selfie-segmentation/.gitignore +++ b/packages/selfie-segmentation/.gitignore @@ -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 diff --git a/packages/selfie-segmentation/Package.swift b/packages/selfie-segmentation/Package.swift new file mode 100644 index 00000000..8dc2c7ee --- /dev/null +++ b/packages/selfie-segmentation/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "CapacitorMlkitSelfieSegmentation", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapacitorMlkitSelfieSegmentation", + targets: ["SelfieSegmentationPlugin"]) + ], + 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: "8.0.0")) + ], + targets: [ + .target( + name: "SelfieSegmentationPlugin", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm"), + .product(name: "MLKitSegmentationSelfie", package: "google-mlkit-swiftpm") + ], + path: "ios/Plugin"), + .testTarget( + name: "SelfieSegmentationPluginTests", + dependencies: ["SelfieSegmentationPlugin"], + path: "ios/PluginTests") + ] +) diff --git a/packages/selfie-segmentation/ios/Plugin.xcodeproj/project.pbxproj b/packages/selfie-segmentation/ios/Plugin.xcodeproj/project.pbxproj index c853230b..d77cef4a 100644 --- a/packages/selfie-segmentation/ios/Plugin.xcodeproj/project.pbxproj +++ b/packages/selfie-segmentation/ios/Plugin.xcodeproj/project.pbxproj @@ -14,9 +14,7 @@ 4A4E0DE62AA478A800BED263 /* ProcessImageResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4E0DE42AA478A800BED263 /* ProcessImageResult.swift */; }; 50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; }; 50ADFF97201F53D600D50D53 /* SelfieSegmentationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* SelfieSegmentationTests.swift */; }; - 50ADFF99201F53D600D50D53 /* SelfieSegmentationPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* SelfieSegmentationPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; }; - 50ADFFA82020EE4F00D50D53 /* SelfieSegmentationPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* SelfieSegmentationPlugin.m */; }; 50E1A94820377CB70090CE1A /* SelfieSegmentationPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* SelfieSegmentationPlugin.swift */; }; /* End PBXBuildFile section */ @@ -36,13 +34,11 @@ 4A4E0DE32AA478A800BED263 /* ProcessImageOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProcessImageOptions.swift; path = Classes/ProcessImageOptions.swift; sourceTree = ""; }; 4A4E0DE42AA478A800BED263 /* ProcessImageResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProcessImageResult.swift; path = Classes/ProcessImageResult.swift; sourceTree = ""; }; 50ADFF88201F53D600D50D53 /* Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 50ADFF8B201F53D600D50D53 /* SelfieSegmentationPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SelfieSegmentationPlugin.h; sourceTree = ""; }; 50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50ADFF96201F53D600D50D53 /* SelfieSegmentationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfieSegmentationTests.swift; sourceTree = ""; }; 50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 50ADFFA72020EE4F00D50D53 /* SelfieSegmentationPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SelfieSegmentationPlugin.m; sourceTree = ""; }; 50E1A94720377CB70090CE1A /* SelfieSegmentationPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelfieSegmentationPlugin.swift; sourceTree = ""; }; 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 = ""; }; 91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.release.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig"; sourceTree = ""; }; @@ -108,8 +104,6 @@ 4A4E0DE22AA4788400BED263 /* Classes */, 50E1A94720377CB70090CE1A /* SelfieSegmentationPlugin.swift */, 2F98D68124C9AAE400613A4C /* SelfieSegmentation.swift */, - 50ADFF8B201F53D600D50D53 /* SelfieSegmentationPlugin.h */, - 50ADFFA72020EE4F00D50D53 /* SelfieSegmentationPlugin.m */, 50ADFF8C201F53D600D50D53 /* Info.plist */, ); path = Plugin; @@ -152,7 +146,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 50ADFF99201F53D600D50D53 /* SelfieSegmentationPlugin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -382,7 +375,6 @@ 50E1A94820377CB70090CE1A /* SelfieSegmentationPlugin.swift in Sources */, 2F98D68224C9AAE500613A4C /* SelfieSegmentation.swift in Sources */, 4A4E0DE52AA478A800BED263 /* ProcessImageOptions.swift in Sources */, - 50ADFFA82020EE4F00D50D53 /* SelfieSegmentationPlugin.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.h b/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.h deleted file mode 100644 index f2bd9e0b..00000000 --- a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -//! Project version number for Plugin. -FOUNDATION_EXPORT double PluginVersionNumber; - -//! Project version string for Plugin. -FOUNDATION_EXPORT const unsigned char PluginVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - diff --git a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.m b/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.m deleted file mode 100644 index 6ec0c6ba..00000000 --- a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.m +++ /dev/null @@ -1,8 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(SelfieSegmentationPlugin, "SelfieSegmentation", - CAP_PLUGIN_METHOD(processImage, CAPPluginReturnPromise); -) diff --git a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.swift b/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.swift index 1aa75515..cc81e980 100644 --- a/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.swift +++ b/packages/selfie-segmentation/ios/Plugin/SelfieSegmentationPlugin.swift @@ -6,7 +6,12 @@ import Capacitor * here: https://capacitorjs.com/docs/plugins/ios */ @objc(SelfieSegmentationPlugin) -public class SelfieSegmentationPlugin: CAPPlugin { +public class SelfieSegmentationPlugin: CAPPlugin, CAPBridgedPlugin { + public let identifier = "SelfieSegmentationPlugin" + public let jsName = "SelfieSegmentation" + public let pluginMethods: [CAPPluginMethod] = [ + CAPPluginMethod(name: "processImage", returnType: CAPPluginReturnPromise) + ] public let tag = "SelfieSegmentation" public let errorPathMissing = "path must be provided." diff --git a/packages/selfie-segmentation/package.json b/packages/selfie-segmentation/package.json index ac37d05e..132ec2d4 100644 --- a/packages/selfie-segmentation/package.json +++ b/packages/selfie-segmentation/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitSelfieSegmentation.podspec" + "CapacitorMlkitSelfieSegmentation.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/subject-segmentation/Package.swift b/packages/subject-segmentation/Package.swift new file mode 100644 index 00000000..0ab661e5 --- /dev/null +++ b/packages/subject-segmentation/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "CapacitorMlkitSubjectSegmentation", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapacitorMlkitSubjectSegmentation", + targets: ["SubjectSegmentationPlugin"]) + ], + dependencies: [ + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0") + ], + targets: [ + .target( + name: "SubjectSegmentationPlugin", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm") + ], + path: "ios/Plugin"), + .testTarget( + name: "SubjectSegmentationPluginTests", + dependencies: ["SubjectSegmentationPlugin"], + path: "ios/PluginTests") + ] +) diff --git a/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.m b/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.m deleted file mode 100644 index 9ed28352..00000000 --- a/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.m +++ /dev/null @@ -1,10 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(SubjectSegmentationPlugin, "SubjectSegmentation", - CAP_PLUGIN_METHOD(processImage, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(isGoogleSubjectSegmentationModuleAvailable, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(installGoogleSubjectSegmentationModule, CAPPluginReturnPromise); -) diff --git a/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.swift b/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.swift index b59d8d4d..0411f5f3 100644 --- a/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.swift +++ b/packages/subject-segmentation/ios/Plugin/SubjectSegmentationPlugin.swift @@ -6,7 +6,14 @@ import Capacitor * here: https://capacitorjs.com/docs/plugins/ios */ @objc(SubjectSegmentationPlugin) -public class SubjectSegmentationPlugin: CAPPlugin { +public class SubjectSegmentationPlugin: CAPPlugin, CAPBridgedPlugin { + public let identifier = "SubjectSegmentationPlugin" + public let jsName = "SubjectSegmentation" + public let pluginMethods: [CAPPluginMethod] = [ + CAPPluginMethod(name: "processImage", returnType: CAPPluginReturnPromise), + CAPPluginMethod(name: "isGoogleSubjectSegmentationModuleAvailable", returnType: CAPPluginReturnPromise), + CAPPluginMethod(name: "installGoogleSubjectSegmentationModule", returnType: CAPPluginReturnPromise) + ] private let implementation = SubjectSegmentation() @objc func processImage(_ call: CAPPluginCall) { diff --git a/packages/subject-segmentation/package.json b/packages/subject-segmentation/package.json index 26260afa..75f358e1 100644 --- a/packages/subject-segmentation/package.json +++ b/packages/subject-segmentation/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitSubjectSegmentation.podspec" + "CapacitorMlkitSubjectSegmentation.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/packages/translation/.gitignore b/packages/translation/.gitignore index 70ccbf71..d1730919 100644 --- a/packages/translation/.gitignore +++ b/packages/translation/.gitignore @@ -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 diff --git a/packages/translation/Package.swift b/packages/translation/Package.swift new file mode 100644 index 00000000..1ac097c2 --- /dev/null +++ b/packages/translation/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "CapacitorMlkitTranslation", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapacitorMlkitTranslation", + targets: ["TranslationPlugin"]) + ], + 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: "8.0.0")) + ], + targets: [ + .target( + name: "TranslationPlugin", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm"), + .product(name: "MLKitTranslate", package: "google-mlkit-swiftpm") + ], + path: "ios/Plugin"), + .testTarget( + name: "TranslationPluginTests", + dependencies: ["TranslationPlugin"], + path: "ios/PluginTests") + ] +) diff --git a/packages/translation/ios/Plugin.xcodeproj/project.pbxproj b/packages/translation/ios/Plugin.xcodeproj/project.pbxproj index 36f6e671..e0808033 100644 --- a/packages/translation/ios/Plugin.xcodeproj/project.pbxproj +++ b/packages/translation/ios/Plugin.xcodeproj/project.pbxproj @@ -12,9 +12,7 @@ 2F98D68224C9AAE500613A4C /* Translation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F98D68124C9AAE400613A4C /* Translation.swift */; }; 50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; }; 50ADFF97201F53D600D50D53 /* TranslationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* TranslationTests.swift */; }; - 50ADFF99201F53D600D50D53 /* TranslationPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* TranslationPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; }; - 50ADFFA82020EE4F00D50D53 /* TranslationPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* TranslationPlugin.m */; }; 50E1A94820377CB70090CE1A /* TranslationPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* TranslationPlugin.swift */; }; /* End PBXBuildFile section */ @@ -32,13 +30,11 @@ 2F98D68124C9AAE400613A4C /* Translation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Translation.swift; sourceTree = ""; }; 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 /* TranslationPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TranslationPlugin.h; sourceTree = ""; }; 50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50ADFF96201F53D600D50D53 /* TranslationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslationTests.swift; sourceTree = ""; }; 50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 50ADFFA72020EE4F00D50D53 /* TranslationPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TranslationPlugin.m; sourceTree = ""; }; 50E1A94720377CB70090CE1A /* TranslationPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranslationPlugin.swift; sourceTree = ""; }; 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 = ""; }; 91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.release.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig"; sourceTree = ""; }; @@ -94,8 +90,6 @@ children = ( 50E1A94720377CB70090CE1A /* TranslationPlugin.swift */, 2F98D68124C9AAE400613A4C /* Translation.swift */, - 50ADFF8B201F53D600D50D53 /* TranslationPlugin.h */, - 50ADFFA72020EE4F00D50D53 /* TranslationPlugin.m */, 50ADFF8C201F53D600D50D53 /* Info.plist */, ); path = Plugin; @@ -138,7 +132,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 50ADFF99201F53D600D50D53 /* TranslationPlugin.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -360,7 +353,6 @@ files = ( 50E1A94820377CB70090CE1A /* TranslationPlugin.swift in Sources */, 2F98D68224C9AAE500613A4C /* Translation.swift in Sources */, - 50ADFFA82020EE4F00D50D53 /* TranslationPlugin.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/packages/translation/ios/Plugin/TranslationPlugin.h b/packages/translation/ios/Plugin/TranslationPlugin.h deleted file mode 100644 index f2bd9e0b..00000000 --- a/packages/translation/ios/Plugin/TranslationPlugin.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -//! Project version number for Plugin. -FOUNDATION_EXPORT double PluginVersionNumber; - -//! Project version string for Plugin. -FOUNDATION_EXPORT const unsigned char PluginVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - diff --git a/packages/translation/ios/Plugin/TranslationPlugin.m b/packages/translation/ios/Plugin/TranslationPlugin.m deleted file mode 100644 index 9921795c..00000000 --- a/packages/translation/ios/Plugin/TranslationPlugin.m +++ /dev/null @@ -1,11 +0,0 @@ -#import -#import - -// Define the plugin using the CAP_PLUGIN Macro, and -// each method the plugin supports using the CAP_PLUGIN_METHOD macro. -CAP_PLUGIN(TranslationPlugin, "Translation", - CAP_PLUGIN_METHOD(deleteDownloadedModel, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(downloadModel, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(getDownloadedModels, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(translate, CAPPluginReturnPromise); -) diff --git a/packages/translation/ios/Plugin/TranslationPlugin.swift b/packages/translation/ios/Plugin/TranslationPlugin.swift index e1f21aac..43149faf 100644 --- a/packages/translation/ios/Plugin/TranslationPlugin.swift +++ b/packages/translation/ios/Plugin/TranslationPlugin.swift @@ -7,7 +7,15 @@ import MLKitTranslate * here: https://capacitorjs.com/docs/plugins/ios */ @objc(TranslationPlugin) -public class TranslationPlugin: CAPPlugin { +public class TranslationPlugin: CAPPlugin, CAPBridgedPlugin { + public let identifier = "TranslationPlugin" + public let jsName = "Translation" + public let pluginMethods: [CAPPluginMethod] = [ + CAPPluginMethod(name: "deleteDownloadedModel", returnType: CAPPluginReturnPromise), + CAPPluginMethod(name: "downloadModel", returnType: CAPPluginReturnPromise), + CAPPluginMethod(name: "getDownloadedModels", returnType: CAPPluginReturnPromise), + CAPPluginMethod(name: "translate", returnType: CAPPluginReturnPromise) + ] public let errorLanguageMissing = "language must be provided." public let errorTextMissing = "text must be provided." public let errorSourceLanguageMissing = "sourceLanguage must be provided." diff --git a/packages/translation/package.json b/packages/translation/package.json index 16c10437..5826cfac 100644 --- a/packages/translation/package.json +++ b/packages/translation/package.json @@ -11,7 +11,8 @@ "android/build.gradle", "dist/", "ios/Plugin/", - "CapacitorMlkitTranslation.podspec" + "CapacitorMlkitTranslation.podspec", + "Package.swift" ], "author": "Robin Genz ", "license": "Apache-2.0", @@ -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 ..", "prepublishOnly": "npm run build" }, "devDependencies": { diff --git a/turbo.json b/turbo.json index a111a1ab..35334fff 100644 --- a/turbo.json +++ b/turbo.json @@ -11,6 +11,7 @@ "dev": { "cache": false }, - "ios:pod:install": {} + "ios:pod:install": {}, + "ios:spm:install": {} } } From 1b23d59a5a0fcc147395ebb79d9b065a66a6005c Mon Sep 17 00:00:00 2001 From: Robin Genz Date: Fri, 17 Apr 2026 13:07:28 +0200 Subject: [PATCH 2/3] Update README.md --- packages/barcode-scanning/README.md | 7 +++++-- packages/face-detection/README.md | 7 +++++-- packages/selfie-segmentation/README.md | 7 +++++-- packages/translation/README.md | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/barcode-scanning/README.md b/packages/barcode-scanning/README.md index eeff1232..80a75caf 100644 --- a/packages/barcode-scanning/README.md +++ b/packages/barcode-scanning/README.md @@ -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 @@ -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: diff --git a/packages/face-detection/README.md b/packages/face-detection/README.md index a82b746a..a381f6ee 100644 --- a/packages/face-detection/README.md +++ b/packages/face-detection/README.md @@ -42,8 +42,6 @@ npm install @capacitor-mlkit/face-detection 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 #### Dependencies @@ -74,6 +72,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. + ## Configuration No configuration required for this plugin. diff --git a/packages/selfie-segmentation/README.md b/packages/selfie-segmentation/README.md index f2c8b599..3798be33 100644 --- a/packages/selfie-segmentation/README.md +++ b/packages/selfie-segmentation/README.md @@ -42,8 +42,6 @@ npm install @capacitor-mlkit/selfie-segmentation 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 #### Variables @@ -64,6 +62,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. + ## Configuration No configuration required for this plugin. diff --git a/packages/translation/README.md b/packages/translation/README.md index f23eff93..be16c99b 100644 --- a/packages/translation/README.md +++ b/packages/translation/README.md @@ -43,8 +43,6 @@ npm install @capacitor-mlkit/translation 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 #### Variables @@ -65,6 +63,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. + ## Configuration No configuration required for this plugin. From 31d9b93ecc0b836e947e7e383b19c5afdb9d9a02 Mon Sep 17 00:00:00 2001 From: Robin Genz Date: Mon, 20 Apr 2026 19:37:31 +0200 Subject: [PATCH 3/3] chore(deps): update ML Kit to v9 --- packages/barcode-scanning/CapacitorMlkitBarcodeScanning.podspec | 2 +- packages/barcode-scanning/Package.swift | 2 +- packages/barcode-scanning/ios/Podfile | 2 +- packages/face-detection/CapacitorMlkitFaceDetection.podspec | 2 +- packages/face-detection/Package.swift | 2 +- packages/face-detection/ios/Podfile | 2 +- .../CapacitorMlkitSelfieSegmentation.podspec | 2 +- packages/selfie-segmentation/Package.swift | 2 +- packages/selfie-segmentation/ios/Podfile | 2 +- packages/translation/CapacitorMlkitTranslation.podspec | 2 +- packages/translation/Package.swift | 2 +- packages/translation/ios/Podfile | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/barcode-scanning/CapacitorMlkitBarcodeScanning.podspec b/packages/barcode-scanning/CapacitorMlkitBarcodeScanning.podspec index 217dd80b..c197ba51 100644 --- a/packages/barcode-scanning/CapacitorMlkitBarcodeScanning.podspec +++ b/packages/barcode-scanning/CapacitorMlkitBarcodeScanning.podspec @@ -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 diff --git a/packages/barcode-scanning/Package.swift b/packages/barcode-scanning/Package.swift index 66ea8c4a..9643e76a 100644 --- a/packages/barcode-scanning/Package.swift +++ b/packages/barcode-scanning/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], 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: "8.0.0")) + .package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0")) ], targets: [ .target( diff --git a/packages/barcode-scanning/ios/Podfile b/packages/barcode-scanning/ios/Podfile index c76cd1d2..8fc3c47a 100644 --- a/packages/barcode-scanning/ios/Podfile +++ b/packages/barcode-scanning/ios/Podfile @@ -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 diff --git a/packages/face-detection/CapacitorMlkitFaceDetection.podspec b/packages/face-detection/CapacitorMlkitFaceDetection.podspec index cc9d08b8..80a699bd 100644 --- a/packages/face-detection/CapacitorMlkitFaceDetection.podspec +++ b/packages/face-detection/CapacitorMlkitFaceDetection.podspec @@ -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 diff --git a/packages/face-detection/Package.swift b/packages/face-detection/Package.swift index 3c142016..5c76a088 100644 --- a/packages/face-detection/Package.swift +++ b/packages/face-detection/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], 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: "8.0.0")) + .package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0")) ], targets: [ .target( diff --git a/packages/face-detection/ios/Podfile b/packages/face-detection/ios/Podfile index 9b8aa3a4..56399aa8 100644 --- a/packages/face-detection/ios/Podfile +++ b/packages/face-detection/ios/Podfile @@ -9,7 +9,7 @@ end target 'Plugin' do capacitor_pods - pod 'GoogleMLKit/FaceDetection', '8.0.0' + pod 'GoogleMLKit/FaceDetection', '9.0.0' end target 'PluginTests' do diff --git a/packages/selfie-segmentation/CapacitorMlkitSelfieSegmentation.podspec b/packages/selfie-segmentation/CapacitorMlkitSelfieSegmentation.podspec index b940e8ea..33522318 100644 --- a/packages/selfie-segmentation/CapacitorMlkitSelfieSegmentation.podspec +++ b/packages/selfie-segmentation/CapacitorMlkitSelfieSegmentation.podspec @@ -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/SegmentationSelfie', '~> 8.0.0' + s.dependency 'GoogleMLKit/SegmentationSelfie', '~> 9.0.0' s.swift_version = '5.1' s.static_framework = true end diff --git a/packages/selfie-segmentation/Package.swift b/packages/selfie-segmentation/Package.swift index 8dc2c7ee..d1ad5df9 100644 --- a/packages/selfie-segmentation/Package.swift +++ b/packages/selfie-segmentation/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], 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: "8.0.0")) + .package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0")) ], targets: [ .target( diff --git a/packages/selfie-segmentation/ios/Podfile b/packages/selfie-segmentation/ios/Podfile index 52097756..36762740 100644 --- a/packages/selfie-segmentation/ios/Podfile +++ b/packages/selfie-segmentation/ios/Podfile @@ -9,7 +9,7 @@ end target 'Plugin' do capacitor_pods - pod 'GoogleMLKit/SegmentationSelfie', '8.0.0' + pod 'GoogleMLKit/SegmentationSelfie', '9.0.0' end target 'PluginTests' do diff --git a/packages/translation/CapacitorMlkitTranslation.podspec b/packages/translation/CapacitorMlkitTranslation.podspec index 8abd8329..5cee6934 100644 --- a/packages/translation/CapacitorMlkitTranslation.podspec +++ b/packages/translation/CapacitorMlkitTranslation.podspec @@ -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/Translate', '~> 8.0.0' + s.dependency 'GoogleMLKit/Translate', '~> 9.0.0' s.swift_version = '5.1' s.static_framework = true end diff --git a/packages/translation/Package.swift b/packages/translation/Package.swift index 1ac097c2..85d1d6ea 100644 --- a/packages/translation/Package.swift +++ b/packages/translation/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], 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: "8.0.0")) + .package(url: "https://github.com/d-date/google-mlkit-swiftpm.git", .upToNextMinor(from: "9.0.0")) ], targets: [ .target( diff --git a/packages/translation/ios/Podfile b/packages/translation/ios/Podfile index 19b2dc4a..71737aee 100644 --- a/packages/translation/ios/Podfile +++ b/packages/translation/ios/Podfile @@ -9,7 +9,7 @@ end target 'Plugin' do capacitor_pods - pod 'GoogleMLKit/Translate', '8.0.0' + pod 'GoogleMLKit/Translate', '9.0.0' end target 'PluginTests' do