[SOLVED] Help w GOG Achievements On Mac

Started by TheVolumeRemote, Thu 27/06/2024 22:17:17

Previous topic - Next topic

TheVolumeRemote

(Large Edit, reorganizing and focusing on MacOS)

While I have the Windows build working in Galaxy Client, I can't get the Mac build to even connect with Galaxy at all, no overlay, no time-played tracking- nothing.

I suspect something is blocking my signature bc Galaxy says my build is from an unknown developer when I did sign, notarize and staple the app as well as sign the dylibs before hand. Oddly enough Galaxy also says A Golden Wake and Strangeland is also unverified.

Here's the entitlements.plist that Hob's Barrow uses and it works for them:
Code: ags
<?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>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
</dict>
</plist>

I'm trying different dylibs to the same result but from what the other AGS games on GOG are doing, like Hob's Barrow, I'm mostly using
Code: ags
libagsgalaxy.dylib
libGalaxy64.dylib
with libGalaxy64.dylib in both Resources and Contents. Sometimes I try libGalaxy.dylib which is newer, to no difference.

TheVolumeRemote

#1
Solved, thanks again to @edenwaith for help and support.

If you want to download this tutorial including how to compile your own Mac App Bundle and all needed files (except GOG API library for legal reasons) you can find step by step instructions for porting your AGS game to Mac and for preparing it for GOG Galaxy and Steam, with working Achievements, HERE

The key to getting your game to work on Galaxy with achievements and without triggering Mac's Gatekeeper security, is you actually want to do less, not more (than Steam). You don't want to Notarize or Staple, or even sign your App Bundle. Signing the .app bundle seals it, the issue being GOG injects auto-generated files into .app/contents/resources and if your .app bundle as a whole is signed, GOG will break the seal, leaving the .app "tampered with" which sets off Gatekeeper, which tells the user Mac won't launch the game and suggests they throw it away.

You do need to sign your dynamic library files (dylib) for the AGS2Client plug-in and the Galaxy API. It doesn't look like you need to sign your executable however this guide does sign it because it works signed/doesn't hurt.

1. Right click YourGame.app > show package contents > Contents > Resources

   - Rename game.ags to ac2game.dat

2. In your computers Home Directory (~/ ) place:

   - YourGame.app
   - prepare_app_bundle_GOG.sh
   - entitlements.plist
   - libagsgalaxy.dylib
   - libGalaxy64.dylib

3. Right click YourGame.app > Contents > MacOS

   - Drag your games executable (unless renamed it is called AGS) into your home directory ( ~/ )
   
4. Place a copy of libGalaxy64.dylib on your Desktop.

5. Open Terminal. Make helper script executable, Run:

chmod +x prepare_app_bundle_GOG.sh

6. Next run the helper script that will sign the dylibs and executable. Run:

./prepare_app_bundle_GOG.sh

7. Right click YourGame.app  > Contents > Resources
In a separate window open your home directory.
DRAG (do not copy) into Resources:

   - libagsgalaxy.dylib
   - libGalaxy64.dylib

8. Navigate to YourGame.app  > Contents > MacOS

   - From home directory, DRAG your executable into MacOS
   - From Desktop, DRAG libGalaxy64.dylib into MacOS

9. Let's check everything.

Run:
Code: ags
codesign -dv --verbose=4 ~/Your\ Game.app
You want to verify that you see:

Sealed Resources=none

This means your app bundle isn't sealed, so GOG can pace their generated hashdb and .info files in the app bundle without flagging Gatekeeper.

Next you can check your dylibs and make sure they are signed with your Developer ID.
Code: ags
codesign -dv --verbose=4 ~/Your\ Game.app/Contents/Resources/libagsgalaxy.dylib
codesign -dv --verbose=4 ~/Your\ Game.app/Contents/Resources/libGalaxy64.dylib
codesign -dv --verbose=4 ~/Your\ Game.app/Contents/MacOS/libGalaxy64.dylib
Each should return output that includes:

Authority=Developer ID Application: Your Name (XXXXXXXXXX)

10. Now your app bundle is ready to upload to GOG Build Creator.

You can make your own prepare_app_bundle_GOG.sh with this script:
Code: ags
#!/bin/bash

# Define paths
HOME_DIR=~
DESKTOP_DIR=~/Desktop
ENTITLEMENTS_PLIST=~/entitlements.plist
CERTIFICATE="Developer ID Application: Your Name (XXXXXXXXXX)"

# Paths for the files
EXECUTABLE_PATH="${HOME_DIR}/AGS"
LIBGALAXY64_PATH="${HOME_DIR}/libGalaxy64.dylib"
LIBAGSGALAXY_PATH="${HOME_DIR}/libagsgalaxy.dylib"
DESKTOP_LIBGALAXY64_PATH="${DESKTOP_DIR}/libGalaxy64.dylib"

# Code sign the executable and dylibs
echo "Signing the main executable..."
codesign --force --sign "$CERTIFICATE" --timestamp --entitlements "$ENTITLEMENTS_PLIST" "$EXECUTABLE_PATH"

echo "Signing the libGalaxy64.dylib in the home directory..."
codesign --force --sign "$CERTIFICATE" --timestamp --entitlements "$ENTITLEMENTS_PLIST" "$LIBGALAXY64_PATH"

echo "Signing the libagsgalaxy.dylib in the home directory..."
codesign --force --sign "$CERTIFICATE" --timestamp --entitlements "$ENTITLEMENTS_PLIST" "$LIBAGSGALAXY_PATH"

echo "Signing the libGalaxy64.dylib on the desktop..."
codesign --force --sign "$CERTIFICATE" --timestamp --entitlements "$ENTITLEMENTS_PLIST" "$DESKTOP_LIBGALAXY64_PATH"

echo "All files have been signed successfully."

And you can make the entitlements.plist with this:
Code: ags
<?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>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
</dict>
</plist>

It's been a wild few weeks getting everything to work on Galaxy and Steam with achievements. And by wild I mean largely terrible, with fleeting moments of glory.

Anyway I'm feeling fulfilled knowing there's some step-by-step instructions on the forums for this now, I really hope this helps people :)

SMF spam blocked by CleanTalk