Skip to content
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

Add support for Swift Package Manager #16

Open
carloe opened this issue Nov 9, 2017 · 10 comments
Open

Add support for Swift Package Manager #16

carloe opened this issue Nov 9, 2017 · 10 comments

Comments

@carloe
Copy link
Owner

carloe commented Nov 9, 2017

Should add support for SPM in addition to CocoaPods

@Schaefers
Copy link

Would be happy to see this happen!

@colejd
Copy link
Contributor

colejd commented Sep 16, 2020

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"

@chrizstone
Copy link

chrizstone commented Oct 6, 2020

But how to combine both? Cocoapods and SPM?

Update: Got it working by the changes from @colejd... Thanks for that!

@svoip
Copy link

svoip commented Nov 5, 2020

@chrizstone How did you manage it to work? Can you share? thanks

@colejd
Copy link
Contributor

colejd commented Nov 5, 2020

@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)

@svoip
Copy link

svoip commented Nov 5, 2020

Works great, thanks @colejd

@crspybits
Copy link

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!

@colejd
Copy link
Contributor

colejd commented Jan 2, 2021

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.

@crspybits
Copy link

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.

@Maxismo
Copy link

Maxismo commented Aug 28, 2024

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.

I just ran into this and I found the workaround for archiving.

the path is 3 levels up from there,
$CONFIGURATION_BUILD_DIR/../../../../../../SourcePackages/checkouts is it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants