Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App bundle for macOS #279

Open
shinra-electric opened this issue Nov 16, 2023 · 1 comment
Open

App bundle for macOS #279

shinra-electric opened this issue Nov 16, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@shinra-electric
Copy link

What feature do you want to get added? And how it will work?

This is kind of both a feature request and a bug report.

It would be great if the project provided an app bundle for macOS when releasing new versions.

But in the meantime, I was making my own bundle script. But I am having an issue where the game will launch when using terminal, but will not launch when double-clicking the app bundle. This issue usually means there is a problem with the Info.plist file, but I can't identify anything out of the ordinary.

For your reference, here is the script I wrote:

#!/usr/bin/env bash

# Requires dylibbundler
brew install dylibbundler

# Script for making an app bundle for the Legend of Zelda: A Link to the Past
# After building, just place this script into the zelda3 project folder and run it. 

# This just gets the location of the folder where the script is run from. 
# For ZSH it is simply SCRIPT_DIR=${0:a:h}
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"

# Create app bundle structure
rm -rf Link\ to\ the\ Past.app
mkdir -p Link\ to\ the\ Past.app/Contents/Resources
mkdir -p Link\ to\ the\ Past.app/Contents/MacOS

# create Info.plist
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>CFBundleGetInfoString</key>
  	<string>zelda3</string>
	<key>CFBundleExecutable</key>
	<string>zelda3</string>
	<key>CFBundleIconFile</key>
	<string>zelda3.icns</string>
	<key>CFBundleIdentifier</key>
	<string>com.nintendo.www</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>zelda3</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>LSMinimumSystemVersion</key>
	<string>11.0</string>
	<key>NSPrincipalClass</key>
	<string>NSApplication</string>
	<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSApplicationCategoryType</key>
	<string>public.app-category.games</string>
</dict>
</plist>
"
echo "${PLIST}" > "Link to the Past.app/Contents/Info.plist"

# Create PkgInfo
PKGINFO="-n APPLLINK"
echo "${PKGINFO}" > "Link to the Past.app/Contents/PkgInfo"

# Bundle resources. 
cp -R zelda3 zelda3_assets.dat saves zelda3.ini Link\ to\ the\ Past.app/Contents/MacOS/

# Create icon if there is a file called zelda1024.png in the build folder
# mkdir zelda3.iconset
# sips -z 16 16     zelda1024.png --out zelda3.iconset/icon_16x16.png
# sips -z 32 32     zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 32 32     zelda1024.png --out zelda3.iconset/icon_32x32.png
# sips -z 64 64     zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 128 128   zelda1024.png --out zelda3.iconset/icon_128x128.png
# sips -z 256 256   zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 256 256   zelda1024.png --out zelda3.iconset/icon_256x256.png
# sips -z 512 512   zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 512 512   zelda1024.png --out zelda3.iconset/icon_512x512.png
# cp zelda1024.png zelda3.iconset/[email protected]
# iconutil -c icns zelda3.iconset
# rm -R zelda3.iconset
# cp -R zelda3.icns Link\ to\ the\ Past.app/Contents/Resources/

# Otherwise get an icon from macosicons.com
curl -o Link\ to\ the\ Past.app/Contents/Resources/zelda3.icns https://parsefiles.back4app.com/JPaQcFfEEQ1ePBxbf6wvzkPMEqKYHhPYv8boI1Rc/3dfb87cfd67d8bd8da0f52d15212db98_The_Legend_of_Zelda___Link_s_Awakening_.icns

# Bundle libs & Codesign
dylibbundler -of -cd -b -x ./Link\ to\ the\ Past.app/Contents/MacOS/zelda3 -d ./Link\ to\ the\ Past.app/Contents/libs/

mv Link\ to\ the\ Past.app ..
@shinra-electric shinra-electric added the enhancement New feature or request label Nov 16, 2023
@shinra-electric
Copy link
Author

I created a workaround for this issue by creating a zsh script for launching the exe, which is run when opening the app bundle:

