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

Embed AppIcon.png within binary #30

Merged
merged 2 commits into from
Apr 22, 2022
Merged

Conversation

fkorotkov
Copy link
Contributor

@fkorotkov fkorotkov commented Apr 21, 2022

I got the following error when tried to install tart binary in /usr/local/bin/tart and ran tart run monterey-base:

$: tart run monterey-base
tart/resource_bundle_accessor.swift:11: Fatal error: could not load resource bundle: from /usr/local/bin/Tart_tart.bundle or /private/var/folders/7v/mm9qgx011bs6q4k8mmj_jrt40000gn/T/cirrus-build/.build/arm64-apple-macosx/debug/Tart_tart.bundle

It appeared that Swift Package Manager doesn't embed resources within a binary. I'm still a noob with swift so it was a discovery for me. Since we are planning to distribute Tart as a single binary via a Homebrew formula we need somhow embed the only icon we need within the binary.

I didn't find a better way then just embed the icon data as a base64 string. I've tried to implement a Plugin that can do such embedding during a build phase but seems the Swift Plugins are not yet mature to allow such functionality. So I decidede to implement this hack since we only have one icon to embed.

PS I've also put the tart.entitelements file outside of the source root since there was a warning:

'cirrus-build': warning: found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /private/var/folders/7v/mm9qgx011bs6q4k8mmj_jrt40000gn/T/cirrus-build/Sources/tart/tart.entitlements

Without it resources are not embedded in the executable
@fkorotkov fkorotkov requested a review from edigaryev April 21, 2022 15:26
@fkorotkov fkorotkov enabled auto-merge (squash) April 21, 2022 15:26
@fkorotkov fkorotkov disabled auto-merge April 21, 2022 15:31
@fkorotkov fkorotkov changed the title Build product explicitly Embed AppIcon.png within binary Apr 21, 2022
@edigaryev edigaryev merged commit 4a5efef into main Apr 22, 2022
@edigaryev edigaryev deleted the build-product-for-testing branch April 22, 2022 07:29
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

Successfully merging this pull request may close these issues.

2 participants