Repository navigation
feat(ios): add a compile-only link: false Swift Package Manager mode - #4372
Merged
Merged
Conversation
With `$RNMapboxMapsSwiftPackageManager = { link: false }` the rnmapbox-maps pod compiles against MapboxMaps
but doesn't link it: it gets a build-order dependency on the package product and the products dir as a Swift
include path. Another Swift package that brings MapboxMaps, e.g. the Navigation SDK, links the only copy.
The dependency is added after the Podfile's post_install hooks, because react_native_post_install drops all
package references. There CocoaPods' counter-based UUIDs have restarted (stabilize_target_uuids resets them),
so `project.new` could return the root PBXProject's UUID and corrupt Pods.xcodeproj. The objects get
MD5-derived UUIDs instead, which also keeps re-running `pod install` byte-identical.
This branch was previously 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
Adds a compile-only Swift Package Manager mode:
$RNMapboxMapsSwiftPackageManager = { link: false }(or{ "link": false }in the Expo plugin options). Use it when another Swift package already bringsMapboxMaps, for example the Mapbox Navigation SDK. Thernmapbox-mapspod then compiles against theMapboxMapspackage product without linking or embedding it: it gets a build-order dependency on the product and the products dir as a Swift include path. The other package links the only copy.The dependency is added after the Podfile's post_install hooks, because
react_native_post_installdrops all package references. At that pointproject.newcan reuse the UUID of an existing object. CocoaPods'stabilize_target_uuidsresets@generated_uuidsto the few leftover UUIDs, andPod::Project's counter-based generator then restarts near 0. Depending on the project's object count, the package reference got the rootPBXProject's UUID (46EB2E00000000), and Xcode reported "The project 'Pods' is damaged". The new objects now get MD5-derived UUIDs, the same way CocoaPods stabilizes target UUIDs, so they can't collide and re-runningpod installis byte-identical. This is the same bug as react/react-native#57576, but in rnmapbox's own hook.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Tested with RN 0.84 and CocoaPods 1.16.2:
{ link: false }: cleanpod install, then a secondpod installwith an identicalproject.pbxproj. Debug build, launch, map and turn-by-turn guidance work, and a Release archive succeeds. The app has exactly oneMapboxMapscopy, andlibrnmapbox-maps.adefines noMapboxMapssymbols./exampleapp:pod installand a debug build both with the default (CocoaPods) setup and withRNMBX_SPM=1(true).yarn lint,yarn type:check,yarn unittest, and the plugin test for the new option. Three Android gradle snapshot tests inyarn test:pluginfail onmainas well.Screenshot OR Video
Component to reproduce the issue you're fixing
Before the fix, the collision happened on every clean
pod installin the navigation app. Where the object count leaves enough spare UUIDs it doesn't, so thisRUBYOPT=-rhook provokes it: it drops the leftover UUIDs right before the compile-only step. Without the fix,rootObjectresolves to themapbox-maps-iospackage reference, andxcodebuild -listfails with-[XCRemoteSwiftPackageReference _setSavedArchiveVersion:]: unrecognized selector. With the fix, the project has no duplicate IDs and loads.