Package mxd as an app bundle
A loose binary can't have a name or icon, so permission lists, Login Items and Activity Monitor showed it bare. mxd.app fixes that, and the source stays one Swift file. mxd.icns is committed so Macs without Icon Composer can build. It's rendered from mxd.icon by ictool, because compiling the .icon into an Assets.car needs actool from full Xcode. The icon is therefore static, with no dark or tinted variants. make install replaces the manual steps. SIGN_ID selects the signing identity: ad-hoc by default, which ties grants to the build's hash. Assisted-by: Claude Sonnet 5.5 Signed-off-by: Yigit BALABAN <balaban@yigid.dev>
This commit is contained in:
1 parent
1a350197fc
commit
128db9fbb7
5 files changed
+104
No files matched your search
@@ -0,0 +1 @@
|
||||
build/
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?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>mxd</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>mxd</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>dev.yigid.mxd</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>mxd</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>mxd</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,50 @@
|
||||
SIGN_ID ?= -
|
||||
ICTOOL ?= /Applications/Icon Composer.app/Contents/Executables/ictool
|
||||
LABEL = dev.yigid.mxd
|
||||
BUILD_DIR = build
|
||||
BUNDLE = $(BUILD_DIR)/mxd.app
|
||||
ICONSET = $(BUILD_DIR)/mxd.iconset
|
||||
INSTALLED_BUNDLE = $(HOME)/Applications/mxd.app
|
||||
LAUNCH_AGENT = $(HOME)/Library/LaunchAgents/$(LABEL).plist
|
||||
|
||||
.PHONY: app icon install uninstall clean
|
||||
|
||||
app:
|
||||
mkdir -p $(BUILD_DIR)
|
||||
swiftc -O -swift-version 5 mxd.swift -o $(BUILD_DIR)/mxd
|
||||
rm -rf $(BUNDLE)
|
||||
mkdir -p $(BUNDLE)/Contents/MacOS $(BUNDLE)/Contents/Resources
|
||||
cp Info.plist $(BUNDLE)/Contents/Info.plist
|
||||
cp $(BUILD_DIR)/mxd $(BUNDLE)/Contents/MacOS/mxd
|
||||
cp mxd.icns $(BUNDLE)/Contents/Resources/mxd.icns
|
||||
codesign --force --sign "$(SIGN_ID)" --identifier $(LABEL) $(BUNDLE)
|
||||
|
||||
icon:
|
||||
rm -rf $(ICONSET)
|
||||
mkdir -p $(ICONSET)
|
||||
for base in 16 32 128 256 512; do \
|
||||
for scale in 1 2; do \
|
||||
canvas=$$((base * scale)); \
|
||||
tile=$$(( (canvas * 824 + 512) / 1024 )); \
|
||||
if [ $$scale -eq 1 ]; then name=icon_$${base}x$${base}.png; else name=icon_$${base}x$${base}@2x.png; fi; \
|
||||
"$(ICTOOL)" mxd.icon --export-image --output-file $(ICONSET)/$$name --platform macOS --rendition Default --width $$tile --height $$tile --scale 1 > /dev/null || exit 1; \
|
||||
sips --padToHeightWidth $$canvas $$canvas $(ICONSET)/$$name > /dev/null || exit 1; \
|
||||
done; \
|
||||
done
|
||||
iconutil --convert icns --output mxd.icns $(ICONSET)
|
||||
|
||||
install: app
|
||||
-launchctl bootout gui/$$(id -u)/$(LABEL)
|
||||
mkdir -p $(HOME)/Applications $(HOME)/Library/LaunchAgents $(HOME)/Library/Logs
|
||||
rm -rf $(INSTALLED_BUNDLE)
|
||||
ditto $(BUNDLE) $(INSTALLED_BUNDLE)
|
||||
sed "s|__HOME__|$(HOME)|g" $(LABEL).plist > $(LAUNCH_AGENT)
|
||||
launchctl bootstrap gui/$$(id -u) $(LAUNCH_AGENT)
|
||||
|
||||
uninstall:
|
||||
-launchctl bootout gui/$$(id -u)/$(LABEL)
|
||||
rm -rf $(INSTALLED_BUNDLE)
|
||||
rm -f $(LAUNCH_AGENT)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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>Label</key>
|
||||
<string>dev.yigid.mxd</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>__HOME__/Applications/mxd.app/Contents/MacOS/mxd</string>
|
||||
</array>
|
||||
<key>AssociatedBundleIdentifiers</key>
|
||||
<array>
|
||||
<string>dev.yigid.mxd</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>ProcessType</key>
|
||||
<string>Interactive</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>__HOME__/Library/Logs/mxd.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in new issue
Block a user