Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Fixes problems loading information about workspaces #27

Closed
wants to merge 1 commit into from
Closed

Fixes problems loading information about workspaces #27

wants to merge 1 commit into from

Conversation

jamiely
Copy link

@jamiely jamiely commented Dec 17, 2012

There are problems that occur because xcodebuild -list -workspace FILE only returns scheme information

@codecaffeine
Copy link
Contributor

@jamiely I’ve run into this problem as well, but this solution might be problematic.

Assume you have both a FooBar.xcodeproj and a FooBar.xcworkspace file in the directory you’re running this from (very common use case, especially with CocoaPods). When you run xcodebuild -list without the workspace argument, it pulls from the FooBar.xcodeproj rather than the FooBar.xcworkspace which may have different targets, schemes, and configurations defined.

The ultimate issue is @xcodebuild_info.build_configurations will be nil if a workspace is passed in. This causes a crash because build.rb has a check to make sure the selected build_configuration is in @xcodebuild_info.build_configurations.

The best solution is to not check that the configuration isn’t in the list of available configurations. This check isn’t needed because xcodebuild will use the default configuration if it doesn’t recognize the configuration that’s passed in.

@mattt
Copy link
Contributor

mattt commented Apr 28, 2013

Sorry to be late to the party. What's the consensus on this, @jamiely & @codecaffeine? Should this patch be merged, or is there another fix to use?

@jamiely
Copy link
Author

jamiely commented Apr 30, 2013

@codecaffeine has a good point. I think that should resolve the issue.

@codecaffeine
Copy link
Contributor

Unfortunately, xcodebuild -workspace <workspace> -list just doesn’t give as much info as xcodebuild -project <project> -list. I’m guessing this is because workspaces only deal with schemes which tie the configuration to the build action?

The other option I’ve played around with is parsing the workspace file (contents.xcworkspacedata) to get the project file paths and passing that into xcodebuild. It didn’t really give me any added benefits and made the code more fragile (parsing XML, handling multiple project files).

@lukeredpath
Copy link

Running into this problem too; ultimately, I think if a workspace and scheme are specified, then configurations are completely irrelevant as they are specified by the scheme. I think shenzhen is trying to be too clever for its own good and is essentially trying to duplicate the logic of what combinations of project/workspace/scheme/configuration are valid - it should just past options into xcodebuild and let xcodebuild fail if the wrong options are supplied IMO.

@lukeredpath
Copy link

Its worth pointing out that this was already fixed once in #13

@codecaffeine
Copy link
Contributor

I agree with @lukeredpath because xcodebuild always uses default configuration even if nothing is passed using the -configuration flag. The -configuration flag is just an override from the default behavior. Therefore, I’d go as far as to remove the determine_configuration! method.

@codecaffeine
Copy link
Contributor

The downside with the above change is we lose the configuration reference in Build Output Info:

Building "MyApp" with Scheme "MyScheme" and Configuration "Debug"

becomes

Building "MyApp" with Scheme "MyScheme"

@codecaffeine
Copy link
Contributor

Hrmm. Just running shenzhen with ba9ec07, I really dislike not knowing what the configuration is. Any other thoughts?

@lukeredpath
Copy link

Maybe saying something like "using default configuration [for scheme]" would be reassuring?

On 21 May 2013, at 16:02, Matt Thomas notifications@github.com wrote:

Hrmm. Just running shenzhen with ba9ec07, I really dislike not knowing what the configuration is. Any other thoughts?


Reply to this email directly or view it on GitHub.

@lukeredpath
Copy link

Does 'xcodebuild [opts] -showBuildSettings' provide anything more useful?

Sent from my iPhone

On 21 May 2013, at 16:02, Matt Thomas notifications@github.com wrote:

Hrmm. Just running shenzhen with ba9ec07, I really dislike not knowing what the configuration is. Any other thoughts?


Reply to this email directly or view it on GitHub.

@codecaffeine
Copy link
Contributor

It -showBuildSettings does show the default configuration.

There is a quirk, though. If you have a unit testing target tied to the scheme, it’ll show the build setting for both the app target and the unit testing target.

@codecaffeine
Copy link
Contributor

In 260d804, I’m gathering the build settings before we set the configuration variable. That way we can set it to the build setting CONFIGURATION if it’s not specified as an argument.

xcodebuild is interesting. If you pass a -target the default configuration is Release but if you pass -scheme the default configuration is Debug. The more you know 🌠

@codecaffeine
Copy link
Contributor

FYI, 260d804 has a bug with PackageApplication if you override the default configuration. I’m still investigating

@mattt
Copy link
Contributor

mattt commented May 30, 2013

@codecaffeine Alright. Keep me posted, and let me know when the pull request is ready to be merged in.

@codecaffeine
Copy link
Contributor

@mattt I’ve been running with this change for the past week without issue. I do wonder if there’s a good way to add some sort of testing to Shenzhen.

@mattt mattt closed this in 6208ad8 Oct 4, 2013
@mattt
Copy link
Contributor

mattt commented Oct 4, 2013

Really sorry for how long this took to merge in, @codecaffeine. 6208ad8 is finally in master. Cutting a new release as soon as I clear out the rest of the open issues. Thanks!

@codecaffeine
Copy link
Contributor

Hah, no worries! You have a lot going on. asciiwwdc.com alone is worth the wait

@enriquez enriquez mentioned this pull request Oct 8, 2013
mattt pushed a commit that referenced this pull request Nov 13, 2013
Use configuration if passed, otherwise find the default configuration
from build setting
Conflicts:

	lib/shenzhen/commands/build.rb
mbaltaks pushed a commit to mbaltaks/shenzhen that referenced this pull request Jun 2, 2015
Use configuration if passed, otherwise find the default configuration
from build setting
Conflicts:

	lib/shenzhen/commands/build.rb
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants