-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
SPM: allow podspecs to declare Swift Package Manager dependencies with spm_dependency #11953
base: master
Are you sure you want to change the base?
Conversation
fadf326
to
d34cd52
Compare
@@ -6,7 +6,8 @@ | |||
url = https://github.com/tonymillion/Reachability.git | |||
[submodule "spec/cocoapods-integration-specs"] | |||
path = spec/cocoapods-integration-specs | |||
url = https://github.com/CocoaPods/cocoapods-integration-specs.git | |||
url = https://github.com/mfazekas/cocoapods-integration-specs.git |
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.
should be reverted before merge
@@ -20,7 +20,8 @@ gemspec | |||
|
|||
group :development do | |||
cp_gem 'claide', 'CLAide' | |||
cp_gem 'cocoapods-core', 'Core' | |||
# cp_gem 'cocoapods-core', 'Core' | |||
gem 'cocoapods-core', :git => 'https://github.com/mfazekas/Core', branch: 'podspec-spm' |
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.
should be reverted before merge
Thank you for this! 👏 |
@dnkoutso how can we move forward with this? |
is there anything we can do to help in shipping this ? 🙂 |
A lot of it depends on folks' time to do OSS. As CocoaPods, if there's not a critical need for a release during betas we tend to really only ship after the RC version of Xcode - so I think this is likely to get some eyes over it in prep for making a release for the next Xcode major We're happy conceptually with the idea, just needs some eyes over implementation ideally around when we are looking at making the next release |
@mfazekas I tested it (after rebasing on cocoapods 1.13.0), and it seems that if I define a dependency in a subspec, I see the library declared in the pod target where I defined the SPM dependency, but the spm dependency isn't added to the Pods xcodeproj. I want to look into this to make it work, would you have some insight for me on where to look ? That would be really helpful🙂 🙏 |
end | ||
|
||
def install_spm_dedpendecies(project, pod_targets) | ||
spm_dependencies = pod_targets.flat_map { |target| target.root_spec.consumer(target.platform).spm_dependencies } |
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.
updating this line to get the dependencies on all the specs lets us define spm dependencies at the subspec level 🙂
spm_dependencies = pod_targets.flat_map { |target| target.root_spec.consumer(target.platform).spm_dependencies } | |
spm_dependencies = pod_targets.flat_map { |target| | |
target.specs.flat_map{ |spec| spec.consumer(target.platform).spm_dependencies } | |
} |
I'm getting here step by step, I added the possibility to add local packages to a podspec. one problem I have now is that for reasons (unknown to me for now) I get a it means that if I have a Pod module A that depends on a swift package B, when I build my project, A compiles, but I get a compile error on the project stating that it doesn't know about B. I may be missing a piece here (I'm lacking understanding of the build system) and any help would be great 🙂. |
Can you check |
Thank you for your quick answer 🙏 It seems that I have everything set here and the paths were added. my error is not a my target does not use the swift package code, only the pod. if I manually add my package to the target, everything compiles. I'm trying with a big project, I'll try making an example |
Ok I have a way of reproducing this, if the podspec that import the swift package is defined as a SPMIntegrationInPodsExample.zip you can install the env by doing :
I would totally understand that you don't have time for this, but if you think of anything that could be of help to me on how to better understand / solve let me know, I'll try to implement and test that to push a PR on your fork 🙂 |
Hi every one, I'm still investigating on the I have a test project that has 3 pods:
in that configuration when I build my app I get a build error saying that I have duplicated symbols for I made another sample project, where I have almost the same architecture, but I don't use Pods, I use static libraries directly that have SPM as dependencies, and everything works fine, I can compile without problem. I may be missing what the difference is between a vanilla static lib and a Pod static framework is. (it seems that in the case of cocoapods, it's generating if anyone has any idea that would be super helpful 🙂 🙏 . Funnily if I add If I do this everything seems to compile and work (no more duplicated symbols 🤷♂️) but it's more of a hack as I need to declare the package in a dynamic pod to see its generated framework in the build products. |
@mfazekas Imagine the situation. I have an OSS project on Github that defines SPM package. I am able to consume it via Cocoapods by manually creating So, I am wondering if your PR can handle this. |
@contfedorov so this PR does what's described in: https://github.com/mfazekas/pods-spm-dep-poc/#how-it-works 1.) Adds the Package Dependency to the Pods project. |
@mfazekas UPD Checked a bit more, looks like there are no chances to do it via podspec only. Thanks for your POC! |
Implements: #11942
See also: #743
and: #344
Also note that implementation is very simplistic, if same spm is included by multiple specs they have to have the exact same requirements. In future this can be improved by implementing a version range merge.
See https://github.com/mfazekas/pods-spm-dep-poc/#how-it-works on description of the changes made to the pods project.
I've added a single integration test, but it required some hacking to project to to_yaml:
https://github.com/CocoaPods/CocoaPods/pull/11953/files#diff-2f87abe8c188a9e01c085e87a3a38d78dcc50ca8d2fe79367e5e2deec6bcd778R13-R15