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

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?

Related

Xcode: merge Unit tests into a single target

I'm developing a modular app with >30 modules, where each module has its own Unit test target. I also have a special test scheme which runs all Unit tests from all the targets.
The problem is - it's too slow. While the tests run fast, it takes a lot of time for Xcode to switch from one test target to another. The "all tests" scheme is supposed to be run in CI so I would really like to improve the performance.
I tried to convert all Unit test targets into static frameworks and link them to a new "merged" Unit test target. In this target I then created a single AllTests.swift file importing the frameworks and manually invoked tests on each of them. The performance improvement was ~4x.
However, this will be quite hard to maintain this file. My assumption is, since they are linked statically, there can be a way to make Xcode run imported in such a way tests automatically. If this works I'll be able to fully automate this process, keeping test targets for development and generating the "merged" target in CI.
What else I tried:
Investigated the option of using SourceKitten to parse the project and generate the AllTests.swift file automatically. This would require building the project one more time, eliminating the performance improvement.
Instead of linking frameworks, include references to source files into the merged target. This introduces a bunch of "multiple files with the same name" and "same declaration" errors that cannot be automatically resolved.
Made all declarations in the static frameworks public.
Googled a lot. This SO question is quite close but the solution doesn't work for me.
So the main question is - is there a way to make Xcode automatically include Unit tests that are part of a static framework the current target is linked against? Or any other suggestion on how I can automate this process will be very much appreciated.

Multiple Frameworks different targets XCode

If there are say 2 frameworks(framework-test,framework-live), one pointing to a test area and the other to live environment is there any way to keep both in the same xcode project and just change based on target or some flag?

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 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 : One test target for multiple app targets

I am wondering if you can link one Unit Testing bundle to multiple targets. So one can test all the application targets with one Testing bundle.
I have some shared code between all app targets but also some specific calculations based upon which app target is running.
Currently I have to set the Bundle Loader option in the Build Settings to the used application target's .app file if I want to test a different application target.
My question to you all is : can this be done without creating multiple test bundle targets for every app target, and without always changing the Bundle Loader option?
You need to:
Select the target you want to test
Go to Test navigation tab
Right-click on test target you want to enable
Click on Enable [name_of_your_target]
No, at this point you can't. It's like the extensions, you have to create a new one for each project's targets you have.
It's not pretty usefull but if the code differes from one to another target, the tests can fail because of missing code, not failing code.
It's why it's not allowed.
Sorry for the negative answer.

Resources