How the error shows up
When you are trying to press Xcode’s build button, you get the error warning rather than getting the desired result. This is what you get in return
Undefined symbols for architecture x86_64
How To Fix the Error “undefined symbols for architecture x86_64”
When you create a project for any platform. Let’s suppose for arm64, you forgot to set up Xcode in order to target it, or perhaps you don’t have the library linked to it. This is the cause of the error. We have come up with a few great solutions to help you remove the error. Have a look at the solutions
Solution 1 – Update Xcode
The first thing to try out is to update Xcode to resolve the error as build behavior can be changed in a way that causes an error because some versions have bugs. So, updating Xcode can be really helpful. There are two types of downloads; from the App store and Apple’s site. Both have different procedures when it comes to updating.
Programmers who installed Xcode from the developer website of Apple, need to visit the Xcode homepage. It opens a way to opt for any version you like to have. You can even have many versions of Xcode in one Mac system. The process you need to follow:
- Open Apple’s developer site, go to download and look for Xcode to click the most recent version. Download it.
- Next, you need to look at the on-screen instruction to install the file successfully.
- Make sure you add a folder (i.e Xcode<version>) to the version of Xcode.
- In the end, you have to make the installation as the default Xcode’s version on the system. Like this:
$ sudo xcode-select -s /Applications/Xcode-<version>.app
In the case you are the one who installed Xcode using the App Store, updating it can be tackled automatically. If you are stuck because the automatic update doesn’t work, then you can do it manually using the following process:
- Click your App Store to open it
- On the sidebar, you need to check for the updates
- Search for Xcode, and click on the update button.
Solution 2 – Manually change the target platform
When you installed the most recent version of Xcode, it is by default set to ARM variants, which needs to be changed. This change requires you to do it manually.
Tap the tab Build Settings from the target. Select arm64 only in the Architectures list.
Solution 3 – Link library
It would be nice to have the error in detail about the library that makes the error appears. As you can help you solve the problem. Have a look at the 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)
When you get the detailed error, you need to open target, go to Build Phrases, and then click Link Binary with Libraries. Add it to the list by clicking the plus icon. It resolves the error.
Solution 4 -Downgrade the version of React Native
Downgrading React Native is another way to handle the error warning. To do that, run the below command in the terminal:
$ npm install react-native@<version>
Where the <version> is the place to add the version you have like 0.68.
In this post, we shed light on the solutions to fix the error “undefined symbols for architecture x86_64”. I hope you liked it!
I wish you all the best!