A Basic Makefile for Compiling an SFML Project
This setup targets beginning programmers who use Xcode on MacOS.
Steps:
-
Download SFML from https://sfml-dev.org. There are two different downloads for the Mac, depending on your CPU. To find your CPU type, visit the Apple menu in the upper left corner of the display and choose "About This Mac". If the "Chip" is given as Apple M1, M2, or M3, then you have an ARM CPU (newer Macs). Otherwise you have an Intel CPU. Here are download links as of 2023-11-26. Choose the one for your "Chip".
- https://www.sfml-dev.org/files/SFML-2.6.1-macOS-clang-64-bit.tar.gz (Intel CPU Download)
- https://www.sfml-dev.org/files/SFML-2.6.1-macOS-clang-arm64.tar.gz (ARM CPU Download)
-
Extract the download to a place you can easily find. When I opened the download in Safari, it automatically extracts the file into my Downloads directory. You can move and/or rename the folder. Example: I placed the folder in my Home directory (Finder -> Go -> Home) and renamed it to SFML-2.6.1.
-
Create a Project in Xcode of type "External Build System".
You should see "/usr/bin/make" for the "Build Tool" as follows. (If you don't see this, likely this tutorial is out of date.)
- Add my main.cpp, Makefile, and sfml.xcconfig files to your project. Change the first line of Makefile to reflect where you extracted the SFML library. (If you placed it in your Home directory with name SFML-2.6.1 you do not have to make any changes.) Edit the part of the first line after "${HOME}/".
SFML_DIR=${HOME}/SFML-2.6.1
so if you extrracted the library into your Downloads folder and did not rename, you can try changing the first line to
SFML_DIR=${HOME}/Downloads/SFML-2.6.1-macOS-clang-64-bit
for Intel CPUs, or
SFML_DIR=${HOME}/Downloads/SFML-2.6.1-macOS-clang-arm64
for ARM CPUs.
- Try to build it. If building was successful, you should add the executable to your project's "scheme".


