App gets "Undefined symbols for architecture armv7" when archiving, unless I don't Strip Linked Product in a library

StackOverflow https://stackoverflow.com/questions/20206501

Question

My app uses four libraries. Two of them are third-party (built from source), and two are my own. Building debug, and release builds of the app works without any problem.

However, when I try to archive the app I get "Undefined symbols for architecture armv7" for every symbol in one of my personal libraries (just one of the two).

I discovered that if I set "Strip Linked Product" to NO in the build settings for that library, I can archive the app.

My question is, why would I need to do that for just one of four libraries? And is there something I can do to fix the issue?

I'm using Xcode 5.0.2. The app and all of the libraries are being built with a deployment target of iOS 7, and with standard architectures (armv7 and armv7s).

Was it helpful?

Solution

The problem was that I had Link-Time Optimization set to YES for that static library.

I used a DTS ticket to figure this one out, so rather than try to paraphrase the response I got I'm just going to quote it:

"Actually, the issue lies with the Link-Time Optimization build setting being enabled for your library. Setting Strip Linked Product to YES and Link-Time Optimization to NO leads Xcode to first strip your library before the optimization process during linking (you can see it by looking at your build log); linking fails as the required symbols were stripped from the library. You are getting a successful archive [when setting Stripped Link Product to NO] because no symbols are removed before the optimization process during linking. Setting Link-Time Optimization to NO for your library should resolve the issue." -- Linda Ouandji

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top