Steps to set up:
- Install SDL2 with Homebrew:
brew install sdl2
- We need Swift 5 for this, so download a snapshot from Swift.org. Install the
.pkg
file. - Download Vulkan/MoltenVK from here and unzip to
$HOME/SDKs
. Example:$HOME/SDKs/vulkansdk-macos-1.1.92.1
- Set up variables in
~/.bash_profile
:
# use downloaded Swift 5 snapshot
export TOOLCHAINS="swift"
# vulkan configuration
export VULKAN_SDK="$HOME/SDKs/vulkansdk-macos-1.1.92.1/macOS" # make sure this matches the downloaded version
export VK_LAYER_PATH="$VULKAN_SDK/etc/vulkan/explicit_layer.d"
export VK_ICD_FILENAMES="$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json"
# pkg-config
export CUSTOM_PKG_CONFIG="$HOME/pkg-config"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$CUSTOM_PKG_CONFIG"
- After the changes above are in place (
source ~/.bash_profile
to be sure), createvulkan.pc
by running this:
mkdir -p $CUSTOM_PKG_CONFIG # make sure this exists
cat > $CUSTOM_PKG_CONFIG/vulkan.pc << EOF
prefix=$VULKAN_SDK
libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: vulkan
Description: Vulkan SDK
Version: 1.0.69
Libs: -L\${libdir} -lvulkan
Cflags: -I\${includedir}
EOF
# if you have a better way of doing this, let me know
ln -s $VULKAN_SDK/lib/libvulkan.1.dylib /usr/local/lib
ln -s $VULKAN_SDK/lib/libMoltenVK.dylib /usr/local/lib
- Confirm right Swift version by running
swift --version
. Should return something likeApple Swift version 5.0-dev
- Run
swift build
at the project's root folder