It is very new to me see this problem which started happening recently. Previously my app used to work fine on the iOS simulator by running this command react-native run-ios
. Now I have done a lot of research and made my app run via XCode. But somehow the metro bundler is not linked when the app runs via XCode.
I tried running the app via react-native run-ios
and every time I am seeing this error. It is too big to copy paste every error here, but here are some of them:
Undefined symbols for architecture x86_64:
"Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from:
generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element> in libMixpanel-swift.a(AutomaticProperties.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld /Users/careerlabsdev/Library/Developer/Xcode/DerivedData/CareerLabs_Elev8-gxcfanteiuxazegkgwkjkrjxbdmw/Build/Products/Debug-iphonesimulator/CareerLabs.app/CareerLabs normal
(1 failure)
I have done a lot of things to make it to work. The only success I got here is, while running the command react-native run-ios, it opens up the metro bundler server
. After that it fails with giving a 1000 lines of error. I picked the error which had some cream part. Some key words to pick from the error:
- ld: symbol(s) not found for architecture x86_64
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
- Did not understand the word Ld, which is listed under BUILD FAILED
What I did is as follows:
- Deleting node_modules, Pods. Cleaning the build from XCode. Running
npm install
and thencd ios && pod install
and then ran the commandreact-native run-ios
- Deleting Pods, Podfile.lock. Did
pod install
and then in the rootreact-native run-ios
- Doing these:
rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
pod install
cd ..
react-native run-ios
- Restarted the system, and ran the command again
react-native run-ios
- Added arm64 in the Excluded Architecture from XCode. Please note, this enabled me to
build and run
the app successfully on XCode. But it doesn’t get attached to the metro bundler server. Looks like it runs the release mode only. - Updated my package
react-native-gesture-handler
to the latest one which is 1.10.3, to see if that removes my problem. But no luck.
My Podfile look like this:
platform :ios, '10.0'
use_flipper!({'Flipper' => '0.81.0'})
post_install do |installer|
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
I am out of options now, and waiting for some insight to be given. It is indeed frustrating to see an error on something which never created a problem. I am using Apple M1 Chip Macbook.
Update V1.0
- I have tried commenting down the
use_flipper!()
, from the/ios/Podfile
, and then redid the same things, like removingPods
,Podfile.lock
. Running this command,pod update && pod install && cd.. && npm run ios
. Ran into multiple issues. I don’t know what the issue is with XCode and React Native on Apple M1.
Update V2.0
I have found some significant places where the developers are complaining about the same. XCode has forced updated my version to 12.5, without my notice. And now XCode is creating a problem with RN Older projects. Here are the supportive links for the same:
I hope this may give some insight to the developers who are confused like me. Please take a look, and looks like Facebook
is fixing it, but don’t know when. Have to keep an eye on it :/
2
Answers
The one hacky thing which I did to make my app run again like before, is to downgrade the XCode Version to the previous stable one, that is Version 12.4. I knew about the problem later, cos,
XCode
force updated my version which started behaving weird with my already existing project. So the only viable option I saw is to downgrade the version to the previous one, and everything worked like before.Please Note: This issue exists majorly with
Apple M1
along withXCode v12.5
andBigSur OS
. So go ahead keeping these things in your mind.For this, I had to do these things:
XCode
completely from the Mac. To do that efficiently, consideringXCode
does caches a lot of things on your Mac, use Mac App Cleaner. If by any chance, you have just removed the XCode without using the link, then use this Completely remove Xcode from Mac.XCode
from this resource XCode Releases. Please Note: This is a legit source which takes you directly to theApple's download pages
, and no unreliable thing. So you can just go ahead and download the previous stable version of theXCode
, with which your app was working fine.App Store
will again install the latest version of the XCode which is buggyv12.5
. So please don't download and install the same fromApple Store
. Use the above mentioned source only for best results.It will work for you, as it did work for me, and now I am continuing my work on my project without any hassle. Cheers!
I am guessing all third party Pods will need to update their RN Pod Specs to use
XCFrameworks
. That’s what I just did and it seems to work ok.This means that you, as an RN package user, you will either need to wait for the package authors to update their podspecs to use
XCFrameworks
or add a build config that excludes the ‘arm64’ arch (but then will not work on M1 macs).Alternatively, you can visit the
node_modules/<package>/thrid-party.podspec
and update it yourself. But that means you will need to build theXCFrameworks
yourself too. So…..