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

Support SPM resource bundles #223

Open
djbe opened this issue Oct 4, 2021 · 3 comments
Open

Support SPM resource bundles #223

djbe opened this issue Oct 4, 2021 · 3 comments

Comments

@djbe
Copy link

djbe commented Oct 4, 2021

As documented in the Mint readme, SPM now supports resource bundles (since 5.3).

With SwiftGen 6.5 we've switched over to fully using SPM for this, but apparently during installation Mint is getting rid of the resource bundles:

Tried it locally as well, and indeed the build folder only contains:

-rwxr-xr-x  1 davidjennes  admin   5.0M Oct  4 15:23 swiftgen

Where it should contain:

drwxr-xr-x  3 davidjennes  admin    96B Oct  4 15:15 SwiftGen_SwiftGenCLI.bundle
-rwxr-xr-x  1 davidjennes  admin   5.2M Oct  4 15:15 swiftgen

To make things a bit spicier, we don't control the name of the bundle, we just use Bundle.module in Swift code. And in this specific case, it is a resource bundle for a framework the binary depends on (called SwiftGenCLI). It is defined here in Package.swift.

@djbe
Copy link
Author

djbe commented Oct 6, 2021

Do note that for Homebrew, we had some trouble because they didn't like that we were installing the binary + the bundle in the bin folder. Apparently they have some validation for that. Not sure if Mint also wants to avoid polluting the bin path like that.

We couldn't just move the bundle somewhere else, the (relative) path to the bundle is hardcoded in the binary (and controlled by Apple/Swift). We ended up installing everything in libexec, and then creating a shim in bin. Initially we tried a symlink, but that doesn't work in all cases.

See these Homebrew PRs for the relevant discussions: Homebrew/homebrew-core#86408 and Homebrew/homebrew-core#86446.

@djbe
Copy link
Author

djbe commented Oct 6, 2021

As a temporary workaround, we re-added our Package.resources but this time pointing it to the generated bundle in the .build/ folder. Props to @tid-kijyun for the fix.

SwiftGen/SwiftGen#885

@tid-kijyun
Copy link

tid-kijyun commented Oct 9, 2021

I am working to resolve this issue at tid-kijyun/Mint.
It's already working in SwiftGen and my sample project, but I will do some more testing and create a PR.


SPM outputs a file named [package name]_[target name].bundle when resources is specified as a target in Package.swift. If resources is specified for multiple targets, multiple bundles will be output, so Mint needs to figure out the dependency graph and copy only what it needs.

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

No branches or pull requests

2 participants