-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I was playing with the package to see how can I use it to add local SwiftPM packages to my project.
The code is something like this:
const project = XcodeProject.open(xcodeProjectPath);
// React
const reactNativePackage = XCLocalSwiftPackageReference.create(project, {
relativePath: path.relative(appIosPath, reactNativePath),
});
const reactNativeProductDependency = XCSwiftPackageProductDependency.create(project, {
productName: 'React',
});I noticed some issues:
1. The uuids does not seems to be generated correctly
console.log(reactNativePackage.uuid)
// XX37FEFE0D07D0B50AB6ACXX
console.log(reactNativeProductDependency.uuid)
// XXD04A0B59BD7509D3A4FDXXThe XX at the beginning and end of the uuids are not Hex values, so they can't be correct
2. Elements are added to the project but they are not added to the PBXProject
The create method correctly adds the packages and the product dependencies into the objects array.
However, that's not enough to configure the project:
- the
PBXProjectneeds to be updated with an array ofpackageReferences- The package references are the uuids of the
XCLocalSwiftPackageReference
- The package references are the uuids of the
- the
PBXBuildFileneeds to have an entry for each package that needs to be built.- The
productRefhas to point to the XCSwiftPackageProductDependency - The buildfile id needs to be added to a
PBXFrameworksBuildPhase - The id of the
PBXFrameworkBuildPhaseabove needs to be added to a PBXNativeTarget'sbuildPhasesection - The native target needs to be part of the
PBXProjectfile
- The
How can we do this properly?
3. Removing old Swift Package References
I couldn't find a way to remove old package references. When reading the project, we might not know the ids in advance and we would have to iterate to the objects or filter them out somehow.
I saw the getObject method but it requires a uuid. There is no removeObject either.
Metadata
Metadata
Assignees
Labels
No labels