Building a Universal Binary Version of Adventure Game Studio for Mac

23rd February 2023 | Games

I was in the process of updating a new Mac port of a game developed with Adventure Game Studio (AGS), and after going through the standard steps, I encountered a confusing error when trying to launch the game.

"MyGreatApp" can’t be opened because Apple cannot check it for malicious software. This software needs to be updated. Contact the developer for more information.

Odd, curious, and frustrating. Since this new build was using the more recent 3.5.1 version of AGS, I assumed that the Mac shell I've been using for 3.5 was causing this mysterious error. However, I did not have the appropriate shell app, so I would need to go and create it...and in the process finally tackle something I've been intending to do for the past year — make a universal binary which can support both Intel and Apple Silicon processors.

The following steps will create a Mac shell app for an AGS game, which I then use to populate using the AGS resources (cfg, vox, exe) from a Windows version of a game.

How to build an AGS Mac shell app:

  1. Pull the code from https://github.com/adventuregamestudio/ags. Switch to another branch if you need to build for a particular version of AGS. For this particular example, I switched to the branch release-3.5.1.
  2. Copy the build_ags.sh script into the ags folder. The script should be in the same folder which contains the CMakeLists.txt file. This will be important in a bit.
  3. Next is the step to ensure that this will build a universal binary so it runs natively on both Intel and Apple Silicon. Open the CMakeLists.txt file. At line 6 (or before the project() function), add the line: set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
  4. Ensure that the build_ags.sh script has proper permissions: chmod 755 build_ags.sh
  5. Run the script: ./build_ags.sh
  6. After a few minutes, this will create a new folder named build_release and will generate a shell Mac app named AGS.app.

Troubleshooting:

I encountered a couple of issues when trying to build the AGS shell on my newer Mac, which seemed to be missing some critical pieces which had been on my older Mac.

% ./build_ags.sh
./build_ags.sh: line 8: cmake: command not found
make: *** No targets specified and no makefile found.  Stop.

Looks like I was missing cmake on my new machine. To verify, I ran which cmake and it returned cmake not found. When I checked my old Mac, these are the details I had about cmake:

% which cmake
/usr/local/bin

% cmake --version
cmake version 3.18.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

That version of cmake had likely been installed by Xcode or manually installed some time in the distant past. On my new machine, I just used Homebrew to install it via the command: brew install cmake

To verify, I checked the new location and version of cmake.

% which cmake
/opt/homebrew/bin/cmake

% cmake --version
cmake version 3.25.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Much better. However, I also discovered that the xcode-select path was not pointing to the desired location of the current version of Xcode. Generally when running a utility like stapler, I will prefix the command with xcrun, which greatly helps in locating the associated utility. But in case of building the AGS project encountered a similar issue, it would be best to fix this by updating the xcode-select path.

% stapler
xcode-select: error: tool 'stapler' requires Xcode, but active developer directory 
'/Library/Developer/CommandLineTools' is a command line tools instance
% xcode-select -p
/Library/Developer/CommandLineTools
% sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 
% xcode-select -p                                                 
/Applications/Xcode.app/Contents/Developer

Despite some of the unexpected frustration I encountered creating this port, it did finally force my hand to build a new version of the Mac shell app, plus learn how to configure a Universal Binary for modern Macs, which surprisingly turned out to be quite simple.