LicenseGenerator-iOS
LicenseGenerator-iOS copied to clipboard
Add support for Swift Package Manager
Should add support for SPM in addition to CocoaPods
Would be happy to see this happen!
You can just point directly at the path where SPM packages are downloaded:
./credits.py -s "$CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts" -o "$SRCROOT/Credits.plist"
But how to combine both? Cocoapods and SPM?
Update: Got it working by the changes from @colejd... Thanks for that!
@chrizstone How did you manage it to work? Can you share? thanks
@svoip Use my PR (#38), which lets you specify multiple paths as inputs. Then you can do something like this:
./credits.py -s "$SRCROOT, $CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts" -o "$SRCROOT/Credits.plist"
-
$SRCROOT
will let it find the license files for your pods -
$CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts
will let it find the license files in your Swift packages. It's basically a weird way to access the DerivedData folder since I don't know a better way and there doesn't appear to be a macro for it.
(sorry @chrizstone, tagged you by mistake)
Works great, thanks @colejd
Hey-- Thanks! I've got this working with SPM now.
This is probably difficult but in one of my SPM dependencies, in its Package.swift, I make use of conditional dependencies:
dependencies: [
"ServerShared",
// For new condition feature, see https://forums.swift.org/t/package-manager-conditional-target-dependencies/31306/26
.product(name: "Kitura", package: "Kitura", condition: .when(platforms: [.linux, .macOS])),
.product(name: "HeliumLogger", package: "HeliumLogger", condition: .when(platforms: [.linux, .macOS])),
.product(name: "Credentials", package: "Kitura-Credentials", condition: .when(platforms: [.linux, .macOS])),
],
however, at least with Xcode, it looks like all checkout are done first (i.e., to $CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts
), and then the conditional rules are applied. So while my iOS app doesn't actually use some of the packages, they show up in my Acknowledgements. Not a big deal. Just makes for an inflated Acknowledgements in my Settings for the app.
Cheers!
Yeah, this looks to be SPM's behavior so it'd need to be changed by the Swift team. You could evaluate the Package.swift using this repo's Python script somehow, then ignore the corresponding directories that don't match, but that does sound like a lot of work.
It looks like this path $CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts
doesn't work when archiving with Xcode. I get:
Showing All Messages
Error: Invalid source path: /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ArchiveIntermediates/Neebla/BuildProductsPath/Release-iphoneos/../../../SourcePackages/checkouts
Command PhaseScriptExecution failed with a nonzero exit code
A workaround is to put a conditional around it like:
if [ "${CONFIGURATION}" != "Release" ]; then
./credits.py -s "$SRCROOT, $CONFIGURATION_BUILD_DIR/../../../SourcePackages/checkouts" -o "$SRCROOT/Credits.plist"
fi
Seems a bit of a hack though. And if you really want to generate the credits on an archive, wouldn't be suitable.