ld: library not found for -lAmplitude when lib exists at …/BuildProductsPath/Debug-iphoneos/Amplitude
I keep getting this error when building my app using xcodebuild from the command line.
xcodebuild -workspace ios/APP_NAME.xcworkspace -scheme APP_NAME clean archive -sdk iphoneos -configuration Debug -UseModernBuildSystem=NO -archivePath $PWD/APP_NAME CODE_SIGNING_ALLOWED=NO;
The app builds fine via Xcode UI. This is a react native app, and I tried a bunch of things that didn't work.
- Setting same deployment target for Pods and App projects
- Deleting
libAmplitude.afrom app project's Frameworks folder - Setting
Build Active Architecture Onlyto NO - Embedding
libAmplitude.aalong withlibPods-APP_NAME.a
Strangely the file it can't find actually exists in the directory. I see two failures of this type (arm64, armv7).
ld: warning: directory not found for option '-L-L/Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/BuildProductsPath/Debug-iphoneos/Amplitude'
ld: library not found for -lAmplitude
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Final build failure:
The following build commands failed:
Ld /Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/IntermediateBuildFilesPath/APP_NAME.build/Debug-iphoneos/APP_NAME.build/Objects-normal/arm64/APP_NAME normal arm64
Ld /Users/Parth/Library/Developer/Xcode/DerivedData/APP_NAME-atzumsqdaojeyaaukpzreucvvlja/Build/Intermediates.noindex/ArchiveIntermediates/APP_NAME/IntermediateBuildFilesPath/APP_NAME.build/Debug-iphoneos/APP_NAME.build/Objects-normal/armv7/APP_NAME normal armv7
(2 failures)
Is there any chance you can provide a sample app that we can use to try to reproduce?
Our SDK is just a wrapper around our iOS and Android sdks. It looks to me like there is an issue with linking.
If unable to provide a sample could you provide details such as react native version, any custom tooling you might be using for your application, xcode version, and macos version? Also does the app build correctly using react native cli?
If no demo is provided, in order to debug we will need to create a react native app/environment similar to yours.
@parthv21 Did you get any solution for this? I am facing the same issue.
Any update here?
Hi all. Can you guys provide the output of running react-native info command, that will be helpful for debugging?
Are you using the cocoapod as a manager and with Xcode 10+?
I did several things to make build works through the command line.
- run
npx react-native linkin the root directory. - Add this in order to remove the warning of
The iOS Simulator deployment targets is different than the range of supported deployment target versionsduring the pod installpost_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' end end end - remove the Podfile.lock and re-run the
pod installin theiosfolder - I also deleted the DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedDataand clean the build. - It will still have the
ARCHIVE FAILEDissue for x86_64 and i386
But if you run arch -x86_64 react-native run-ios, you can successfull build and run the app.