Linking library: Mach-O linker error


#1

After detaching (and linking to the PODS header files from each library dependency), I’m getting a Mach-O linker error. Here’s the full error:

ld: library not found for -lAmplitude-iOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas? What is Amplitude-iOS, how can I link it?


#2

Ok, clues:

  1. I can see that Amplitude-iOS is a library included by expo
  2. Amplitude-iOS is the first POD header, alphabetically

I’m going to hazard a guess that it has something to do with these build flags for the main project target:


#3

Amplitude-iOS is a dependency of ExpoKit (this is shown in ExpoKit.podspec). It should have been installed automatically when you ran pod install in your detached project. Does your Podfile.lock show that cocoapods has some version of Amplitude present?


#4

Yes, - Amplitude-iOS (3.14.1)


#5

Hmm, I’m not sure I have enough information to say. Something is trying to link against Amplitude and doesn’t know where to find Amplitude. I haven’t seen this happen in an ExpoKit project before but it might be particular to the library you added, or something about the way your search paths are configured. Here’s some general ideas (without knowing much about your situation):

  • Figure out which target is looking for Amplitude and failing
  • See whether it actually needs Amplitude. If not, maybe there’s an erroneous setting telling it to link against Amplitude.
  • If it does, make sure the Framework Search Paths make sense for that target.
  • You can always try cleaning your build…!

#6

OK, some headway. After removing derived files, cleaning and rebuilding, I started getting a different error related to duplicate symbols.
I then set up an empty test build and started adding and building packages 1-by-1. It seems to be getting stuck on react-native-static-server (opened issue here: https://github.com/futurepress/react-native-static-server/issues/4), producing the same duplicate symbole error. I’ll keep you posted.


#7

Hi, @buishi @ben

Is this issue has been solved ?

I faced same issue here on my detached apps after following ios section on https://docs.expo.io/versions/v17.0.0/guides/expokit.html

btw, im using:

Node: 7.10.0
Expo CLI : 41.0.0
Expo: SDK 17
React Native: SDK 17 (Expo forked)
XCode: 8.3.2
Pod: 1.2.1


#8

Are you able to build a newly detached Expo project in XCode? It seems that this issue is related to the same problem I am facing (Building and archiving detached app iOS Mac fails). From @ben response, he is able to build a newly detached app without any problems.


#9

I was experiencing the same issue until I decided to reread the configuration instructions and realized I was opening the xcodeproj instead of the xcworkspace file.


#10

Doh! Just hit the same pothole. Thanks for the warning!


#11

In the end this problem was related to Header Search paths, which are kind of a pain to deal with. Different libraries that you link to expo will look for the headers in different locations, so you for each linked package, you have to see where it’s base xcode file is, and add a relative header search path that points to the headers correctly. See here: https://docs.expo.io/versions/latest/guides/expokit.html


#12

Following up on this depressing thread, we’re working on getting react-native link to play nicely with cocoapods so that people don’t run into issues like this any more.


#13

I’ve also had this issue, but it was because I’ve disabled Find Implicit Dependencies in Xcode > Product > Scheme > Edit Scheme, so it might be helpful if anyone have done the same and forgot about it.