Skip to content

Commit dea2cf2

Browse files
committed
ci: test Capacitor iOS build with Capacitor 6 and 7 matrix
- Revert SPM workarounds: use idiomatic call.reject()/getString() - Test against Capacitor 6 and 7 (both CocoaPods-default) - Auto-detect SPM vs CocoaPods and use correct xcodebuild flags - Log which package manager each version creates
1 parent 4609e0e commit dea2cf2

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

.github/workflows/build-capacitor-ios.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: macos-14
11+
runs-on: macos-15
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- capacitor-version: '6'
17+
xcode-version: '16.2'
18+
- capacitor-version: '7'
19+
xcode-version: '16.2'
1220
steps:
1321
- uses: actions/checkout@v4
1422

@@ -20,7 +28,7 @@ jobs:
2028
- name: Select Xcode
2129
uses: maxim-lobanov/setup-xcode@v1
2230
with:
23-
xcode-version: '15.4'
31+
xcode-version: ${{ matrix.xcode-version }}
2432

2533
- name: Install dependencies and build TypeScript
2634
run: |
@@ -29,19 +37,23 @@ jobs:
2937
3038
- name: Install Capacitor CLI and create test app
3139
run: |
32-
npm install -g @capacitor/cli
40+
npm install -g @capacitor/cli@${{ matrix.capacitor-version }}
3341
npx @capacitor/create-app test-cap-app --name TestApp --app-id com.test.app
3442
cd test-cap-app
35-
npm install @capacitor/ios
43+
npm install @capacitor/ios@${{ matrix.capacitor-version }}
3644
npx cap add ios
45+
# Log which package manager was used
46+
if [ -d ios/App/CapApp-SPM ]; then
47+
echo "::notice::Capacitor ${{ matrix.capacitor-version }} created an SPM project"
48+
else
49+
echo "::notice::Capacitor ${{ matrix.capacitor-version }} created a CocoaPods project"
50+
fi
3751
3852
- name: Install plugin
3953
run: |
4054
cd test-cap-app
41-
# Create minimal web assets (required by cap sync)
4255
mkdir -p dist
4356
echo '<html><body></body></html>' > dist/index.html
44-
# Remove default plugins to avoid version conflicts
4557
npm uninstall @capacitor/camera @capacitor/splash-screen 2>/dev/null || true
4658
cp "$GITHUB_WORKSPACE/www/store.js" "$GITHUB_WORKSPACE/capacitor/www/store.js"
4759
cp "$GITHUB_WORKSPACE/www/store.d.ts" "$GITHUB_WORKSPACE/capacitor/www/store.d.ts"
@@ -51,7 +63,14 @@ jobs:
5163
- name: Build iOS
5264
run: |
5365
cd test-cap-app/ios/App
66+
# Use workspace if CocoaPods (Podfile.lock exists), plain scheme if SPM
67+
if [ -f Podfile.lock ]; then
68+
BUILD_ARGS="-workspace App.xcworkspace"
69+
else
70+
BUILD_ARGS=""
71+
fi
5472
xcodebuild build \
73+
$BUILD_ARGS \
5574
-scheme App \
5675
-sdk iphoneos \
5776
CODE_SIGN_IDENTITY="" \

capacitor/ios/Sources/PurchasePlugin/PurchasePlugin.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,8 @@ public class PurchasePlugin: CAPPlugin, CAPBridgedPlugin {
376376
}
377377
}
378378

379-
/// Wrapper for call.reject that works with both CocoaPods (source) and SPM (precompiled xcframework).
380-
/// The xcframework doesn't export Swift extension methods or initializers with bare nil args,
381-
/// so we use typed locals to give the compiler enough context.
382379
private func rejectCall(_ call: CAPPluginCall, _ message: String) {
383-
let code: String? = nil
384-
let err: Error? = nil
385-
let data: [String: Any] = [:]
386-
let error = CAPPluginCallError(message: message, code: code, error: err, data: data)
387-
call.errorHandler(error)
380+
call.reject(message)
388381
}
389382

390383
private func debugLog(_ msg: String) {

0 commit comments

Comments
 (0)