[Bug]: cap sync drops the minor version of IPHONEOS_DEPLOYMENT_TARGET in CapApp-SPM/Package.swift, so plugins that require e.g. iOS 15.6 or 16.4 fail to resolve
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ios, swift, typescript
- 領域
- build-system, mobile
調査の方向性
cli/src/ios/common.ts の getMajoriOSVersion と cli/src/util/spm.ts の generatePackageText を読みます。issue には両方のエントリポイントへのリンクと再現手順があります。16.4 などの Deployment Target で再現手順を実行し、生成された ios/App/CapApp-SPM/Package.swift を確認します。iOS プラットフォーム宣言にアプリの完全な Deployment Target が保持され、示されたパッケージ解決が成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 9.0.0
@capacitor/core: 9.0.0
@capacitor/android: 9.0.0
@capacitor/ios: 9.0.0
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 9.0.0
@capacitor/core: 9.0.0
@capacitor/ios: 9.0.0
[success] iOS looking great! 👌
Our app is on Capacitor 8.6.0, where we hit this. The doctor output above is from the reproduction on 9.0.0 (current latest), to show it is still present. Also reproduced with @capacitor/cli 8.6.0 and 8.6.3.
Other API Details
npm 11.20.0, node v26.13.0, Xcode 27.1 (27A9275), SPM
Platforms Affected
- iOS
- Android
- Web
Current Behavior
cap sync ios writes only the major part of the app's deployment target into ios/App/CapApp-SPM/Package.swift.
With IPHONEOS_DEPLOYMENT_TARGET = 16.4 the generated file contains:
platforms: [.iOS(.v16)],
.v16 means 16.0. If any plugin (or an SDK a plugin depends on) declares a minimum between x.1 and x.9, package resolution fails, even though the app's real deployment target satisfies it:
error: The package product 'MinPlugin-product' requires minimum platform version 16.4 for the iOS platform, but this target supports 16.0 (in target 'CapApp-SPM' from project 'CapApp-SPM')
Same result on Capacitor 8.6.0 and 8.6.3 with IPHONEOS_DEPLOYMENT_TARGET = 15.6: the file gets .iOS(.v15) and the error reads "requires minimum platform version 15.6 ... but this target supports 15.0".
The plugin cannot work around it by lowering its own platforms:. When the minimum comes from a dependency (for example a vendor SDK shipped as a binary Swift package that declares .iOS("15.6")), the same error just moves one level down, to the plugin target.
Editing the generated line by hand to .iOS("16.4") makes the project build, but the file is regenerated on every sync.
The same app builds with CocoaPods, because the Podfile carries the full version (platform :ios, '15.6').
getMajoriOSVersion reads two characters after the first IPHONEOS_DEPLOYMENT_TARGET = in project.pbxproj:
and generatePackageText writes that value with the symbolic form:
Expected Behavior
CapApp-SPM/Package.swift declares the same deployment target as the app. When the target has a minor part, the string form is needed, since .vXX only exists for major versions:
platforms: [.iOS("16.4")],
This is not a request to change Capacitor's own minimum. It is only about the generated package matching the value the app already has in Xcode.
Project Reproduction
https://github.com/mgarrido-fiwind/capacitor-spm-minor-version-repro
Additional Information
Steps below (no repo needed). Pass 8.6.0 15.6 or 8.6.3 15.6 as arguments to reproduce on Capacitor 8.
CAP="${1:-9.0.0}" # also reproduces with 8.6.3
TARGET="${2:-16.4}" # use 15.6 with Capacitor 8
SWIFT_PM="${CAP%%.*}.0.0"
mkdir repro && cd repro && mkdir www && touch www/index.html
echo '{"appId":"com.example.repro","appName":"repro","webDir":"www"}' > capacitor.config.json
npm init -y > /dev/null
npm i @capacitor/core@$CAP @capacitor/ios@$CAP && npm i -D @capacitor/cli@$CAP
# A local plugin whose Swift package requires the same minor version as the app.
mkdir -p min-plugin/ios/Sources/MinPlugin
echo '{ "name": "min-plugin", "version": "1.0.0", "capacitor": { "ios": { "src": "ios" } } }' > min-plugin/package.json
cat > min-plugin/Package.swift <<EOF
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "MinPlugin",
platforms: [.iOS("$TARGET")],
products: [.library(name: "MinPlugin", targets: ["MinPlugin"])],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "$SWIFT_PM")
],
targets: [
.target(
name: "MinPlugin",
dependencies: [.product(name: "Capacitor", package: "capacitor-swift-pm")],
path: "ios/Sources/MinPlugin")
]
)
EOF
cat > min-plugin/ios/Sources/MinPlugin/MinPlugin.swift <<'EOF'
import Capacitor
@objc(MinPlugin)
public class MinPlugin: CAPPlugin, CAPBridgedPlugin {
public let identifier = "MinPlugin"
public let jsName = "Min"
public let pluginMethods: [CAPPluginMethod] = []
}
EOF
npm i ./min-plugin
npx cap add ios --packagemanager SPM
sed -i '' "s/IPHONEOS_DEPLOYMENT_TARGET = [0-9.]*;/IPHONEOS_DEPLOYMENT_TARGET = $TARGET;/g" ios/App/App.xcodeproj/project.pbxproj
npx cap sync ios
grep -m1 IPHONEOS_DEPLOYMENT_TARGET ios/App/App.xcodeproj/project.pbxproj
grep platforms ios/App/CapApp-SPM/Package.swift
xcodebuild -project ios/App/App.xcodeproj -scheme App -destination 'generic/platform=iOS' CODE_SIGNING_ALLOWED=NO build 2>&1 | grep -E "error:|BUILD"
Output with the defaults (Capacitor 9.0.0):
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
platforms: [.iOS(.v16)],
error: The package product 'MinPlugin-product' requires minimum platform version 16.4 for the iOS platform, but this target supports 16.0 (in target 'CapApp-SPM' from project 'CapApp-SPM')
** BUILD FAILED **
Output with 8.6.0 15.6 and with 8.6.3 15.6:
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
platforms: [.iOS(.v15)],
error: The package product 'MinPlugin-product' requires minimum platform version 15.6 for the iOS platform, but this target supports 15.0 (in target 'CapApp-SPM' from project 'CapApp-SPM')
** BUILD FAILED **
- 主要言語
- TypeScript
- スター
- 17.1k
- フォーク
- 1.3k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ionic-team/capacitor のほかの issue
-
[Bug]: Plugin call after navigation can be answered before reply proxy is updated対応中かも @MateStrysewske が 71 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
ionic-team/capacitor#8616 ·
メンテナーはふだん 1 日以内に返信
-
help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ionic-team/capacitor#8574 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16)対応中かも @kttalley が 62 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ionic-team/capacitor#8530 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
fix(android): remove unchecked Java compilation warnings対応中かも @Ajamuar が 15 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ionic-team/capacitor#8529 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Plugin proxy is unintentionally Thenable: get-trap default returns function wrapper for 'then' / 'catch' / 'finally'対応中かも @playopsstudio が 198 日前に担当しました。 オープンneeds reproduction
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ionic-team/capacitor#8472 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
ionic-team/capacitor の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
cloudhal-dev/podbay#235 ·
メンテナーはふだん 1 日以内に返信
-
area: bio enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Hilal-11/snaplnk.io#36 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
elecnix/bellwether#570 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
canblmz1/prefix-safe-json#135 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jenkins-infra/plugin-modernizer-stats#220 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信