Xcodegen: Scheme auto selects first build target as an executable to run.

Created on 20 May 2019  路  9Comments  路  Source: yonaskolb/XcodeGen

馃憢 First of all, thank you for this amazing library!
We are in the process of migrating our big ( ~30 targets ) project into XcodeGen 馃帀 and we are loving it!
But we've stumbled upon an issue 馃檧

In our old project, we had a scheme that would aggregate all unit tests, which when build - would build all the apps, and when tested - would run all the tests. We've managed to express it using xcodegen in the following way:

schemes:
  AllTests:
    build:
      parallelizeBuild: true
      buildImplicitDependencies: true
      targets:
        - Target 1
        - Target 2
        - Target 3
    test:
      targets:
        -  Target 1 tests
        -  Target 2 tests
        - ...

However, we've noticed that AllTests target has run executable set ( this is the issue ), and we do not want that.
We've dug into xcodegen a bit deeper and we've found this bit of logic that selects the first build target as run if it's executable.
https://github.com/yonaskolb/XcodeGen/blob/846bae8b9ff45bbf1ac527a95ca1cf890748ba9c/Sources/XcodeGenKit/SchemeGenerator.swift#L117

Questions!

Question 1: Is there a way to express in the configuration file that we do not want AllTests to be runnable?
Like that 馃憞
Screenshot 2019-05-20 at 23 18 02
Question 2: If it's impossible and we were to make a PR with the fix, what is/was the reason for https://github.com/yonaskolb/XcodeGen/blob/846bae8b9ff45bbf1ac527a95ca1cf890748ba9c/Sources/XcodeGenKit/SchemeGenerator.swift#L117 this line of code?
Could we introduce a flag on a scheme runnable: true/false that would drive this behaviour?

Once again, thanks for all the great work!

Most helpful comment

We have exactly the same problem and it would be great to have a solution for this.

All 9 comments

We have exactly the same problem and it would be great to have a solution for this.

executable could be a parameter on a Scheme Run Action (here). It could default to the first target, but you could also explicitly say that you want it to be a specific application target, to ask on launch or that it does not have an associated executable (None), which covers the runnable: true/false flag.

@yonaskolb If it's okay, I could look into it and sending a PR

@edulpn That would be nice, thanks!

@brentleyjones I forked the repo and was already taking a look at the code. Any help or someone that can help me with how the spec parsing works and how it's forwarded to the Kit (also how default values are filled in)?
I thought about expressing this behavior as an enum (.none, .askOnLaunch, .application(name: String)), but I'm not familiar with any patterns already used in the project for this kind of configuration.

@edulpn I implemented the copyFiles(Config) build phase on the BuildPhase enum, which is similar to the type of spec change you want to make. This commit shows how I made that change: https://github.com/yonaskolb/XcodeGen/commit/5e96eedd78579dab3336d302b27bf6edc5305188

@brentleyjones cool! I'll take a look

Any updates on this? I'm currently renaming my targets such that the correct target shows up first alphabetically, and would love to not have to do this

Master now has run.executableName that resolves this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ImLaufderZeit picture ImLaufderZeit  路  5Comments

djbe picture djbe  路  6Comments

lukewakeford picture lukewakeford  路  6Comments

rpassis picture rpassis  路  5Comments

ismetanin picture ismetanin  路  3Comments