How to get Xcode 14.1 to build only my currently selected scheme/target?
Asked Answered
A

1

8

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!]

Aurie answered 25/12, 2022 at 2:39 Comment(16)
@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.Aurie
@matt The project lives on GitHub here: 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.Aurie
Silly me, I didn't even notice that all the warnings were deprecations.Parishioner
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.Parishioner
@Parishioner 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.Aurie
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.Parishioner
@Parishioner 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).Aurie
@Parishioner 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!Aurie
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.Cotidal
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.Cotidal
@Cotidal 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?Aurie
@Aurie - did you ever find a fix for this? I've been having the same problem for a long time and am stumped.Neuburger
@Neuburger - no, it remains an open problem, and continues to drive me crazy. Thanks for the reminder, though – I'm going to file a bug about it.Aurie
@Aurie did you ever find a fix for this? Currently having the same issue and it's driving me nutsAnthroposophy
@Anthroposophy Nope. Still drives me crazy. Hard to understand how/why this can persist for so long, when it is so broken.Aurie
I've never been clear on the difference - exactly like Apple! 🤪Mucor
S
2

This behavior also drives me crazy, and I keep landing here when searching Stack Overflow hoping someone has come up with an answer. Unless/until Apple provides a real fix for this problem, here's what I do when it happens:

  1. Choose Product>Clear All Issues
  2. In Product>Schemes>Manage Schemes, deselect all but one of the schemes and build it.
  3. Reselect all of the schemes you want to show up in the Schemes menu.

I don't know why, but for me (on Xcode 15.2 at least) this makes the problem go away, and any warnings and errors for the previously active scheme disappear from the issues when I switch schemes.

Salzhauer answered 11/9 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.