Open mfazekas opened 1 year ago
I think it's becoming increasingly important for CocoaPods to address this need.
My initial understanding (which could be mistaken) is that for Swift Macros, the only way to define and distribute them that works with Xcode is via SPM. And as you said, a variety of projects (notably the official Apple swift-*
utility ones, like swift-algorithms and swift-collections) are SPM only.
Yes, I echo that sentiment for Swift macro support.
We chatted (pretty briefly) about this idea and have a general consensus that we should support it in CocoaPods. Right now there are (at least) three implementations of the idea:
I think everyone is all working in the same sort of space here, but I think you've got the right abstraction level for getting started. I think we should look at the simplest implementation ATM, which is adding it at Podspec level as dependencies.
We are open to a PR adding this to CocoaPods core 👍🏻
While I think that CocoaPods/Bundle style semantic version declarations are easier to read, I think having something which can be directly passed to SPM is probably the winner here - its about us being forwards compatible with the SPM package format, if someone uses a ref which doesn't work in a newer SPM then they can update the Podspec and aren't forced to update CocoaPods.
I think we could note the dependency exists in our lockfile, but I think the resolving and locking process should all live in SPM (which means leaving their Package.resolved as the real source of truth) - this is a bit lossy, but feels like the right starting place given that SPM is an evolving platform (vs CocoaPods which ideally wants to not have to handle SPM changes)
For me the question mark is whether duplicate code being in the app is going to be an issue, if a dependency you use includes the pod "CocoaLumberJack"
and another includes the SPM version of it then the person running pod install
is at a bit of a bind.
Perhaps there could be some sort of de-duplication or ahead of time warnings (CP knows the repo for both for example), but maybe that's a 2.0 version of this feature.
+1
+1
With the release of Xcode 15, the Swift macro feature is officially available. We now want to incorporate this feature into the development repository of CocoaPods to assist in development. Therefore, may I inquire about the current progress and plans regarding this issue?
Hi Team, what is the plan for supporting SPM? Is there an ETA? :)
Hi Team, what is the plan for supporting SPM? Is there an ETA? :)
@snooky23 while waiting for the support from CocoaPods, you might want to look for a plugin that supports SPM integration. I wrote cocoapods-spm plugin to simplify such an integration. Hope it helps!
Any plan on this guys?
Can take a look at this stackoverflow discussion for temporary solution.
+1
+1
Background
Swift Package Manager is becoming the de-facto standard for new libraries, due to its builtin support in Xcode. Currently Cocoapods libraries that want's to consume a SPM package have these choices:
Suggested solution
Introduce SPM dependencies as part of pod spec.
In ruby this could look like:
This would perform the following modifications: 1.) Add the declared Swift Package Manger dependency to the Pods project 2.) Add the CocoaLumberjack dependency to the pod's target
Prototype
Proof of concept implementation is available at: https://github.com/mfazekas/pods-spm-dep-poc/
Questions/to be addressed:
The POC uses SPM syntax for versions
{kind: 'upToNextMajorVersion', minimumVersion: '3.8.0'}
, but it think we'd be better of using the gem version constraints syntax.~> 3.8.0
. But we'll need a method that converts gem version constraints to SPM. Also not everything is representable. Like Version Range require upper and lover range.~>2.1.0
{kind: "upToNextMinor",minimumVersion: "2.1.0" }
~>2.1
{kind:"upToNextMajor",minimumVersion:"2.1"}
]>=1.0.0,<1.2.0
{kind"versionRange",minimumVersion:"1.0.0",maximumVersion:"1.2.0"}
=1.0.3
{kind:"exact",version:"1.0.3"}
Lockfile. I don't think we can/should put SPM to the lock file. If we want to put SPM to the lock file we'd need to resolve the version. But that is something Xcode does. Xcode stores resolved data in
.xcworkspace/xcshareddata/swiftpm/Package.resolved
which is checked into the GIT. I'd say we're better not duplicating that info.Notes:
SWIFT_INCLUDE_PATHS
, so that Targets in Pod projects can find the modules. (Otherwise I getNo such module
error)References/related issues:
10049
11618
10463
https://developer.apple.com/documentation/packagedescription/package/dependency/requirement-swift.enum https://www.swift.org/package-manager/ https://guides.cocoapods.org/syntax/podspec.html https://forums.swift.org/t/possible-to-use-spm-packages-from-cocoapods-pods-project/53187/14