Many developers using the Apple silicon chips have run into The React Native build error “Undefined symbols for architecture x86_64”. Scroll down to find out why this error occurs and how to get rid of it to continue developing your app.
React Native build error: Undefined symbols for architecture x86_64
This error is most likely to occur when you run the simulator for your React Native app with Xcode on an M1 or M2-based computer.
Apple announced the transition from Intel chips to in-house designs in 2020. Since then, they have introduced ARM-based M1 and M2 processors. Many Mac computer series have switched to them.
This transition from Intel’s x86-64 to ARM64 isn’t without issues, especially when it comes to compatibility.
By default, Xcode uses the recommended architecture build settings, including every CPU architecture in the Apple ecosystem. But your version of React Native might come with pre-compiled libraries only for the x86-64 simulator, not the ARM64 one. Trying to run the simulator for your React Native app with it, the errors will occur like this:
Undefined symbols for architecture x86_64 building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
Upgrade React Native
Trying to update React Native used in your project may solve this problem. It also gives you access to more features: Developer tools, views, and APIs.
First, you need to get the latest version in your system with npm:
npm install -g [email protected]
You can use the upgrade command in the command line as a one-step method. It uses
git apply internally to determine which files in your project should be modified, removed, or created, putting the number of conflicts to a minimum.
Run this command in the Terminal app to begin the upgrading process:
npx react-native upgrade
The second one you have is the Upgrade Helper – a website that can show in detail which files need which modifications. This tool also explains why such changes are needed.
You will need to select the current version and version you want to upgrade to. Install the dependencies if Upgrade Helper shows them in the package.json file.
You can disable the simulator for the ARM64 architecture. To do this on Xcode:
- Open your React Native’s workspace, open Build Settings
- In the Excluded Architectures section, add arm64 for the iOS simulator SDK of both Debug and Release options.
You can also change this setting by adding the ‘EXCLUDED_ARCHS’ option to your project’s Podfile:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64" end end end
Now you can use the simulator to run your app. Open the Terminal and type in this command:
npx react-native run-ios
This step is necessary when your React Native installation still hasn’t updated its support for Apple silicon Macs. Even though it might work, only use this build setting when you know which target architecture you want to include or exclude. Don’t change the ARCHS setting to get the same result.
The React Native build error “Undefined symbols for architecture x86_64” occurs when you build your app on an Apple silicon Mac computer. Update your React Active installation or exclude the ARM64 architecture to solve this problem.
Maybe you are interested:
- useLocation() may be used only in the context of a Router component
- react hook useeffect has a missing dependency error
- sh: react-scripts: command not found
My name is Robert. I have a degree in information technology and two years of expertise in software development. I’ve come to offer my understanding on programming languages. I hope you find my articles interesting.
Name of the university: HUST