From 84bf22e4274d59596d9f79948fd8deb6fca5bcfa Mon Sep 17 00:00:00 2001 From: Karmaz95 Date: Thu, 18 Jul 2024 20:12:42 +0200 Subject: [PATCH] Adding make_bundle.sh script for building a codeless app bundle --- App Bundle Extension/custom/make_bundle.sh | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 App Bundle Extension/custom/make_bundle.sh diff --git a/App Bundle Extension/custom/make_bundle.sh b/App Bundle Extension/custom/make_bundle.sh new file mode 100755 index 0000000..91092cd --- /dev/null +++ b/App Bundle Extension/custom/make_bundle.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +### --- CREATE APP ICON --- ### +# Create a red icon using Python +python3 -c "from PIL import Image; Image.new('RGB', (1024, 1024), 'red').save('red_icon.png')" + +# Prepare iconset directory +mkdir -p red_icon.iconset + +# Convert the red icon to all necessary sizes and place them in the iconset directory +sips -z 16 16 red_icon.png --out red_icon.iconset/icon_16x16.png +sips -z 32 32 red_icon.png --out red_icon.iconset/icon_16x16@2x.png +sips -z 32 32 red_icon.png --out red_icon.iconset/icon_32x32.png +sips -z 64 64 red_icon.png --out red_icon.iconset/icon_32x32@2x.png +sips -z 128 128 red_icon.png --out red_icon.iconset/icon_128x128.png +sips -z 256 256 red_icon.png --out red_icon.iconset/icon_128x128@2x.png +sips -z 256 256 red_icon.png --out red_icon.iconset/icon_256x256.png +sips -z 512 512 red_icon.png --out red_icon.iconset/icon_256x256@2x.png +sips -z 512 512 red_icon.png --out red_icon.iconset/icon_512x512.png +sips -z 1024 1024 red_icon.png --out red_icon.iconset/icon_512x512@2x.png + +# Convert iconset to icns +iconutil -c icns red_icon.iconset + +# Clean up temporary files +rm -r red_icon.iconset red_icon.png + +### --- MAKING BUNDLE --- ### +# Prepare a minimal bundle structure +mkdir -p bare_bone.app/Contents/MacOS + +# Create a simple script that opens Calculator +echo '#!/bin/bash\nopen -a Calculator' > bare_bone.app/Contents/MacOS/bare_bone + +# Add executable permissions to binary/script +chmod +x bare_bone.app/Contents/MacOS/bare_bone + +# Creating Info.plist +echo ' + + + + CFBundleExecutable + bare_bone_exe + +' > bare_bone.app/Contents/Info.plist + +# Renaming executable +mv bare_bone.app/Contents/MacOS/bare_bone bare_bone.app/Contents/MacOS/bare_bone_exe + +# Creating Resources directory +mkdir -p bare_bone.app/Contents/Resources + +# Move icon to Resources +mv red_icon.icns bare_bone.app/Contents/Resources/red_icon.icns + +# Update Info.plist to use new icon +plutil -insert CFBundleIconFile -string "red_icon" bare_bone.app/Contents/Info.plist + +# Creating Frameworks directory +mkdir -p bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/Resources + +# Create a script in the framework that opens Clock +echo '#!/bin/bash\nopen -a Clock' > bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/ClockOpen +chmod +x bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/ClockOpen + +# Create necessary symbolic links in the framework +ln -s A bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/Current +ln -s Versions/Current/ClockOpen bare_bone.app/Contents/Frameworks/ClockOpen.framework/ClockOpen +ln -s Versions/Current/Resources bare_bone.app/Contents/Frameworks/ClockOpen.framework/Resources + +# Creating Info.plist for Framework +echo ' + + + + CFBundleExecutable + ClockOpen + +' > bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/Resources/Info.plist + +# Modify the main executable to use the script from ClockOpen Framework +echo 'SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"' >> bare_bone.app/Contents/MacOS/bare_bone_exe +echo '"$SCRIPT_DIR/../Frameworks/ClockOpen.framework/ClockOpen"' >> bare_bone.app/Contents/MacOS/bare_bone_exe + +# Sign the application +codesign -f -s - --deep bare_bone.app \ No newline at end of file