Deployment target influences build order in release build configuration

Xcode version: 12.4

Projects:
  • - Main: deployment target 9.0

  • - Some: deployment target 9.0

  • - Base: deployment target 14.0

There are three projects, project "Some" and project "Base" are <Dynamic Library>.

In "Some"'s build phase, Base.framework is added into the "Link Binary With Libraries".

In "Main"'s build phase, Some.framework is added into the "Link Binary With Libraries".

So the dependency is: Main -->. Some --> Base.

When the build configuration is "Debug", it works as expected, "Base" builds first, "Some" follows and "Main" lasts.

But after changed the build configuration to "Release", the linker shows an error:

ld: framework not found Base

Change the project "Base" deployment target to 9.0 can make everything ok again.

I tried some different combinations of deployment targets of project "Base" and project "Some"

When project "Some" deployment target < 11.0, and project "Base" deployment target >= 11.0, the link error shows, because the Base.framework is not generated.(Only in Release build configuration)

ps: May someone tell me that where I can see how the Xcode decide the build order? I can only check build logs, but this is a build result, not why.

Xcode needs to know how the targets depend on each other to determine which order to build things in. For each target, ensure its dependencies are declared in the Target Dependencies build phase. However, if your 3 projects are in a workspace, you won't be able to add them to that dependencies list. Also go to the scheme editor, and look at the Build section. Ensure "Find Implicit Dependencies" is enabled. This is the default, and will allow Xcode to discover any dependencies present in a workspace that you can't explicitly declare in the Target Dependencies build phase.
Thank you so much for your reply!!

if your 3 projects are in a workspace, you won't be able to add them to that dependencies list.

This is the problem that I met, I'm not able to add the dependencies explicitly. The "Find Implicit Dependencies" is enabled, but after changing the deployment target in release configuration. Xcode can't find the dependencies correctly(with some deployment target combinations), what should I do with this?

Is there a way that developer can check how the Xcode decides build order? or decides build order other than implicit dependencies?


I generally suggest taking the time to draw yourself an accurate diagram of your expected build dependencies and linkages between binaries, and then comparing them to what is actually implemented in your Xcode workspace. Most often, this is due to a missing connection in the build graph that isn't obvious, because there's an explicit dependency missing (within a single Xcode project), or a missing link phase that you haven't realized.

As to additional resources for diagnosing your specific issue if you can't see it after thinking through those items, you have two options:

  • WWDC is the week of June 7, with lab availability for the week opening that day. You can bring this issue to one of the labs.
  • Open a Technical Support Incident and work with a DTS engineer on this outside of the conference time frame. We can collection additional project-specific info from you to help look at this — Xcode project files, build logs, and more, which is best done outside of the forums.
Deployment target influences build order in release build configuration
 
 
Q