Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Scenario:

I have TargetA, which is an iOS application. This app uses a static library, compiled by TargetB. Obviously, TargetB is a dependency of TargetA, and TargetB is always built before TargetA. So far so good.

Now, I want a script to run TargetA is built, but even before TargetB.

What I tried:

  1. Adding a "setup" aggregate/external-build target, and making it a dependency of TargetA. It half works: Xcode runs setup and TargetB at the same time, so TargetB may get built too soon. Not good enough.
  2. The same, but specifying in the scheme not to build in parallel. This works, but is a waste, since there are other targets that can be built in parallel.
  3. Run the script in a pre-action build step inside the scheme. This works, but seems wrong (why? output from that step doesn't go into the build log; so perhaps I'm not meant to use it this way?).

What I don't want to do:

Add the script as a dependency of TargetB. This would work; however, TargetB actually comes from another sub-project, and in the context of building it, parameters to the script are not yet known (mainly the root directory of TargetA's project).

Am I missing anything, or do I have to settle for #2 or #3 above?

EDIT: in option #2 above, changing the order of dependencies (in my case, between Setup and TargetB does not help -- Xcode still selects the order arbitrarily.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
841 views
Welcome To Ask or Share your Answers For Others

1 Answer

Running the script as a pre-action build step inside the scheme is the best way to accomplish what you want. A common use of this approach is to adjust the project's build number base on the source control state (example). As far as capturing the script output, unfortunately the only thing you can do is redirect stdout for the script to a log file. That log file could be part of your project, so it would be easy to view from Xcode.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...