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

Support SPM generated projects #124

Merged
merged 4 commits into from
Oct 21, 2017
Merged

Support SPM generated projects #124

merged 4 commits into from
Oct 21, 2017

Conversation

pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Oct 19, 2017

Resolves #119

Short description 📝

As @josefdolezal described in the issue above, projects generated by the Swift Package Manager cannot be opened with xcproj because the project.workspace property is non-optional. The purpose of this PR is to provide support for those.

Solution 📦

Since property is public, any change in the property would introduce a breaking change in the API. What I did instead is initializing a workspace with one file reference, self: in the same way Xcode does.

Implementation 👩‍💻👨‍💻

  • Add changes to the XcodeProject model.
  • Add some unit and integration tests.

Note: I added a project that we use as a fixture for the test that I added.

GIF

gif

@pepicrft pepicrft added this to the 1.0.1 milestone Oct 19, 2017
@pepicrft pepicrft self-assigned this Oct 19, 2017
@pepicrft pepicrft requested a review from a team October 19, 2017 16:26
@@ -34,6 +34,12 @@ public class XCWorkspace {
self.data = data
}

/// Returns an empty workspace.
public static var `empty`: XCWorkspace {
let data = XCWorkspace.Data(references: [])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to omit XCWorkspace. and use only Data(references: [])?

return fixturesPath() + "iOS/Project.xcodeproj"

func test_init_usesAnEmptyWorkspace_whenItsMissing() {
let got = projectWithoutWorkspace()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you use this name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a project that doesn't have a workspace internally. Would you use a different name @artemnovichkov?

@@ -34,6 +34,12 @@ public class XCWorkspace {
self.data = data
}

/// Returns an empty workspace.
public static var `default`: XCWorkspace {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes it seem as if it's a singleton. You could remove this and just make a new initializer that doesn't take data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes more sense. Let me update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @yonaskolb

@pepicrft pepicrft merged commit d67a309 into master Oct 21, 2017
@pepicrft pepicrft deleted the project-workspace-optional branch October 21, 2017 07:15
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.

Swift Package Manager Support
3 participants