#!/usr/bin/env zsh

# Requires dylibbundler
# brew install dylibbundler

# Script for making an app bundle for the Legend of Zelda: A Link to the Past
# After building, just place this script into the zelda3 project folder and run it. 

# This just gets the location of the folder where the script is run from. 
SCRIPT_DIR=${0:a:h}
cd "$SCRIPT_DIR"

# Create app bundle structure
rm -rf Link\ to\ the\ Past.app
mkdir -p Link\ to\ the\ Past.app/Contents/Resources
mkdir -p Link\ to\ the\ Past.app/Contents/MacOS

# create Info.plist
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>CFBundleGetInfoString</key>
  	<string>zelda3</string>
	<key>CFBundleExecutable</key>
	<string>launch_zelda3.sh</string>
	<key>CFBundleIconFile</key>
	<string>zelda3.icns</string>
	<key>CFBundleIdentifier</key>
	<string>jp.co.nintendo.www</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>zelda3</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>0.3</string>
	<key>CFBundleVersion</key>
	<string>0.3</string>
	<key>LSMinimumSystemVersion</key>
	<string>11.0</string>
	<key>NSPrincipalClass</key>
	<string>NSApplication</string>
	<key>NSHighResolutionCapable</key>
	<true/>
	<key>LSApplicationCategoryType</key>
	<string>public.app-category.games</string>
</dict>
</plist>
"
echo "${PLIST}" > "Link to the Past.app/Contents/Info.plist"

# Create PkgInfo 
PKGINFO="-n APPLLINK"
echo "${PKGINFO}" > "Link to the Past.app/Contents/PkgInfo"

# Create launch script (Launching the executable directly doesn't work for some reason) and set executable permissions
LAUNCHER="#!/usr/bin/env zsh

SCRIPT_DIR=\${0:a:h}
cd "\$SCRIPT_DIR"

./zelda3"
echo "${LAUNCHER}" > "Link to the Past.app/Contents/MacOS/launch_zelda3.sh"
chmod +x "Link to the Past.app/Contents/MacOS/launch_zelda3.sh"

# Bundle resources. 
cp -R zelda3 zelda3_assets.dat saves zelda3.ini Link\ to\ the\ Past.app/Contents/MacOS/

# Create icon if there is a file called zelda1024.png in the build folder
# mkdir zelda3.iconset
# sips -z 16 16     zelda1024.png --out zelda3.iconset/icon_16x16.png
# sips -z 32 32     zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 32 32     zelda1024.png --out zelda3.iconset/icon_32x32.png
# sips -z 64 64     zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 128 128   zelda1024.png --out zelda3.iconset/icon_128x128.png
# sips -z 256 256   zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 256 256   zelda1024.png --out zelda3.iconset/icon_256x256.png
# sips -z 512 512   zelda1024.png --out zelda3.iconset/[email protected]
# sips -z 512 512   zelda1024.png --out zelda3.iconset/icon_512x512.png
# cp zelda1024.png zelda3.iconset/[email protected]
# iconutil -c icns zelda3.iconset
# rm -R zelda3.iconset
# cp -R zelda3.icns Link\ to\ the\ Past.app/Contents/Resources/

# Otherwise get an icon from macosicons.com
curl -o Link\ to\ the\ Past.app/Contents/Resources/zelda3.icns https://parsefiles.back4app.com/JPaQcFfEEQ1ePBxbf6wvzkPMEqKYHhPYv8boI1Rc/3dfb87cfd67d8bd8da0f52d15212db98_The_Legend_of_Zelda___Link_s_Awakening_.icns

# Bundle libs & Codesign
dylibbundler -of -cd -b -x ./Link\ to\ the\ Past.app/Contents/MacOS/zelda3 -d ./Link\ to\ the\ Past.app/Contents/libs/

codesign --force --deep --sign - Link\ to\ the\ Past.app

This works, but doesn't solve the core issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant