1

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 listed here - Xcode - ld: library not found for -lPods, 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)

Issue filed with amplitude - https://github.com/amplitude/Amplitude-ReactNative/issues/87

Edit

This might be the root cause of the problem, after changing other linker flags to ${inherited}, I see 2 mentions for Amplitude.

  1. -l"Amplitude"
  2. -l"amplitude-react-native"

linker flags

Parth
  • 2,682
  • 1
  • 20
  • 39

1 Answers1

0

I got this working after changing this setting -UseModernBuildSystem=YES.

xcodebuild -workspace ios/APP_NAME.xcworkspace -scheme APP_NAME clean archive -sdk iphoneos -configuration Debug -UseModernBuildSystem=YES -archivePath $PWD/APP_NAME CODE_SIGNING_ALLOWED=NO;

I also had to:

  1. Update minimum support to iOS 11
  2. Set linker flags to ONLY ${inhereted}
  3. Set Build Active Architecture Only to YES.
Parth
  • 2,682
  • 1
  • 20
  • 39