SPM autolinking hardcodes iOS 15, so libraries whose Package.swift requires iOS 16+ can't be autolinked
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, react-native, swift
- Bereich
- build-system, mobile, tooling
Rechercherichtung
Beginne mit scripts/spm/generate-spm-autolinking.js bei den Plattformdeklarationen um die Zeilen 1072 und 1220 und untersuche anschließend scripts/spm/scaffold-package-swift.js um Zeile 769 sowie die .xcodeproj-Änderungen des Injectors. Führe npx react-native spm update mit dem obligatorischen Reproducer aus; erledigt bedeutet, dass die generierten Manifeste ein iOS-Mindestdeployment auswählen, das mit den autoverlinkten Paketen und dem App-Target kompatibel ist, einschließlich der erzeugten Manifeste, und dass der iOS-Build aufgelöst wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
scripts/spm/generate-spm-autolinking.js writes the top-level Autolinked package with a literal minimum platform (line 1072 in 0.87.1):
let package = Package(
name: "Autolinked",
platforms: [.iOS(.v15)],
Its AutolinkedAggregate target depends on the product of every autolinked library. SwiftPM doesn't let a target depend on a product whose package declares a higher minimum platform, so a self-managed library whose Package.swift declares .iOS(.v16) or later fails package resolution. That happens even when the app's own deployment target is 16.0 or higher. The library can't declare iOS 15 instead when its own dependencies need iOS 16, because SwiftPM applies the same check on that edge.
The same literal appears in two more places, which a fix should cover too:
- the per-dependency packages synthesized for podspec-based libraries (
generate-spm-autolinking.js, line 1220) - the manifests
npx react-native spm scaffoldwrites (scaffold-package-swift.js, line 769)
Suggested fix, in order of preference, instead of the literal:
- The highest
.iOS(...)declared by an autolinked self-managed package. The aggregate has to be at least that, and the app target must already be at least that to link the library. - The app target's
IPHONEOS_DEPLOYMENT_TARGET, read from the.xcodeprojthe injector already edits. - An explicit
spm.minimumIosVersionin the app'sreact-native.config.js.
Workaround, applied with patch-package:
--- a/node_modules/react-native/scripts/spm/generate-spm-autolinking.js
+++ b/node_modules/react-native/scripts/spm/generate-spm-autolinking.js
@@ -1069,7 +1069,7 @@
${guardBlock}let package = Package(
name: "${AUTOLINKED_PACKAGE_NAME}",
- platforms: [.iOS(.v15)],
+ platforms: [.iOS(.v16)],
products: [
.library(name: "${AUTOLINKED_PACKAGE_NAME}", targets: ["AutolinkedAggregate"]),
],
Steps to reproduce
- Create a React Native 0.87.1 app and migrate it to SPM with
npx react-native spm. - Add a native module that ships its own
Package.swiftdeclaringplatforms: [.iOS(.v16)]. - Raise the app target's
IPHONEOS_DEPLOYMENT_TARGETto 16.0. - Run
npx react-native spm updateand build.
Expected: the packages resolve, since the app and the library both target iOS 16.
Actual: resolution fails with the error below.
React Native Version
0.87.1
Affected Platforms
Build - MacOS, Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 26.7
CPU: (16) arm64 Apple M4 Max
Memory: 17.97 GB / 128.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.19.0
path: /usr/local/bin/node
Yarn:
version: 4.11.0
path: /opt/homebrew/bin/yarn
npm:
version: 10.9.3
path: /usr/local/bin/npm
Watchman:
version: 2025.11.10.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: ~/.gem/ruby/3.4.0/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.2
- iOS 26.2
- macOS 26.2
- tvOS 26.2
- visionOS 26.2
- watchOS 26.2
Android SDK:
API Levels:
- "36"
- "37"
Build Tools:
- 35.0.0
- 36.0.0
System Images:
- android-35 | Pre-Release 16 KB Page Size Google APIs ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 26.2/17C52
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.18
path: /usr/bin/javac
Ruby:
version: 3.4.7
path: ~/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.2.0
wanted: 20.2.0
react:
installed: 19.2.3
wanted: 19.2.3
react-native:
installed: 0.87.1
wanted: 0.87.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
error: The package product 'Heracross' requires minimum platform version 16.0 for the iOS platform,
but this target supports 15.0 (in target 'AutolinkedAggregate' from project 'Autolinked')
MANDATORY Reproducer
https://github.com/bstillitano/rn-spm-ios16-repro
Built from the reproducer template (0.87.1): migrated to SPM, deployment target 16.0, and one stub library whose ios/Package.swift declares .iOS(.v16). Its iOS CI job fails with the error above; applying the one-line workaround makes the same build succeed.
Screenshots and Videos
None.
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react/react-native
-
Needs: Triage :mag: Platform: Android Platform: iOS
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
react/react-native#58750 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
react/react-native#58659 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Author Feedback Needs: Repro
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
react/react-native#58621 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Attention Needs: Repro
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
react/react-native#58610 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Needs: Triage :mag:
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
react/react-native#58565 · 1 Kommentar · 2 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in react/react-native
Ähnliche Issues
-
area/ysql kind/bug priority/medium
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
yugabyte/yugabyte-db#34552 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 94/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
ai_p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ClickHouse/ClickHouse#123351 ·
Maintainer antworten meist innerhalb von 1 Tag