-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat(ios): spm package support #176
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Nice, thanks for the contribution! Will take a look soon |
First pass looks good to me. The |
It can go either way - really just wanted to save having to type/pass in the For the configure operation, perhaps something like this would work nicely? platforms:
ios:
targets:
App:
spmPackages:
- name: "swift-numerics"
libs: [ "Numerics" ]
repositoryURL: "https://github.com/apple/swift-numerics.git"
version: "1.0.0" |
@rigor789 apologies, forgot to respond. That looks good! |
No worries, I'll look at adding the configure operation like that. And just a note, we're test driving these changes against real projects, so will adjust anything as needed if we run into anything odd (though so far, it's bee working great!) |
Update: added support for local SPM packages. For local packages, the definition requires the package name, libs and a path, for example: // local SPM packages
await project.ios?.addSPMPackage('App', {
name: 'local-swift-numerics',
libs: ['LocalNumerics'],
path: 'path/to/package',
}) PS.: I will be looking at implementing the configure operations next. |
Update: Added the configure operation, for example platforms:
ios:
version: 16.4
targets:
App:
spmPackages:
- name: "swift-numerics"
libs: [ "Numerics" ]
repositoryURL: "https://github.com/apple/swift-numerics.git"
version: "1.0.0"
- name: "local-swift-numerics"
libs: [ "ComplexModule", "RealModule" ]
path: "../path/to/local-swift-numerics" Diff after running the above operation
diff --git a/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj b/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
index 5928a9c..f0d9623 100644
--- a/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
+++ b/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
@@ -28,6 +28,9 @@
507D3D05271DC2D000EEA707 /* My Share Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 507D3CFB271DC2D000EEA707 /* My Share Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };
+ 6457BCEED2DC47EDBF855E6E /* Numerics in Frameworks */ = {isa = PBXBuildFile; productRef = 483ED33D8EA44A62977EF3A4 /* Numerics */; };
+ CBB5D9DA80524BD886CE16B9 /* ComplexModule in Frameworks */ = {isa = PBXBuildFile; productRef = EFED82049B0144B7B4441595 /* ComplexModule */; };
+ 487C691400984C4C939C59A9 /* RealModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0933A1A614C64F4884E6F617 /* RealModule */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -127,6 +130,9 @@
buildActionMask = 2147483647;
files = (
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */,
+ 6457BCEED2DC47EDBF855E6E /* Numerics in Frameworks */,
+ CBB5D9DA80524BD886CE16B9 /* ComplexModule in Frameworks */,
+ 487C691400984C4C939C59A9 /* RealModule in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -287,6 +293,11 @@
productName = App;
productReference = 504EC3041FED79650016851F /* Awesome App.app */;
productType = "com.apple.product-type.application";
+ packageProductDependencies = (
+ 483ED33D8EA44A62977EF3A4 /* Numerics */,
+ EFED82049B0144B7B4441595 /* ComplexModule */,
+ 0933A1A614C64F4884E6F617 /* RealModule */,
+ );
};
507D3CC1271DC20100EEA707 /* My App Clip */ = {
isa = PBXNativeTarget;
@@ -411,6 +422,10 @@
507D3CE1271DC20300EEA707 /* My App ClipUITests */,
507D3CFA271DC2D000EEA707 /* My Share Extension */,
);
+ packageReferences = (
+ EBF7078813744D8DB3856886 /* XCRemoteSwiftPackageReference "swift-numerics" */,
+ E4715DA7E0374B379A8EE091 /* XCLocalSwiftPackageReference "../path/to/local-swift-numerics" */,
+ );
};
/* End PBXProject section */
@@ -1065,6 +1080,42 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
+
+/* Begin XCRemoteSwiftPackageReference section */
+ EBF7078813744D8DB3856886 /* XCRemoteSwiftPackageReference "swift-numerics" */ = {
+ isa = XCRemoteSwiftPackageReference;
+ repositoryURL = "https://github.com/apple/swift-numerics.git";
+ requirement = {
+ kind = upToNextMajorVersion;
+ minimumVersion = 1.0.0;
+ };
+ };
+/* End XCRemoteSwiftPackageReference section */
diff --git a/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj b/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
index 5928a9c..f0d9623 100644
--- a/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
+++ b/packages/common/test/fixtures/ios-and-android/ios/App/App.xcodeproj/project.pbxproj
@@ -28,6 +28,9 @@
507D3D05271DC2D000EEA707 /* My Share Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 507D3CFB271DC2D000EEA707 /* My Share Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };
+ 6457BCEED2DC47EDBF855E6E /* Numerics in Frameworks */ = {isa = PBXBuildFile; productRef = 483ED33D8EA44A62977EF3A4 /* Numerics */; };
+ CBB5D9DA80524BD886CE16B9 /* ComplexModule in Frameworks */ = {isa = PBXBuildFile; productRef = EFED82049B0144B7B4441595 /* ComplexModule */; };
+ 487C691400984C4C939C59A9 /* RealModule in Frameworks */ = {isa = PBXBuildFile; productRef = 0933A1A614C64F4884E6F617 /* RealModule */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -127,6 +130,9 @@
buildActionMask = 2147483647;
files = (
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */,
+ 6457BCEED2DC47EDBF855E6E /* Numerics in Frameworks */,
+ CBB5D9DA80524BD886CE16B9 /* ComplexModule in Frameworks */,
+ 487C691400984C4C939C59A9 /* RealModule in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -287,6 +293,11 @@
productName = App;
productReference = 504EC3041FED79650016851F /* Awesome App.app */;
productType = "com.apple.product-type.application";
+ packageProductDependencies = (
+ 483ED33D8EA44A62977EF3A4 /* Numerics */,
+ EFED82049B0144B7B4441595 /* ComplexModule */,
+ 0933A1A614C64F4884E6F617 /* RealModule */,
+ );
};
507D3CC1271DC20100EEA707 /* My App Clip */ = {
isa = PBXNativeTarget;
@@ -411,6 +422,10 @@
507D3CE1271DC20300EEA707 /* My App ClipUITests */,
507D3CFA271DC2D000EEA707 /* My Share Extension */,
);
+ packageReferences = (
+ EBF7078813744D8DB3856886 /* XCRemoteSwiftPackageReference "swift-numerics" */,
+ E4715DA7E0374B379A8EE091 /* XCLocalSwiftPackageReference "../path/to/local-swift-numerics" */,
+ );
};
/* End PBXProject section */
@@ -1065,6 +1080,42 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
+
+/* Begin XCRemoteSwiftPackageReference section */
+ EBF7078813744D8DB3856886 /* XCRemoteSwiftPackageReference "swift-numerics" */ = {
+ isa = XCRemoteSwiftPackageReference;
+ repositoryURL = "https://github.com/apple/swift-numerics.git";
+ requirement = {
+ kind = upToNextMajorVersion;
+ minimumVersion = 1.0.0;
+ };
+ };
+/* End XCRemoteSwiftPackageReference section */
+
+/* Begin XCSwiftPackageProductDependency section */
+ 483ED33D8EA44A62977EF3A4 /* Numerics */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = EBF7078813744D8DB3856886 /* XCRemoteSwiftPackageReference "swift-numerics" */;
+ productName = Numerics;
+ };
+ EFED82049B0144B7B4441595 /* ComplexModule */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = E4715DA7E0374B379A8EE091 /* XCLocalSwiftPackageReference "../path/to/local-swift-numerics" */;
+ productName = ComplexModule;
+ };
+ 0933A1A614C64F4884E6F617 /* RealModule */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = E4715DA7E0374B379A8EE091 /* XCLocalSwiftPackageReference "../path/to/local-swift-numerics" */;
+ productName = RealModule;
+ };
+/* End XCSwiftPackageProductDependency section */
+
+/* Begin XCLocalSwiftPackageReference section */
+ E4715DA7E0374B379A8EE091 /* XCLocalSwiftPackageReference "../path/to/local-swift-numerics" */ = {
+ isa = XCLocalSwiftPackageReference;
+ relativePath = "../path/to/local-swift-numerics";
+ };
+/* End XCLocalSwiftPackageReference section */
};
rootObject = 504EC2FC1FED79650016851F /* Project object */;
} |
I believe this is ready for review @mlynch. We haven't needed it yet, but perhaps in the future we could add a |
This is a stab at implementing iOS SwiftPackageManager (SPM) package support.
To properly support SPM packages - they need to be added to the
pbxproj
directly. The necessary additions were based on what XCode does when adding a new SPM package.Example diff after adding a package via XCode
I've decided to implement the details in a separate file to keep it fairly self-contained, however I'm happy to refactor if a different style is preferred.
Most changes required directly editing the pbx data structures, as these are not implemented/covered by the
xcode
package (https://github.com/apache/cordova-node-xcode). For example, SPM has a new type of BuildFile that uses aproducRef
. Some of these changes could alternatively be implemented in thexcode
package directly.Example usage:
Diff after running the above
General notes about using SPM packages:
xcodebuild
. For example:xcodebuild -resolvePackageDependencies
will download/resolve the newly added packages.xcodebuild -scheme
rather than-target
Additional features to consider:
ref #130