Swift packagemanager not working
PatrickKuijpers opened this issue ยท 6 comments
When a package is added using the swift packagemanager, then the new package is removed as soon as I run xcake make
. Is it not supported by xcake, is it bugged, or am I missing some necessary configuration in the cakefile?
@PatrickKuijpers I did remember it was somewhat complicated so I checked. Apparently Apple's way of adding SwiftPM packages to an Xcode project is quite cumbersome behind the scenes, and doesn't have a single Package.swift
that centralizes all the dependencies:
1 - Reference the package, similar to the manifest file
786816C424AE1C3600FECB42 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.1;
};
};
2 - Create a built package product:
786816C524AE1C3600FECB42 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
package = 786816C424AE1C3600FECB42 /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit;
};
3 - Use the special file reference in the framework build phase:
C6A8E264F7297619122A1AE8 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
786816C624AE1C3600FECB42 /* SnapKit in Frameworks */,
7199C1F72237189779807730 /* Foundation.framework in Frameworks */,
B64D979A0BF88947BB5EB2C3 /* UIKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Nerd-sniping does work - @PatrickKuijpers I've managed to figure out a way to do what you were asking for - but not part of Xcake (doesn't seem related). ๐
New gem, called Xcoed (Xcode-coed) - you create a SwiftPM Package.swift
file, and it matches it with your project.
In the Cakefile
you can add it to the before_save
phase like so:
project.before_save do |project|
Xcoed::integrate_package_swift! project
end
@PatrickKuijpers here is the demo app for this Xcoed utility: https://github.com/igor-makarov/DemoXcoed
Thanks for the demo app! :)
I only came across this error when running bundle exec xcake make
{"name"=>"swiftui-navigation-stack", "requirement"=>{"branch"=>["develop"]}, "url"=>"https://github.com/biobeats/swiftui-navigation-stack.git"}
bundler: failed to load command: xcake (/usr/local/bin/xcake)
RuntimeError: Unsupported package requirement `branch`
Is it also possible to support other package dependency requirements, such as revision
and branch
?
The Package.swift file looks like this:
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "PackageName",
products: [
],
dependencies: [
.package(
url: "https://github.com/biobeats/swiftui-navigation-stack.git", from: "0.0.0"),
],
targets: [
.target(
name: "TargetName",
dependencies: [
"NavigationStack"
]
),
]
)
Hi @rtjinasjoe!
I have added the support for branch
and revision
requirements.
Please get the latest Xcoed version .
In the future, make sure to open an issue on Xcoed repo, so we can discuss it there ๐ช๐ป
Thanks @igor-makarov for the quick and awesome fix!
In the future, make sure to open an issue on Xcoed repo, so we can discuss it there ๐ช๐ป
Will do! :)