-
Notifications
You must be signed in to change notification settings - Fork 822
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 for Swift Packages #624
Conversation
b478357
to
e3b66f8
Compare
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.
LGTM🙆♂️
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'm going to pull this down and experiment with our project to see if everything is good. Looks good from review though.
Docs/ProjectSpec.md
Outdated
## Swift Package | ||
Swift packages are defined at a project level, and then linked to individual targets via a [Dependency](#dependency). | ||
|
||
> Note that Swift Packages don't work in projects with configurations other than Debug and Release |
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.
Can we add a link to https://bugs.swift.org/browse/SR-10927?
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
Is it possible to allow for adding multiple products? One use case is that I am looking to add a target that contains mock/test data. Edit: project.yml:
Package.swift:
|
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.
Because these are statically linked, we should treat them like target
dependencies that are static libraries. What this means is that if I declare the following:
packages:
Yams:
url: https://github.com/jpsim/Yams
majorVersion: 2.0.0
targets:
App:
dependencies:
- target: StaticLibraryA
- package: Yams
StaticLibraryA:
dependencies:
- package: Yams
Then Yams
should only be linked to App
, not StaticLibraryA
, otherwise we will get duplicated symbols. (And the same if only StaticLibraryA
declared the dependency). You can see how it was done at https://github.com/yonaskolb/XcodeGen/blob/swift_packages/Sources/XcodeGenKit/PBXProjGenerator.swift#L470-L479 for target
dependencies.
We also need to add the packages as Target Dependencies (especially once you make the above change, since Xcode won't know to build the SPM package before building StaticLibraryA
):
Really nice work @yonaskolb!
This works great for us! Thanks! Supporting local packages would help us immensely when it comes to project maintenance. This seems like it should be fairly easy since Xcode 11 already fully supports local packages. A little background for use case... Our main usage of this feature is to generate xcode projects for our Swift Package Manager projects that need to be tested on multiple platforms via command line; especially those with special requirements. For example, our security framework requires the keychain access entitlement on all platforms except macOS to run unit tests. To facilitate CI we generate a project using Now that xcodegen supports package dependencies we can generate a fairly straightforward project for the framework, then we add our test & test host targets. Unfortunately this means we are duplicating package dependencies that are already defined in our Supporting local packages would allow us to generate an |
With Xcode 11 Final right around the corner ... are there any plans on merging this soon into master with an official release? |
e4acc8d
to
6c9b814
Compare
Ok I've:
@brentleyjones could you look this over again, and make sure it works with your static library setup
To accomplish that you can use multiple dependency declarations. This allows us to control settings for a single linkage if needed dependencies:
- package: SomeDependency
product: SomeDependency # this isn't required
- package: SomeDependency
product: SomeDependencyTestData
Yes this will be possible. It isn't in this PR but will come in a followup one. It's just adding a path as a PBXFileReference and Xcode takes care of the rest.
Yes, I'd like to get this released as soon as possible. If you could test it on your setup that would help. Mint makes this easy:
|
I've added support for package target dependencies for proper build dependency resolution. |
bea4f4a
to
6da4686
Compare
I just experimented with it (see https://github.com/allaboutapps/ios-starter/tree/spm) and it works great! |
@yonaskolb I'll start reviewing this shortly. I'll let you know! |
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.
Works great!
Released in 2.8.0! |
PR yonaskolb#624 introduced a bug with operator priorities discarding false link settings for dependencies when the target is an executable and the dependency a static library. This PR fixes that.
PR #624 introduced a bug with operator priorities discarding false link settings for dependencies when the target is an executable and the dependency a static library. This PR fixes that.
This adds support for defining and linking to Swift Packages
See the ProjectSpec diff for more documentation https://github.com/yonaskolb/XcodeGen/pull/624/files#diff-938b5cf412212f1137a53f072512963a
Please test this out and report any issues.
One thing that is broken as of Xcode 11 beta 5 is that packages don't work if you are using configurations other than the default
Debug
andRelease
. That SPM bug is tracked here https://bugs.swift.org/browse/SR-10927