Improve macOS app integration (#746)

* Improve macOS app integration

Tart is now a proper application bundle, with the name and icon
declared in the Info.plist, which we were missing.

This also allows us to declare the app as LSBackgroundOnly
as a default, which means that 'tart create' and similar
background commands will not show the application icon in
the dock, while 'tart run' will, thanks to it overriding
the activation policy of the app.

For now the logic of creating the Tart.app bundle is duplicated
between the CI packaging scripts and the run-signed.sh script.
Now that these scripts are growing, it makes sense to look
at whether we can share the logic somehow, e.g. by building
the application bundle directly during build, and packaging
that, instead of creating it as a post install step.

* Integration tests: fix DockerContainer import

To work around the breaking change in 4.0.0,
see 383b12e9d6.

* .cirrus.yml(Release (Dry Run)): no need to install Sentry CLI

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
This commit is contained in:
Tor Arne Vestbø 2024-03-11 14:05:56 +01:00 committed by GitHub
parent 99bbd838a1
commit 0b693f6bc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 20 deletions

View File

@ -7,6 +7,8 @@ export VERSION="${CIRRUS_TAG:-0}"
mkdir -p .ci/pkg/
cp .build/arm64-apple-macosx/release/tart .ci/pkg/tart
cp Resources/embedded.provisionprofile .ci/pkg/embedded.provisionprofile
cp Resources/AppIcon.png .ci/pkg/AppIcon.png
cp Resources/Info.plist .ci/pkg/Info.plist
pkgbuild --root .ci/pkg/ --identifier com.github.cirruslabs.tart --version $VERSION \
--scripts .ci/pkg/scripts \
--install-location "/Library/Application Support/Tart" \

View File

@ -3,11 +3,13 @@
set -e
# fix structure
mkdir -p "$2/tart.app/Contents/MacOS"
mv "$2/tart" "$2/tart.app/Contents/MacOS/tart"
mv "$2/embedded.provisionprofile" "$2/tart.app/Contents/embedded.provisionprofile"
mkdir -p "$2/Tart.app/Contents/MacOS" "$2/Tart.app/Resources"
mv "$2/tart" "$2/Tart.app/Contents/MacOS/tart"
mv "$2/embedded.provisionprofile" "$2/Tart.app/Contents/embedded.provisionprofile"
mv "$2/AppIcon.png" "$2/Tart.app/Resources/AppIcon.png"
mv "$2/Info.plist" "$2/Tart.app/Contents/Info.plist"
echo "#!/bin/sh" > /usr/local/bin/tart
echo "exec '$2/tart.app/Contents/MacOS/tart' \"\$@\"" >> /usr/local/bin/tart
echo "exec '$2/Tart.app/Contents/MacOS/tart' \"\$@\"" >> /usr/local/bin/tart
chmod +x /usr/local/bin/tart

View File

@ -89,7 +89,6 @@ task:
install_script:
- brew install go goreleaser/tap/goreleaser-pro
- brew install mitchellh/gon/gon
- curl -sL https://sentry.io/get-cli/ | sh
info_script:
- security find-identity -v
- xcodebuild -version

18
Resources/Info.plist Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Tart</string>
<key>CFBundleIdentifier</key>
<string>org.cirruslabs.tart</string>
<key>CFBundleExecutable</key>
<string>tart</string>
<key>LSBackgroundOnly</key>
<string>1</string>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon.png</string>
</array>
</dict>
</plist>

View File

@ -349,9 +349,7 @@ struct Run: AsyncParsableCommand {
if noGraphics {
// enter the main even loop, without bringing up any UI,
// and just wait for the VM to exit.
let nsApp = NSApplication.shared
nsApp.setActivationPolicy(.prohibited)
nsApp.run()
NSApp.run()
} else {
runUI(suspendable, captureSystemKeys)
}
@ -529,8 +527,6 @@ struct Run: AsyncParsableCommand {
nsApp.setActivationPolicy(.regular)
nsApp.activate(ignoringOtherApps: true)
nsApp.applicationIconImage = NSImage(data: AppIconData)
struct MainApp: App {
static var disappearSignal: Int32 = SIGINT
static var capturesSystemKeys: Bool = false

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import requests
from testcontainers.core.waiting_utils import wait_container_is_ready
from testcontainers.general import DockerContainer
from testcontainers.core.container import DockerContainer
class DockerRegistry(DockerContainer):

View File

@ -8,8 +8,11 @@ set -e
swift build --product tart
codesign --sign - --entitlements Resources/tart-dev.entitlements --force .build/debug/tart
mkdir -p .build/tart.app/Contents/MacOS
cp -c .build/debug/tart .build/tart.app/Contents/MacOS/tart
cp -c Resources/embedded.provisionprofile .build/tart.app/Contents/embedded.provisionprofile
rm -Rf .build/Tart.app/
mkdir -p .build/Tart.app/Contents/MacOS .build/Tart.app/Contents/Resources
cp -c .build/debug/tart .build/Tart.app/Contents/MacOS/tart
cp -c Resources/embedded.provisionprofile .build/Tart.app/Contents/embedded.provisionprofile
cp -c Resources/Info.plist .build/Tart.app/Contents/Info.plist
cp -c Resources/AppIcon.png .build/Tart.app/Contents/Resources
.build/tart.app/Contents/MacOS/tart "$@"
.build/Tart.app/Contents/MacOS/tart "$@"