-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Add XCLocalSwiftPackageReference Support #799
Add XCLocalSwiftPackageReference Support #799
Conversation
✅ Deploy Preview for xcodeproj ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hello @kwridan, @pepicrft, @yonaskolb 👋🏻 Firstly, thank you very much for supporting this project. It is used by me in many different Swift scripts I wrote. Could you please review this PR? It is mentioned in Sourcery (krzysztofzablocki/Sourcery#1206) and other projects which face this issue on Xcode 15. I hope I did not miss anything, but if I did, could you please be so kind informing me, I'll apply the change as soon as I can. Thank you 🙏🏻 |
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.
Thanks for contributing this @art-divin
I wasn't aware Xcode 15 changed this 😅, local packages were previously supported as file references and Xcode somehow deals with them correctly. It seems this is still the case in Xcode 15 if you add a local package via dragging from Finder to Xcode, however if you use the Package editor UI and select "Add Local" this is where this new format is used.
From testing locally, it seems we may be missing a few pieces. I created a project with a local package, read it via XcodeProj and wrote it back to disk again - the expectation was that it would result in no diffs, however noticed a few things got omitted 🤔
- packageReferences = (
- FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "../LocalPackage" */,
- );
/* End XCConfigurationList section */
-/* Begin XCLocalSwiftPackageReference section */
- FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "../LocalPackage" */ = {
- isa = XCLocalSwiftPackageReference;
- relativePath = ../LocalPackage;
- };
-/* End XCLocalSwiftPackageReference section */
-
It'll be helpful to include a small fixture of a project with a local package using this new format in Fixtures
folder and performing a similar integration test (see some of the example test in XcodeProjIntegrationTests
).
👋🏻 Hello @kwridan , thank you very much for your test! Apparently, decoding was not set properly. So I have added an integration test to What I have discovered is that I guess it is better to split this feature into multiple PRs, and firstly, implement support to unblock further work. What do you think? Thank you 🙏🏻 |
Hey @kwridan , I have added one more integration test, and seems that everything1 is settled now. Please let me know if this PR can be merged or still it is missing somethig. P.S. when run locally, I got failed unit tests related to
in file Test Case '-[XcodeProjTests.XcodeProjIntegrationTests test_read_write_produces_no_diff]' started.
error: cannot run gpg: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object Footnotes
|
cc @pepicrft, @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.
I have added one more integration test, and seems that everything1 is settled now.
Thanks for the updates @art-divin and for adding the fixture, note the fixture can be simplified and slimmed down to focus primarily on the local package (i.e. it wouldn't need any of the extra schemes / breakpoint files / remote packages etc...) Locally I created a dummy project with a local package and used that test.
when run locally, I got failed unit tests related to git checks, specifically, locally I have enabled all commits signed by default with gpg. So when run, these unit tests fail with the following error:
Interesting, indeed looks like it may be related to the signed commits, as locally and on CI those seem to be ok. Perhaps locally only to get it working you can modify the test helper that invokes the git command to include the appropriate extra arguments?
On the topic of this sort of test, I re-ran it against a local project I created with a local swift package and it seems a diff is still produced with the comments:
(Xcode uses relative path, vs the changes in PR utilise the name)
@@ -117,7 +117,7 @@
);
mainGroup = FBF72AFE2AD3E600003BEEEF;
packageReferences = (
- FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "../LocalPackage" */,
+ FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "LocalPackage" */,
);
productRefGroup = FBF72B082AD3E600003BEEEF /* Products */;
projectDirPath = "";
@@ -366,7 +366,7 @@
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
- FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "../LocalPackage" */ = {
+ FBE04FC42AD3E7F70014D6BD /* XCLocalSwiftPackageReference "LocalPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../LocalPackage;
};
it might be worth including that sort of test against the fixture?
/// Remote Swift packages. | ||
public var remotePackages: [XCRemoteSwiftPackageReference] { |
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.
to ensure we don't introduce a breaking API change can we maintain the old variable and mark it as deprecated?
/// Remote Swift packages. | |
public var remotePackages: [XCRemoteSwiftPackageReference] { | |
/// Remote Swift packages. | |
@available(*, deprecated, message: "use remotePackages or localPackages.") | |
public var packages: [XCRemoteSwiftPackageReference] { | |
remotePackages | |
} | |
/// Remote Swift packages. | |
public var remotePackages: [XCRemoteSwiftPackageReference] { |
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.
Done, thank you ✅
👋🏻 Hey @kwridan , Thank you for your throughout review 🤝 I have addressed all the points mentioned and hopefully this time PR is ready. However, I noticed that some other PRs also include changes related to contributors. Should I do it here as well? Anything else? Thank you |
@all-contributors add @art-divin for code |
I've put up a pull request to add @art-divin! 🎉 |
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 have addressed all the points mentioned and hopefully this time PR is ready.
Awesome thank you for the great work on this, testing locally it's all working nicely now 👍
I noticed that some other PRs also include changes related to contributors. Should I do it here as well? Anything else?
Done via #800
One nit would be to squash this PR before merging there are few commits in here |
Thank you for your approvals 🤝 Please merge this MR at your convenience, I do not have enough privileges, thank you 👍🏻 |
@pepicrft Any chance this change can be released soon? People creating new projects in Xcode 15 that use local package references are currently unable to use XcodeProj (or tools that depend on it) because project parsing fails with an error. |
Resolves krzysztofzablocki/Sourcery#1206
Short description 📝
This PR implements parsing of new element type named
XCLocalSwiftPackageReference
which seems to be introduced with the release of Xcode 15.Solution 📦
To support the new element type, I simply copied everything related to
XCRemoteSwiftPackageReference
and removed all code related to VersionMatching and "URL". Instead, onlypath
argument is supported for instantiatingXCLocalSwiftPackageReference
.Implementation 👩💻👨💻
XCRemoteSwiftPackageReference
toXCLocalSwiftPackageReference
XCLocalSwiftPackageReference
toPBXObjectParser
switch statementXCLocalSwiftPackageReference
objects inPBXObjects
XCLocalSwiftPackageReference
support inPBXProject
PBXProjEncoderTests