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

Xcode schemes #207

Merged
merged 19 commits into from
Aug 18, 2023
Merged

Xcode schemes #207

merged 19 commits into from
Aug 18, 2023

Conversation

godrei
Copy link
Contributor

@godrei godrei commented Aug 14, 2023

Context

Our tooling (go-xcode libs, ios steps, and project scanner) expects shared schemes to be placed in the project's shared data directory (<project_name>.xcodeproj/xcshareddata/xcschemes) as a .xcscheme file.

This expectation is not necessarily valid, by default Xcode projects are generated with a shared scheme, but this scheme isn't in the shared data dir as a scheme file. The scheme file gets generated when you modify any scheme related setting, but Xcode works well without it.

This PR updates the xcodeproject package's scheme management to make it more similar to how Xcode handles schemes.

Related ticket: https://bitrise.atlassian.net/browse/BIVS-2082

Changes

1, New scheme listing logic

The visible schemes are the project's shared and user schemes (of the current user). Other user's schemes are not considered by Xcode.

The default schemes are not living as xcscheme files, but Xcode stores information about them under the current user's xcschememanagement.plist.

If the project doesn't have any visible schemes, Xcode recreates the default schemes unless the 'Autocreate schemes' option is disabled. If this option is disabled, Xcode presents a 'No schemes’ message and no actions are available.

In the case of workspaces, the logic is pretty much the same, but the 'Autocreate schemes' option is stored under the workspace and the same project level options are not considered.

2, Missing properties added to the scheme data model

The skipped and parallelizable fields were missing from the TestableReference. Because the package works with complete data models, I just added them, but they aren't used by the code.

The shouldAutocreateTestPlan was also added to the TestAction, in a follow-up PR we might update Test Plan handling, to utilize this new property.

@godrei godrei marked this pull request as ready for review August 16, 2023 08:44

return tmpDir
}

// GitCloneBranch clones a branch from a git repository into an existing directory
func GitCloneBranch(t *testing.T, repo string, branch string, dir string) {
cmd := command.New("git", "clone", "-b", branch, repo, dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's worth adding --depth=1 for fast tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in: 473d0c3

@godrei godrei requested a review from lpusok August 16, 2023 11:02
ofalvai
ofalvai previously approved these changes Aug 16, 2023

func (p XcodeProj) userSchemesDir() (string, error) {
// <project_name>.xcodeproj/xcuserdata/<current_user>.xcuserdatad/xcschemes/
currentUser, err := user.Current()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to check for the current user only, if running in a CI env?
I assume in most cases schemes would be recreated if a specific user schema would not be found, so maybe would not break for most people who relied on the previous version that did not consider the current user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should follow how Xcode behaves, to avoid confusion.
I don't think it is too frequent, that you intentionally make a scheme not shared and then customize it.
Also, steps and tools depending on this package might be running locally too (this is probably the minority of uses, but still I think we should consider it), not just in CI.

ofalvai
ofalvai previously approved these changes Aug 17, 2023
}

var settings serialized.Object
if _, err := plist.Unmarshal(workspaceSettingsContent, &settings); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: are we ignoring directories, symlinks here?

Copy link
Contributor

@lpusok lpusok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work.

@godrei godrei merged commit dd93ee0 into v1 Aug 18, 2023
@godrei godrei deleted the xcode-schemes branch August 18, 2023 07:02
This was referenced Aug 18, 2023
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

Successfully merging this pull request may close these issues.

3 participants