Embed AppIcon.png within binary (#30)

* Build product explicitly

Without it resources are not embedded in the executable

* Embed icon in code
This commit is contained in:
Fedor Korotkov 2022-04-22 03:29:52 -04:00 committed by GitHub
parent f07ffed6c8
commit 4a5efefbc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 10 deletions

View File

@ -5,8 +5,8 @@ task:
labels:
os: darwin
arch: arm64
build_script: swift build
sign_script: codesign --sign - --entitlements Sources/tart/tart.entitlements --force .build/debug/tart
build_script: swift build --product tart
sign_script: codesign --sign - --entitlements Resources/tart.entitlements --force .build/debug/tart
binary_artifacts:
path: .build/debug/tart

View File

@ -15,7 +15,7 @@ before:
after:
hooks:
- codesign --sign - --entitlements Sources/tart/tart.entitlements --force .build/arm64-apple-macosx/release/tart
- codesign --sign - --entitlements Resources/tart.entitlements --force .build/arm64-apple-macosx/release/tart
archives:
- id: binary

View File

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="sign debug" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="codesign --sign - --entitlements Sources/tart/tart.entitlements --force .build/debug/tart" />
<option name="SCRIPT_TEXT" value="codesign --sign - --entitlements Resources/tart.entitlements --force .build/debug/tart" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/sign.sh" />
<option name="SCRIPT_OPTIONS" value="" />
@ -14,4 +14,4 @@
<envs />
<method v="2" />
</configuration>
</component>
</component>

View File

@ -17,9 +17,6 @@ let package = Package(
.executableTarget(name: "tart",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
resources: [
.process("Resources/AppIcon.png")
]),
]
)

View File

@ -38,8 +38,7 @@ struct Run: AsyncParsableCommand {
nsApp.setActivationPolicy(.regular)
nsApp.activate(ignoringOtherApps: true)
let icon = Bundle.module.image(forResource: "AppIcon.png")
nsApp.applicationIconImage = icon
nsApp.applicationIconImage = NSImage(data: AppIconData)
struct MainApp: App {
var body: some Scene {

5
Sources/tart/Embed.swift Normal file

File diff suppressed because one or more lines are too long