Repository navigation
fix(ios): make the Swift Package Manager opt-in build, launch and archive - #4368
Merged
Merged
Conversation
…hive $RNMapboxMapsSwiftPackageManager failed in several ways with static pods: - rnmapbox-maps couldn't find the package's modules (no such module 'MapboxMaps'); - the product was linked into both the pod and the app target (duplicate symbols); - the dynamic MapboxCommon, MapboxCoreMaps and Turf frameworks weren't embedded (dyld crash at launch); - Xcode 26 archives failed with "MapboxCommon.xcframework-ios.signature already exists"; - react_native_post_install drops every package reference, so a $RNMapboxMaps.post_install that ran before it (as the docs and the Expo plugin order it) lost the package. Use React Native's spm_dependency for the rnmapbox-maps pod, add the package frameworks to the frameworks CocoaPods embeds, add a script phase that removes the duplicate xcframework signatures, and remove the product an earlier version added to the app targets. `true` selects mapbox-maps-ios with a requirement derived from $RNMapboxMapsVersion. The example Podfile enables it with RNMBX_SPM=1.
Writes $RNMapboxMapsSwiftPackageManager into the Podfile, either `true` or the options hash.
… can react/react-native#58781 makes spm_dependency embed package frameworks through install_spm_framework, defaulting to the products (MapboxMaps, a static product). Where it's supported, pass MapboxCommon, MapboxCoreMaps and Turf as embed_frameworks, and skip our framework_paths_by_config entries when the app has an embed script anyway (a framework or a dynamic xcframework), so they aren't embedded twice.
4 of 8 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The opt-in
$RNMapboxMapsSwiftPackageManagermode didn't work with static pods. It failed withno such module 'MapboxMaps'becausernmapbox-mapshad no include path to the package modules. With the include path added, linking the product into both the pod and the app target produced duplicate symbols. Without the app-target link, the app crashed at launch in dyld, because nothing embedded the dynamicMapboxCommon,MapboxCoreMapsandTurfframeworks. Xcode 26 archives failed withMapboxCommon.xcframework-ios.signature … already exists. With Expo, and with the hook order documented for bare apps,react_native_post_installran after$RNMapboxMaps.post_installand dropped the package reference.What changed:
spm_dependency. That adds the include path and doesn't depend on hook order, and the app target is no longer touched.ios/rnmapbox_spm.rb). On React Native versions whosespm_dependencyembeds package frameworks itself (fix(iOS): embed the dynamic frameworks of spm_dependency Swift packages react/react-native#58781), the pod passes them asembed_frameworksand skips its own entries when the app has an embed script anyway, so they aren't embedded twice.pod installremoves the product that earlier versions added to app targets, and logs a warning when it does.trueselectsmapbox-maps-ios, with the requirement derived from$RNMapboxMapsVersion. A hash overridesurl,requirementorproduct_name.RNMapboxMapsSwiftPackageManageroption.CocoaPods stays the default; nothing changes unless you opt in. Podfile:
Expo
app.json:Verified on the RN 0.84 example (Xcode 26.6, iOS 26.5 simulator) with
RNMBX_SPM=1 pod install: a Debug simulator launch rendered the map, and an unsigned Release archive succeeded. The archive embedsMapboxCommon,MapboxCoreMapsandTurfonce each and definesMapboxMaps.MapViewonce. With an Expo SDK 54 app,expo prebuild --clean+pod installkept the package reference, and the Release simulator build launched. The default CocoaPods path still runspod installwithout changing the app project, and the example still builds. Each failure listed above was first reproduced onmain. On RN0.89.0-nightly-20261018-27e77216e, which includes #58781, the frameworks are embedded once through RN'sinstall_spm_framework, a Debug simulator launch rendered the map, and an unsigned Release archive succeeded.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Screenshot OR Video
Component to reproduce the issue you're fixing
No component; it's a build setup. Set
$RNMapboxMapsSwiftPackageManager = { url: 'https://github.com/mapbox/mapbox-maps-ios.git', requirement: { kind: 'upToNextMinorVersion', minimumVersion: '11.23.1' }, product_name: 'MapboxMaps' }inexample/ios/Podfileonmain, runpod installand build: it fails withno such module 'MapboxMaps'. On this branch,RNMBX_SPM=1 pod installthen builds, launches and archives.