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)

Most upvoted comments

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:

  1. add use_frameworks! to my podfile (this makes the libraries dynamic instead of static)
  2. modify the podspecs in any libraries that reference React as a dependency in their podspec to instead depend on React-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
  3. I then brought in patch-package to create patch files that changes those for me as part of npm install

Note, 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

image

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:

  pod 'MapboxCoreNavigation', :build_type => :dynamic_framework
  pod 'MapboxNavigation', :build_type => :dynamic_framework

hey @rossmartin @mertozylmz yeah… following steps solved the issue for me

  1. Go to project>build settings> library search path
  2. remove “$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)” at this point i was able to run the app on simulator but not on device
  3. after this I had to set Don't Dead-strip Inits and Terms to Yes for both Project and Target.
  4. and most importantly update the cocoapods to 1.10.1 at this point i was also able to run the app on device

However, I am still seeing following issues which were not originally related to this issue

  1. seeing a random language issue on navigation view. I have tried following steps mentioned here : https://github.com/mapbox/mapbox-navigation-ios/issues/2605#issue-693268777 but no luck
  2. once the navigation finishes in the , nothing happens if you click on 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 of React to React-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 in 0.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) -

# define architecture at the top level of your Podfile
architecture = `uname -p` # arm64 or i386

target 'YourAppNameHere' do

  # ... you will have all your stuff in between here

    post_install do |installer|
        flipper_post_install(installer)
        ## add this here after the above
        installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
            if architecture === 'arm64' # only enable this for apple silicon
              config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
            end
          end
        end
    end
end