Show errors for current target only in xcode - ios

I just updated to Xcode 14.1 and noticed that when I build my app (which has 4 targets) and if there are some errors, it shows the same error for all the targets and not for just the target that I'm working on like the following so that makes the error count goes to noOfTargets*noOfActualCodebaseError, in my case (for 1 error) go 4 rather than 1 like the following:
(Also, the issues count in the images are wayyyyyy off)
Is there a way to just get the error for the target that I am working on or that I have selected?

Is there a way to just get the error for the target that I am working on or that I have selected?
No. If you told Xcode to compile all four targets, you see the errors for all four targets.
Presumably you've shared the same code file directly among all four targets. That's the real issue.
This wouldn't be happening if the code were in a framework or package (ie a single target, plus dependencies).

Related

Xcode compiles the storyboard for each app target when changed

We have a big Xcode project with 9 different targets for our app. They differ in branding, API-url's, and other smaller differences.
They are all using the same files/classes/storyboard, and only certain build settings, bundleID, appGroups etc are different. The logic in code that separates them are simply prepro-macros in the same files.
When I change something in the Storyboard, it recompiles the entire storyboard. Since it's a pretty big storyboard, it takes a while. My problem is that it compiles for each target. So, when I make a change, it compiles the entire storyboard nine times, and it takes a very long time. Since it is the exact same storyboard shared between these targets, why can't it compile it once and share the compiled result?
Every time I change something visual in Storyboard, or every time I have changed something small in the storyboard and try to build/run a target to a device, it says this in the status bar:
Building "MyTargetOne": | Compiling 1 of 1 Storyboard files
[...]
Building "MyTargetTwo": | Compiling 1 of 1 Storyboard files
[...]
Building "MyTargetThree": | Compiling 1 of 1 Storyboard files
etc.
Even if I try to run a specific target, and that target is first in the line of compiling, it still compiles the rest of the targets before it considers the app successfully built.
How can I prevent this, and only build the one I'm running?
I know about Editor->Automatically Refresh Views, but that didn't really help, other than that it doesn't show what I'm doing in the storyboard.. It still builds all targets when I build/run.
It is always a pain to play with the same files on different targets.
If your app deployment target is iOS8 and above, you can try creating dynamic framework(Cocoa Touch Framework) with your storyboard and link your target's binaries with it.

How to prevent storyboard from running every target in my application?

I have an Xcode project which has several targets, among which a shared target which has a dependency dedicated to increasing the build number when archiving.
Whenever I edit my Storyboards, the build number increases, which means the archiving target is run even though it is NOT the active target.
I've noticed that I get warnings on my IBDesignable elements, which according to another answer comes from one of my test targets not currently compiling properly, which confirms my thinking that Storyboard go and compile targets they should not, imho. These are coded in Swift, if it matters.
Henceforth, how do I make sure the storyboard compilation only involves the currently active target?

How do I make sure my Xcode UITest Target Only Builds the Target Application?

I have an Swift iOS project with 50+ targets each of which makes a slightly different version of the app for different clients (Different App Icons / Logos / Names / Colours etc).
I also have a test target for UI Testing with XCTest. The problem is that when I run a test rather than just building the target that has been selected as the Target Application for the test it is building all 50+ targets.
Obviously this takes a VERY long and will only get longer as more targets are added so I need to work out how to make sure that the only target that gets built is the target application.
Thanks.
Well, I figured it out so will put the answer here in case anyone else has the same problem.
Basically, In the Test Target -> Build Phases -> Target Dependencies all the targets had been added as dependencies unnecessarily. I just needed to remove them all.

Xcode second target gives Cannot Run Using Selected Device or Dead Bootstrap Subset

