Home > OS >  "Undefined symbols for architecture x86_64 error" when migrating from React Navigation 5 t
"Undefined symbols for architecture x86_64 error" when migrating from React Navigation 5 t

Time:02-23

I am developing an app with React Native and trying to migrate from React Navigation 5 to 6. For this I have followed the steps that come in the Upgrading from 5.x guide.

The versions of React and React Native are these:

"react": "17.0.2",
"react-native": "0.67.2",

I have installed these packages:

"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.1.1",
"react-native-safe-area-context": "^3.4.1",
"react-native-screens": "^3.12.0",
"react-native-tab-view": "^3.1.1",

After upgrading the packages I ran pod install command in ios folder.

If I run npx react-native run-ios --simulator="iPhone 13" command or I run on a device using Xcode, I get this error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNSSearchBar", referenced from:
      objc-class-ref in libRNScreens.a(RNSScreenStackHeaderConfig.o)
  "_OBJC_CLASS_$_RNSScreenStackAnimator", referenced from:
      objc-class-ref in libRNScreens.a(RNSScreenStack.o)
  "_OBJC_CLASS_$_RNSScreenWindowTraits", referenced from:
      objc-class-ref in libRNScreens.a(RNSScreen.o)
      objc-class-ref in libRNScreens.a(RNSScreenStack.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It looks like libRNScreens.a is from the react-native-screens package.

Do you know how to solve this problem?

CodePudding user response:

It might be related to using use_frameworks! in Podfile. Try adding the following step to your Podfile:

pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('RNScreens')
        def pod.build_type
          Pod::BuildType.static_library
        end
      end
    end
  end

Details Here

CodePudding user response:

solution is very simple

remove this

Xcode -> Build Settings -> Search Paths -> Library Search Paths -> "$(TOOLCHAINDIR)/usr/lib/swift-5.0/$(PLATFORMNAME)"

  • Related