Created
February 23, 2018 05:28
-
-
Save rheinardkorf/08fb7a7d619dbcb5dcf4dcdd18a79759 to your computer and use it in GitHub Desktop.
Makefile for building and bundling a Go app as MacOS Application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TITLE=My Title | |
BUNDLE_ID=com.rheinardkorf | |
PROJECT=MyApp | |
EXEC=app | |
VERSION=0.1 | |
define plist | |
<?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>CFBundleExecutable</key> | |
<string>$(EXEC)</string> | |
<key>CFBundleIdentifier</key> | |
<string>$(BUNDLE_ID).$(PROJECT)</string> | |
<key>CFBundleVersion</key> | |
<string>$(VERSION)</string> | |
<key>CFBundleDisplayName</key> | |
<string>$(TITLE)</string> | |
<key>LSRequiresIPhoneOS</key> | |
<string>false</string> | |
<key>NSHighResolutionCapable</key> | |
<string>Yes</string> | |
</dict> | |
</plist> | |
endef | |
export plist | |
default: | |
@echo "Building app..." | |
@go build -o $(EXEC) | |
@mkdir -p $(PROJECT).app/Contents/{MacOS,Frameworks} | |
@cp `otool -L $(EXEC) | awk '/\/usr\/local/ {print $$1,"$(PROJECT).app/Contents/Frameworks"}'` | |
@install_name_tool -change `otool -L $(EXEC) | awk '/\/usr\/local/ {print $$1; gsub(/^.*\//,"",$$1); print "@executable_path/../Frameworks/"$$1}'` $(EXEC) | |
@cp $(EXEC) $(PROJECT).app/Contents/MacOS | |
@rm $(EXEC) | |
@echo $$plist > $(PROJECT).app/Contents/Info.plist | |
@echo "All packaged up!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment