. Advertisement .
..3..
. Advertisement .
..4..
There is no official documentation for the React Native build error: “Undefined symbols for architecture x86_64”. You should closely investigate the error message and try different solutions – also what this article strives to achieve.
React Native Build Error: “Undefined symbols for architecture x86_64”
After hitting the build button on Xcode, instead of getting a successful web application, you may receive a variation of this error message from this program:
Undefined symbols for architecture x86_64
In short, your project is created for other platforms like arm64, but you haven’t set up Xcode to target this platform, or no proper library has been linked. Depending on what is going on in your system, there are various solutions for your problem.
Change The Target Platform
While the latest Xcode versions should set ARM variants as the default platforms, you may need to change this manually.
From your target, click the Build Settings tab. In the Architectures list, choose only arm64.
Upgrade Xcode
Sometimes a specific Xcode version may have a bug that changes the build behaviors in the wrong way. Upgrading it to the latest version may solve this problem.
If your Xcode program is installed through the App Store, updates should be handled automatically. But for some reason, they don’t work, and you are stuck with an outdated version:
- Open App Store.
- Click the Updates tab on the sidebar.
- Look for Xcode and click the Update button next to it.
If your Xcode installation comes from the installer on Apple’s developer site, go back to the Xcode homepage. This method allows you to not just pick a specific version but also keep multiple Xcode versions in a single Mac system.
- Go to https://developer.apple.com/download/all/?q=xcode and choose the latest version. Wait for the download process to complete.
- Click on the installer file and follow the instructions on the screen.
- Remember to add the folder to Xcode’s version, such as Xcode-<version>.
- Set this installation as the default version of Xcode on your system:
$ sudo xcode-select -s /Applications/Xcode-<version>.app
Now you have multiple versions of Xcode, try to build your React Native with the latest installation. Note: check this tutorial if you see the “React Native 0.64 won’t build iOS app” error after your upgrade.
Downgrade React Native
There is no official way to downgrade this framework, even though many developers have successfully used this trick to resolve the problem. Prioritize it if you have only seen the error since your recent React Native upgrade.
Run this npm command in your terminal:
$ npm install react-native@<version>
<version> should be a string of numbers indicating your most recent React Native version, such as 0.68.
Link The Require Library
If the error message is quite detailed about which library has caused the problem, you can try adding it to solve the issue.
Example:
Undefined symbols for architecture x86_64:
"__swift_FORCE_LOAD_$_swiftDataDetection", referenced from:
__swift_FORCE_LOAD_$_swiftDataDetection_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
(maybe you meant: __swift_FORCE_LOAD_$_swiftDataDetection_$_YogaKit)
"__swift_FORCE_LOAD_$_swiftFileProvider", referenced from:
__swift_FORCE_LOAD_$_swiftFileProvider_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
(maybe you meant: __swift_FORCE_LOAD_$_swiftFileProvider_$_YogaKit)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If you see this message, go to your target > Build Phrases > Link Binary With Libraries. Click the plus icon and add into the list.
Conclusion
The React Native build error: “Undefined symbols for architecture x86_64” comes from the mismatch between the architectures of the build targets and libraries used in your application. Setting them up correctly (or upgrading your Xcode) may get rid of the problem.
Leave a comment