Amplitude-ReactNative icon indicating copy to clipboard operation
Amplitude-ReactNative copied to clipboard

ld: library not found for -lAmplitude when lib exists at …/BuildProductsPath/Debug-iphoneos/Amplitude

Open kadanes opened this issue 4 years ago • 5 comments

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.a from app project's Frameworks folder
  • Setting Build Active Architecture Only to NO
  • Embedding libAmplitude.a along with libPods-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)

kadanes avatar Jun 26 '21 22:06 kadanes

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.

kelsonpw avatar Jul 04 '21 17:07 kelsonpw

@parthv21 Did you get any solution for this? I am facing the same issue.

jarnakhimani avatar Feb 10 '22 09:02 jarnakhimani

Any update here?

PujanShah22 avatar Apr 15 '22 16:04 PujanShah22

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+?

yuhao900914 avatar Apr 18 '22 16:04 yuhao900914

I did several things to make build works through the command line.

  1. run npx react-native link in the root directory.
  2. Add this in order to remove the warning of The iOS Simulator deployment targets is different than the range of supported deployment target versions during the pod install post_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
  3. remove the Podfile.lock and re-run the pod install in the ios folder
  4. I also deleted the DerivedData rm -rf ~/Library/Developer/Xcode/DerivedData and clean the build.
  5. It will still have the ARCHIVE FAILED issue for x86_64 and i386 Screen Shot 2022-04-18 at 10 59 00 AM But if you run arch -x86_64 react-native run-ios, you can successfull build and run the app.

yuhao900914 avatar Apr 18 '22 18:04 yuhao900914