Search code examples
iosxcodelinkerxcode10

Framework fails to link in Xcode 10


My App uses a static framework "A" (built as a dependency) which itself uses a static framework "B". In Xcode 9 this built and worked fine. In Xcode 10 I get "Undefined symbols for architecture x86_64" followed by a list of symbols referenced from "A" defined in "B". It appears the symbol definition exists in "A" but not the data. Xcode 9 includes the data in "A" but Xcode 10 does not.

Using Xcode 9:

nm -m -arch x86_64 "A" | grep "<symbol from B>"
                 (undefined) external _<symbol from B>
0000000000000f20 (__DATA,__const) external _<symbol from B>

Using Xcode 10:

nm -m -arch x86_64 "A" | grep "<symbol from B>"
                 (undefined) external _<symbol from B>

Why is this only failing in Xcode 10?


Solution

  • 2020 Xcode 12 edit: While the original problem seems to have been fixed, this problem can still occur if the library B has an iOS Deployment Target lower than library A.

    For some reason Xcode 10 does not pass the items listed in "Link Binary with Libraries" to libtool when creating the static library "A". This might be a bug or there might be some logic to it, I'll file a bug report. A workaround is to add the following to "Other Librarian Flags" in build settings for "A":

    "${BUILT_PRODUCTS_DIR}/B.framework/B"