Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheme auto selects first build target as an executable to run. #589

Closed
mkuliszkiewicz opened this issue May 20, 2019 · 9 comments
Closed

Comments

@mkuliszkiewicz
Copy link

👋 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.

let target = project.getTarget(scheme.build.targets.first!.target)

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

let target = project.getTarget(scheme.build.targets.first!.target)
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!

@tomquist
Copy link
Contributor

tomquist commented Jun 5, 2019

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

@edulpn
Copy link

edulpn commented Dec 17, 2019

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.

@edulpn
Copy link

edulpn commented Dec 17, 2019

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

@brentleyjones
Copy link
Collaborator

@edulpn That would be nice, thanks!

@edulpn
Copy link

edulpn commented Dec 18, 2019

@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.

@brentleyjones
Copy link
Collaborator

@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: 5e96eed

@edulpn
Copy link

edulpn commented Dec 18, 2019

@brentleyjones cool! I'll take a look

@jcolicchio
Copy link
Contributor

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

@yonaskolb
Copy link
Owner

yonaskolb commented May 31, 2020

Master now has run.executableName that resolves this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants