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:
yigid committed 2026-10-31 00:09:23 +03:00
1 parent 1a350197fc
commit 128db9fbb7
5 files changed
+104

No files matched your search

+50
View File
@@ -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)