I am having an issue where I cannot get a second target in my Xcode project to run (using Xcode 5.1.1).
I have checked the Schemes and they appear to be identical except they each point to their own proper executable .app (as they should). The excecutable name matches the Product Name in Build Settings.
I checked Build Settings to make sure they each were pointing to individual Info.plist files (target1-Info.plist and target2-Info.plist). The second target has a different Target name, different Bundle ID and different Product Name from the first target.
In order to get the first target to run, I had to follow this post: Xcode 5 cannot run using selected device on iOS simulator
However the second target will still not run in the simulator and I will get one of the following errors:
Either I get this error which says Xcode cannot run using the selected device
Or I get the following message that appears in the debug area at the bottom of Xcode which says Dead bootstrap subset and Error spawning child process: Permission denied
Now if I archive both targets for iOS this gives an additional hint as to what the problem might be...
When I Archive Target 1, it takes about 15 to 20 seconds to build and archive and generates a 43MB estimated file size (this archive is correct).
But when I try to Archive Target 2, it takes about 1 second to build and archive and generates a 5MB estimated file size with a blank white icon. Target 2 should be the same 43MB file size as Target 1, so clearly something somewhere in Xcode is confused and causing Target 2 to not archive properly (which would explain why it is not running in the simulator).
Also the other thing I noticed is under Build Settings, Target 2 is missing all the Apple LLVM sections and I tried to get them to appear but cannot.
Any ideas would be appreciated. Thanks
So assuming that both targets were working fine at one time, and now one of them will no longer run, I basically duplicated the working target and deleted the non-working one like this:
Rename the bad Target name to something like BadTarget.
Rename the bad Scheme name to something like BadScheme.
Duplicate the good working target.
Rename this new duplicated target to something like NewTarget.
Change the Bundle ID, Bundle Name, Bundle Display Name and Product name of this new target.
Rename the new scheme that was created when you duplicated the target to something like NewScheme.
Test run the original working target and the new duplicated target to make sure they both work.
Make any other changes to new duplicated target Build Settings that are unique in the bad target. For example, I define a variable FreeApp or PaidApp in the Apple LLVM Preprocessor section to identify which target is the free/lite version versus the paid/full version.
Delete the bad Target.
Delete the bad Scheme.
I would hope somebody comes up with an easier solution, but this is the only workaround I could come up with.

Building for 2 different targets in an Xcode project has unexpected results

I'm using Xcode 4.3.3. My project has 2 targets and they are very similar (one was a duplicate of the other). The only thing is they have different names and there is a small amount of #ifdef going on. One project compiles a few more files and copies a few more bundle resources than the other. Other than that they ought to be the same. It's like having Pro and Lite app versions.
I seem to have a few issues (building for one of the targets is absolutely fine, so all these issues relate to the 'other' target)...
When building the 'other' target it gives me the warning "Multiple build commands for output file...". It is referring to 'icon-72.png'. However, I've not only removed the second reference to that file (still got the warning), but I have also removed that file entirely and removed all references I could find for it, including deleting the icon from the Target Summary, ensuring the file doesn't exist in any project folder in Finder for this project, and also ensuring it's not listed in 'Copy Bundle Resources' in 'Build Phases'. The warning still appears.
When building the 'other' target it doesn't give me the usual warnings. These warnings should exist in both builds at this time. I have checked what is being compiled and the files that should generate these warnings are included in both 'Compile Sources' in both targets' 'Build Phases'.
Building the 'other' target gives me 'Failed'. However, in the Issue Navigator there is no explanation as to why it failed.
Incidentally, the 'other' target was the original one, not the new one.
Also, I have tried cleaning before each build attempt and have also restarted Xcode. I have recently restarted the computer too.
Any help or general pointing in the right direction would be greatly appreciated.
Atb.
EDIT....
I updated the project settings as prompted in the Issue Navigator to use LLDB. Now I don't get any warnings for either target, but the 'other' target still fails to build without reason.
Right. Well, it turns out that this was mostly the answer (check the last comment). I closed the actual Xcode window with my project in (cmd-W), then I went to File > Open and opened the project file from there (as opposed to opening it from the splash window or the recents list).
Now I can see the warnings and tell why the build is failing too. Phew!!

Resources