Search code examples
cobjective-cxcodebuildapple-open-source

How to Successfully Build the Open Source Apple Chess Game in XCode


I am trying to download and run the source code of a previous version of the Apple macOS chess game (preferably in the 369-408 version range) using XCode 14.1.

The game is written in Objective-C and interfaces with a chess engine called "sjeng" that is written in C. (Correct me if I'm wrong).

I have already navigated some preliminary stumbling blocks (which you may want to follow to duplicate if you'd like to give this a try):

  1. Downloading the source code in the first place.

[ The next four steps come from here ]

  1. Commenting out the "#include..." line from the Chess.xcconfig file.

  2. Removing the com.apple.private.tcc.allow entitlement from the Chess.entitlements file.

  3. Getting my provisioning profile set up for the X-Code project (this is straight-forward as long as you already have a developer profile).

  4. Changing the bundle identifier from "com.apple..." to something random.

  5. Resolving "Implicit declaration of function is invalid in C99" compile-time errors related to the C code within the sjeng chess engine. This question helped with that.

But now I am stuck on the next and hopefully final step which is this is the build error:

./build-book normal nbook.pgn
+ test -z ''
+ SJENG=/Users/classified/Library/Developer/Xcode/DerivedData/MBChess-frynfmbcfskhcfdlqxxctvlldmnm/Build/Products/Development/sjeng.ChessEngine
+ cat
+ /Users/classified/Library/Developer/Xcode/DerivedData/MBChess-frynfmbcfskhcfdlqxxctvlldmnm/Build/Products/Development/sjeng.ChessEngine
./build-book: line 21: /Users/classified/Library/Developer/Xcode/DerivedData/MBChess-frynfmbcfskhcfdlqxxctvlldmnm/Build/Products/Development/sjeng.ChessEngine: No such file or directory
make: *** [nbook.db] Error 1
Command ExternalBuildToolExecution failed with a nonzero exit code

I have no clue what this stage of the build process pertains to.

I have verified in the Finder that the directory in the error message does indeed not exist.

I tried "Cleaning the Build Folder" in XCode and building again, but same result.

Can anyone get the game actually running (from source) on macOS and describe the steps required to get there?


Solution

  • Here is how it worked for me:

    1. Download the project from here (build tag 408);
    2. Unarchive the project and open MBChess.xcodeproj file with Xcode;
    3. Open MBChess target and do as follows:
      • Change Bundle Identifier to something more relevant to you
      • Enable "Automatically manage signing" flag
      • Choose your Apple Developer team OR choose any personal team
      • (Optional) If you chose a personal team, don't forget to remove incompatible entitlements from here (Game Center)

    enter image description here

    1. Remove Chess.xcconfig file from Project Navigator: enter image description here

    2. Find Chess.entitelements file and remove com.apple.private.tcc.allow array from it: enter image description here

    3. Select sjeng target and build it first enter image description here

    4. Select MBChess target and build it for the same platform enter image description here

    At this point the app should build successfully (I was using macOS Ventura 13.0.1 (22A400) as the target platform with Xcode Version 14.1 (14B47b))