Xcode command-line build doesn't find embedded framework at compile time. Why not?

Viewed 491

It feels like this question has been asked a few times before, but usually involving 'pods' or other complicating factors. For the purposes of this question, I have simplified the context.

Using Xcode 8.3.3, I created two projects .. an iOS app called "A" and a framework called "F". The app uses the framework (there is an import F statement in one source file of "A") so "F" needs to be embedded in "A". Everything is Swift, no Obj-C.

The "A" project contains the "F" project and "F" is a "Target Dependency" (sorry, not revealed in this screenshot, but it's true) so it looks like this:

enter image description here

All the project settings in "A" and "F" are default values, and specifically FRAMEWORK_SEARCH_PATHS is blank, apart from the addition of the "Copy Files" phase to embed "F" into "A" at build time.

That's the setup, here's the problem: a build by Xcode completes successfully (compiles without error and embeds "F" in "A"), but a command-line xcodebuild build fails, at compile time, because the import F doesn't find "F":

 . . /A/A/ViewController.swift:10:8: error: no such module 'F'

My much larger, real, non-sample project has been migrated up through Xcode versions from a long way back .. fearing some version skew (for example, the "Embed Frameworks" build phase of old, is now just a "Copy Files" phase), I created this simple example case using only Xcode 8.3.3.

It would seem to me that Xcode and xcodebuild should compile the same, regardless of some other build-time variations: Xcode builds a 'debug' and xcodebuild builds a 'release'; and the results of their work end up in different places, Xcode in "DerivedData" (deep in ~/LibraryXcode/) and xcodebuild in a build folder alongside the "A" project file.

Why does xcodebuild fail to satisfy the import F when Xcode has no trouble with it? Thanks for any insights.

EDIT: added zipped projects .. https://www.dropbox.com/s/lqfifh0qt4jlm5b/A%2BF.zip?dl=0

0 Answers
Related