-
Notifications
You must be signed in to change notification settings - Fork 19
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
Comments
@dvkch Thank you for reporting this 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
|
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 |
I will try this problem again. |
This seems great ! Do you think there would be a way to detect if we are building Release vs Debug ? Maybe something like this instead ? But honestly even if the env doesn't match, it seems already really great to have let macCatalystPath = try context.tool(named: "spp").path.string
.replacingOccurrences(of: "/Debug/", with: "/Debug-maccatalyst/")
.replacingOccurrences(of: "/Release/", with: "/Release-maccatalyst/") |
@dvkch I forgot about release builds. And I realized that there is a problem with workaround. |
I don't think it is, but it might still exist from a previous Debug build? |
This is possible if you have not executed cleaning build folder. |
I am surprised you are closing this since the patch above #34 (comment) should work, although i didn't have the time yet to look in more details. It may be improved by detecting the build config (since it is possible to have more than just Debug and Release) and use a regex to fix the tool path properly, but this should already handle most situations |
I did take the time to look more into this and found what I think should be a sturdy fix, that worked on a clean build for me. By replacing the func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
fatalError(try! context.tool(named: "spp").url.absoluteString)
} I noticed that it returns I then added a script phase to my project to run env
exit 1 and inspected the resulting available vars. I confirmed that:
Since we know that func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
return [
makeBuildCommand(
executableURL: URL(fileURLWithPath: "/${TARGET_BUILD_DIR}/spp"),
sourcePackagesURL: try sourcePackages(context.pluginWorkDirectoryURL),
outputURL: context.pluginWorkDirectoryURL.appending(path: "LicenseList.swift")
)
]
} And i am happy to report that it works properly. the initial As an alternative I also though about replacing I hope this can be integrated in the project, and if you have any more question I'd be more than happy to continue investigating this a bit more. |
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
:Indeed,
spp
exists but in theRelease-maccatalyst
folder, notRelease
.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
This is...suboptimal, but at least lets the project archive for catalyst properly
The text was updated successfully, but these errors were encountered: