5

My Xcode project has six different targets/schemes (I've never been clear on the difference, but in any case I have six targets and six schemes), all based on the same sources in different ways. I just started using Xcode 14.1 (from a substantially older version), and now when I do a build it builds all of my targets/schemes and shows issues for them all on the left:

enter image description here

This is not what I want. For one thing, since the targets/schemes are all based on the same sources I'm seeing a lot of the same issues repeated over and over. For another thing, when I'm working on a particular target/scheme I really want to focus on that and not be distracted. Also, I don't really want my machine to be slowed down by building all those other targets/schemes; I want my build turnaround to be as fast as possible.

So. How I do get back the old behavior of Xcode that I'm used to, of building just the currently selected scheme and its associated target? I'm looked in the preferences and "behaviors", and googled, and maybe I'm blind but I can't see any mention of this anywhere.

[ADDENDUM, pursuant to the comments from Matt. It continues to happen, now with errors rather than warnings, and unrelated to deprecation. Here's a new screenshot:

enter image description here

I made a change in a header that broke usage in various places in the project. Now my issues pane is filled with crap from other targets – mostly the SAME crap, repeated for each target. Particularly annoyingly, the target I have selected and am working on, called slim_multi, doesn't even come first in the issues pane – it's down at the bottom, after all of the other targets I'm NOT working on. I tried switching to other targets and doing "Clean Build Folder"; that made no difference to the situation. There must be a fix for this!]

bhaller
  • 1,803
  • 15
  • 24
  • @matt Nope, definitely not. Each is an independent target. And if there were a dependency between targets, that would have caused previous versions of Xcode to build the dependencies too. This is an Xcode UI issue. If I start a build, the selected scheme/target builds and completes, and then issues from the other schemes/targets start getting added to the issues list (as in the screenshot above) as their respective builds finish. – bhaller Dec 25 '22 at 19:46
  • @matt The project lives on GitHub here: https://github.com/MesserLab/SLiM. It was created in maybe Xcode 12.2 or so, I think, so it is not super old, but not a fresh 14.1 project. It'd be pretty surprising (to me at least) if a behavior like this depended on the age of the project, though. Anyhow, I fixed the various build issues so it builds pretty cleanly now. I tried adding a #warning to eidos_rng.h (included by all targets), and interestingly the behavior did not reproduce with that. I wonder if it happens particularly with deprecation warnings, or something? Now I'm puzzled. – bhaller Dec 26 '22 at 05:09
  • Silly me, I didn't even notice that all the warnings were deprecations. – matt Dec 26 '22 at 13:34
  • Nevertheless I'm still not able to reproduce in a new project. I made a new project with two app targets / schemes. A file shared by both targets has a deprecated call. No matter what I do, I see just one warning in the Issues navigator. However, I'm going to suggest a kind of workaround as an answer, even though it doesn't _really_ answer the question. – matt Dec 26 '22 at 15:29
  • @matt Thanks for looking into it. I upvoted your answer, since it's potentially helpful, but I'm not going to accept it since, as you say, it doesn't really answer the question. I'll also continue to observe the behavior in Xcode and see if I can figure out what's going on in more helpful detail. Hard to believe that "build all targets instead of just the selected one" is somehow a side effect of the project being a couple of versions old – I think there must be a project setting somewhere that is set to do that, in the Build Settings or Preferences, but I can't find it. – bhaller Dec 26 '22 at 16:53
  • I'm with you. This isn't the first time I've heard something like this, so it will be interesting to see if you can track this down. — Another thing to watch out for is the danger of illusion. Once you _have_ built a target and gotten a warning, that warning might remain even if you now build a _different_ target. So one thing to try would be Product > Clear All Issues and try building again. – matt Dec 26 '22 at 16:58
  • @matt Yes; but the screenshot above was taken after opening the project for the first time in the new Xcode, without switching targets at all. So all those warnings from the other targets just showed up of their own volition. And each time I fixed a particular warning and did a build, ALL the targets would rebuild (or so it appeared in the UI). – bhaller Dec 26 '22 at 17:08
  • 1
    @matt See the addendum I just added on the question. The problem is not going away, not limited to warnings (errors too), not limited to deprecation. Ack! – bhaller Dec 26 '22 at 17:57
  • Did you ever find a solution to this? I'm seeing the same behavior. I think it was introduced in Xcode 14, as I never had this problem before, but it is very annoying. – Rob Feb 06 '23 at 17:26
  • You say “when I do a build it builds all of my targets/schemes”. Actually, look at “Report Navigator” and you’ll see that “Product” » “Build” only builds the scheme’s current target. What’s happening is that while you’re editing your code, Xcode does a real-time syntax checking which allows it to show you code issues as you’re editing, between explicit builds. It is this syntax checking process that ignores the current scheme’s target. – Rob Feb 06 '23 at 18:34
  • 1
    @Rob perhaps, but if I turn off "Show live issues" in Xcode's General prefs, the behavior doesn't change; and if I start a new build, all of the issues disappear and then reappear in the Issue navigator (indicating that they are connected to building, in some way). Previous versions of Xcode certainly had the real-time syntax checking, but did not exhibit this very annoying behavior (which totally wedges my machine because it's spending so much CPU on all the different schemes in my project). Do you have a way to turn this behavior off? – bhaller Feb 06 '23 at 21:23

0 Answers0