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

Catalyst support #34

Open
dvkch opened this issue May 12, 2024 · 2 comments
Open

Catalyst support #34

dvkch opened this issue May 12, 2024 · 2 comments

Comments

@dvkch
Copy link

dvkch commented May 12, 2024

Hi there!

First of all thank you for this amazing and easy to setup library :)

I've been using it for a couple apps using SPM and it works perfectly. I've only encountered one issue: when archiving a catalyst target it fails when running spp:

 /bin/sh -c /Users/user/Library/Developer/Xcode/DerivedData/App-fuvpklgnlnmjljbizexrsmuamxxm/Build/Intermediates.noindex/LicenseList.build/Release-maccatalyst/LicenseList.build/Script-9591152079458176390.sh

sandbox-exec: execvp() of '//Users/user/Library/Developer/Xcode/DerivedData/App-fuvpklgnlnmjljbizexrsmuamxxm/Build/Products/Release/spp' failed: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

Indeed, spp exists but in the Release-maccatalyst folder, not Release.

For now I'm gonna do a simple symlink, but if you have any idea on how to fix this that would be amazing :)

EDIT:

it does look awfully similar to https://forums.swift.org/t/package-manager-executable-not-available-when-building-for-platforms-other-than-macos/56279/2, and the solution doesn't seem that simple to setup.

EDIT2:

Because the build folder always changes I had to be a bit creative. I created an aggregate build target, containing the following script, and added it as a dependecy for my main target

# Type a script or drag a script file from your workspace to insert its path.
SIMLINK_DIR=${BUILT_PRODUCTS_DIR/Release-maccatalyst/Release}
[ ! -d "$SIMLINK_DIR" ] && ln -s "$BUILT_PRODUCTS_DIR" "$SIMLINK_DIR"

This is...suboptimal, but at least lets the project archive for catalyst properly

@Kyome22
Copy link
Collaborator

Kyome22 commented May 20, 2024

@dvkch Thank you for reporting this issue.
I also reproduced the issue.

I found that it is possible to build using the workaround below, but it does not solve the fundamental problem.

@main
struct PrepareLicenseList: BuildToolPlugin {
    // ...

    // This command works with the plugin specified in `Package.swift`.
    func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
+       var executablePath = try context.tool(named: "spp").path
+           .removingLastComponent()
+           .removingLastComponent()
+           .appending(["Debug-maccatalyst", "spp"])
        return [
            makeBuildCommand(
+               executablePath: executablePath,
                sourcePackagesPath: try sourcePackages(context.pluginWorkDirectory),
                outputPath: context.pluginWorkDirectory
            )
        ]
    }
}

https://github.com/cybozu/LicenseList/blob/support-catalyst/Plugins/PrepareLicenseList/main.swift

#if targetEnvironment(macCatalyst) preprocessor also doesn't work. X(

@dvkch
Copy link
Author

dvkch commented May 23, 2024

Oh! I didn't know you could modify the build commands like this, that's good to know! But as you say, the underlying issue is still there

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