react-native-mapbox-navigation: Xcode build failure
Hi all, I am getting following error during xcode build after installing this package
ld: warning: building for iOS, but linking in dylib file (/Users/nitinsharma/Library/Developer/Xcode/DerivedData/app-bpqejjqomhurrldtyubqevqtdqzc/Build/Products/Debug-iphoneos/MapboxAccounts.framework/MapboxAccounts) built for Mac Catalyst
Undefined symbols for architecture arm64:
"_swift_getFunctionReplacement", referenced from:
_swift_getFunctionReplacement50 in libswiftCompatibilityDynamicReplacements.a(DynamicReplaceable.cpp.o)
(maybe you meant: _swift_getFunctionReplacement50)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using
react-native : v0.63.0
xcode : 12.4
mapbox related pods from my podfile.lock
- Mapbox-iOS-SDK (6.3.0):
- MapboxMobileEvents (~> 0.10.4)
- MapboxAccounts (2.3.1)
- MapboxCommon (9.2.0)
- MapboxCoreNavigation (1.2.1):
- MapboxAccounts (~> 2.3.0)
- MapboxDirections (~> 1.2.0)
- MapboxMobileEvents (~> 0.10.2)
- MapboxNavigationNative (~> 30.0)
- Turf (~> 1.0)
- MapboxDirections (1.2.0):
- Polyline (~> 5.0)
- Turf (~> 1.0)
- MapboxMobileEvents (0.10.7)
- MapboxNavigation (1.2.1):
- Mapbox-iOS-SDK (~> 6.0)
- MapboxCoreNavigation (= 1.2.1)
- MapboxMobileEvents (~> 0.10.2)
- MapboxSpeech (~> 1.0)
- Solar (~> 2.1)
- MapboxNavigationNative (30.0.0):
- MapboxCommon (= 9.2.0)
- MapboxSpeech (1.0.0)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 25 (11 by maintainers)
Thanks for the details. Has your RN Xcode project gone through RN version updates? I think this can explain the need for step 1 and 2 in your solution.
My next question was going to be around what version of cocoapods was being used. I should have asked that one first.
In regard to the issues that are still there - I can’t solve that 1st issue yet unfortunately.
The 2nd issue you mention I should be able to implement that delegate method on the native side and provide a prop that accepts a callback function. Perhaps something like
onNavigationFinish
that takes a function. I’ll need to implement that on android and iOS.I’m going to close this issue for now and I’ll follow up when I release a new version with the prop for handling the navigation ending.
So, I have gotten this to work for me. In my case, I did need to have the Mapbox Libraries load dynamically. In order to achieve this, I needed to:
use_frameworks!
to my podfile (this makes the libraries dynamic instead of static)React
as a dependency in their podspec to instead depend onReact-Core
. In my case, this included:@react-native-community/masked-view
,amazon-cognito-identity-js
,react-native-gesture-handler
, and this library,@homee/react-native-mapbox-navigation
patch-package
to create patch files that changes those for me as part of npm installNote, our app uses the expo libraries (not build environment) which requires
use_unimodules!
, and this still works. I did not need to remove the swift-5.0 toolchain for this to work, or setting any code stripping things.I’m curious did you create a bridging header for swift or already have one? There is a step in the readme on how to do this if you haven’t created one yet - https://github.com/homeeondemand/react-native-mapbox-navigation#ios-specific-instructions
Something interesting to note, when we pulled all the library source code into the project, we found everything works if it’s marked as dynamically linked. Seems to be something related to the library being statically linked?
Relevant lines from our Podfile:
hey @rossmartin @mertozylmz yeah… following steps solved the issue for me
Don't Dead-strip Inits and Terms
toYes
for both Project and Target.1.10.1
at this point i was also able to run the app on deviceHowever, I am still seeing following issues which were not originally related to this issue
End Navigation
button.These two should be easily reproducible…thx
@LowBudgetMan @devguy22 I had some time to revisit this stuff tonight. I spent too much time going down this rabbit hole with the root cause of the library being statically linked.
One thing I did do is publish
1.0.1
that changes the dependency ofReact
toReact-Core
in the podspec (https://github.com/homeeondemand/react-native-mapbox-navigation/releases/tag/1.0.1).If I get some more time I’ll try and find a solution. Until cocoapods can incorporate dynamic swift pods then I may have to go the route that @LowBudgetMan mentions.
Thanks for providing the details. I haven’t had time until now to catch up on emails. I closed on the purchase of a house yesterday and I’ve been busy with that and starting to move. I’ll be swamped in the coming weeks but I’ll try to help when I can.
Hey @nitinsh99 I added an
onArrive
prop that gets called when you reach the destination. This is published in0.2.2
.I could not find a delegate/callback in the SDK that gets called when you tap the “End Navigation” in the bottom banner. Now you will know when you have arrived at the destination though.
Hey glad you got it figured out for the simulator at least. I see that you received an answer in your stackoverflow post and hopefully that resolves it.
I have witnessed some odd behavior with language in the navigation UI as well. I believe it is related to this - https://github.com/mapbox/mapbox-navigation-ios/issues/2605. I left a comment in that thread.
In the future I might add language prop and then set it on the native side. It should be using the language set by the device but I have witnessed some parts of the nav UI be different.
Thanks for looking into this. I have a 4 year old mac. arm64 could be attributed to me running this on an actual iphone device? But regardless let me try the podfile changes you suggested and report back.
You appear to have a mac that is using apple silicon. The underlying SDK needs to be updated to handle this but until that happens you can get around it by adding this to your Podfile (
ios/Podfile
) -