diff --git a/.gitignore b/.gitignore index 34aaa253..548c1d92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +build +dist debian/gridtracker debian/.debhelper debian/files diff --git a/macos/README.md b/macos/README.md new file mode 100644 index 00000000..e45fe7cb --- /dev/null +++ b/macos/README.md @@ -0,0 +1,34 @@ +# MacOS-specific notes and instructions + +# Development Environment + +Gridtracker uses [NW](nwjs.io) (formerly known as node-webkit) to run. +Install the correct version of NW.js from (nwjs.io)[https://nwjs.io/] for your operating system. + +To run the app, just call `macos/run.sh` from your local repository. + +The script will download a copy of the right version of NWJS to the `build/macos` directory and use it to +run GridTracker from the source files. + + + +# Building & Releasing + +To package a version of GridTracker for distribution, update the NWJS version in `macos/build.sh` as needed +and run `./macos/build.sh` from the top level of your local repository. + +The script will download a copy of NWJS and follow the steps described +[in the nwjs docs](https://nwjs.readthedocs.io/en/latest/For%20Users/Package%20and%20Distribute/) +to produce a `GridTracker.app` macOS application in the `dist` directory. + + + +# Troubleshooting + +### NWJS won't run GridTracker + +If you see the error `"The display compositor is frequently crashing"` it's most likely because of +[this known issue](https://github.com/nwjs/nw.js/issues/7253) that requires `package.js` to +have a `product_string` value of `nwjs`, or not be present. The `macos/run.sh` script takes care of +this for you, but if you want to run it in a different way, you'll have to manually edit `package.json` +and remember not to commit those changes upstream. diff --git a/macos/app.icns b/macos/app.icns new file mode 100644 index 00000000..a91f5a16 Binary files /dev/null and b/macos/app.icns differ diff --git a/macos/build.sh b/macos/build.sh new file mode 100755 index 00000000..69483878 --- /dev/null +++ b/macos/build.sh @@ -0,0 +1,33 @@ +NWJS_VERSION=0.49.0 + +if [ ! -e build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app ]; then + echo "Downloading NWJS $NWJS_VERSION" + mkdir -p build/macos + cd build/macos + curl -O https://dl.nwjs.io/v$NWJS_VERSION/nwjs-v$NWJS_VERSION-osx-x64.zip + unzip nwjs-v$NWJS_VERSION-osx-x64.zip + cd ../.. +fi + +mkdir -p dist +rm -rf dist/GridTracker.app +cp -r build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app build/macos/GridTracker.app + +mv build/macos/GridTracker.app/Contents/MacOS/nwjs build/macos/GridTracker.app/Contents/MacOS/GridTracker +cp -r package.nw build/macos/GridTracker.app/Contents/Resources/app.nw +cp -f macos/app.icns build/macos/GridTracker.app/Contents/Resources/app.icns +cp -f macos/app.icns build/macos/GridTracker.app/Contents/Resources/document.icns + +sed -i "" -e "s/nwjs<\/string>/GridTracker<\/string>/g" build/macos/GridTracker.app/Contents/Info.plist +sed -i "" -e "s/io\.nwjs\.nwjs<\/string>/org.gridtracker.GridTracker<\/string>/g" build/macos/GridTracker.app/Contents/Info.plist +sed -i "" -e "s/NWJS<\/string>/GridTracker<\/string>/g" build/macos/GridTracker.app/Contents/Info.plist + +sed -i "" -e "s/\"nwjs\"/\"GridTracker\"/g" build/macos/GridTracker.app/Contents/Resources/en.lproj/InfoPlist.strings + +sed -i "" -e s/\"product_string\"/\"ignore_product_string\"/g build/macos/GridTracker.app/Contents/Resources/app.nw/package.json + +mv build/macos/GridTracker.app dist + +echo "" +echo "GridTracker has been packaged for distribution and is available as 'dist/GridTracker.app'" +echo "" diff --git a/macos/run.sh b/macos/run.sh new file mode 100755 index 00000000..62c28900 --- /dev/null +++ b/macos/run.sh @@ -0,0 +1,16 @@ +NWJS_VERSION=0.49.0 + +if [ ! -e build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app ]; then + echo "Downloading NWJS $NWJS_VERSION" + mkdir -p build/macos + cd build/macos + curl -O https://dl.nwjs.io/v$NWJS_VERSION/nwjs-v$NWJS_VERSION-osx-x64.zip + unzip nwjs-v$NWJS_VERSION-osx-x64.zip + cd ../.. +fi + +sed -i "" -e s/\"product_string\"/\"ignore_product_string\"/g package.nw/package.json + +build/macos/nwjs-v$NWJS_VERSION-osx-x64/nwjs.app/Contents/MacOS/nwjs ./package.nw + +sed -i "" -e s/\"ignore_product_string\"/\"product_string\"/g package.nw/package.json