-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Swift Package fixes #444
+29
−27
Merged
Swift Package fixes #444
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9679ef4
make swift package inits and properties public
yonaskolb bb25dc6
add .swiftpm to .gitignore
yonaskolb 2da634f
update changelog
yonaskolb 6c9c400
make project packages public and non optional
yonaskolb 371cd13
Make PBXTarget.packageProductDependencies non optional
yonaskolb 22215cc
Make packageReferences attribute optional
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,17 +111,17 @@ public class XCRemoteSwiftPackageReference: PBXContainerItem, PlistSerializable | |
} | ||
|
||
/// Repository url. | ||
var repositoryURL: String? | ||
public var repositoryURL: String? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch! Good catch |
||
|
||
/// Version rules. | ||
var versionRules: VersionRules? | ||
public var versionRules: VersionRules? | ||
|
||
/// Initializes the remote swift package reference with its attributes. | ||
/// | ||
/// - Parameters: | ||
/// - repositoryURL: Package repository url. | ||
/// - versionRules: Package version rules. | ||
init(repositoryURL: String, | ||
public init(repositoryURL: String, | ||
versionRules: VersionRules? = nil) { | ||
self.repositoryURL = repositoryURL | ||
self.versionRules = versionRules | ||
|
@@ -143,7 +143,7 @@ public class XCRemoteSwiftPackageReference: PBXContainerItem, PlistSerializable | |
} | ||
|
||
/// It returns the name of the package reference. | ||
var name: String? { | ||
public var name: String? { | ||
return repositoryURL?.split(separator: "/").last?.replacingOccurrences(of: ".git", with: "") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we've been doing for deciding whether a property should be optional or not is whether Xcode is able to open a project without that attribute. If I'm not wrong, Xcode is able to open a project that doesn't have this attribute. If that's the case, I'd keep this property as optional. It also ensures that we are not adding attributes to Xcode 10 projects that are are not readable by Xcode 10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed it to an empty array if there is nothing to decode, and only encode if there's something in it. I'm not sure I understand you, does this mess up a specific use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this change makes sense - optional arrays are often troubling when it comes to accessing their contents. I can't see a situation where this will cause a problem.
If you want to check the presence of a package inside the Xcodeproj it's possible to by calling
packageReferences.count > 0
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take the following scenario:
packageReferences
attribute.Xcode 10.x will ignore the attribute, but we are introducing unexpected modifications to the project. That's something we've always avoided, and I don't think it's solvable by not writing the array when it's empty, because that's another possible value for the attribute.
If I'm not wrong, I think Xcode 11 updates some attribute in the project to say that the project is compatible with version X of Xcode. What about using that value to decide whether the attribute should be written or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pepibumur What do you mean by attribute? The packageReferences? If the array is empty we don't write it to the project, exactly as if it was nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let me put it on a table:
By turning nil into an empty array we'll get a diff after writing the project to disk in the first scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume'd we wouldn't write
Empty packageReferences
. Is there a benefit to doing so? If we assume empty means we don't write it then we don't have to worry about the truth table above since we only handle two scenarios, empty and non-emptyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't any difference for Xcode. The point is that users don't want to see git diffs if the project hasn't been modified, and with the current implementation they will. I suggest the following modification:
Does that look good @ollieatkinson / @yonaskolb ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense - 👍