Problems building with Vulkan support for iOS

Hi there!

I’m having some trouble building SDL2 with Vulkan support for iOS (and I think macOS as well?). My current setup is as follows:

macOS Mojave
SIP disabled (i.e. DYLD_LIBRARY_PATH and such is available when using env)
VulkanSDK installed (brew cask install vulkan-sdk)
The following environment variables are set:

export VULKAN_SDK=/usr/local/Caskroom/vulkan-sdk/
export VK_ICD_FILENAMES=$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d

export CFLAGS="-I/usr/local/Caskroom/vulkan-sdk/"
export LDFLAGS="-L/usr/local/Caskroom/vulkan-sdk/"

I have tried a number of different variations with the above flags, but nothing seems to work. CMake itself has no problems finding Vulkan when using find_package(Vulkan).

I have tried building using both the script and the bundled Xcode project. I have also tried building (for macOS) using the CMake build system, and I can’t get it to recognize that I have the Vulkan SDK installed either (always VIDEO_VULKAN (Wanted: ON): OFF).

So I guess my question is, how are you supposed to build SDL2 with Vulkan support for iOS? I’ve tried everything I’ve found when searching around and reading the docs, and I’m starting to run of ideas here… I would really appreciate some help please. :slight_smile:

So a quick update, after a couple of hours of testing stuff I think I have found a workaround.

First of, I changed the following lines in SDL_config_iphoneos.h:



#error "Broken build, need Metal in order to support Vulkan"

This way I quickly get compile errors whenever SDL is built without Vulkan support. After this I tried changing various settings in the configure scripts when building with and various settings in the xcode project when building with SDL.xcodeproj.

The combination I finally got working was to build with the Xcode project (SDL.xcodeproj), with the following changes:

  • Change iOS Deployment Target to iOS 12.0
  • Change tvOS Deployment Target to tvOS 12.0
  • Build the libSDL-iOS target, the All-iOS target gave compile errors
  • Select Generic iOS Device as target platform

The output libSDL2.a ends up in a build folder in ~/Library/Developer/Xcode/DerivedData/, for me it was: ~/Library/Developer/Xcode/DerivedData/SDL-fxroinjqtfjbdnepvpfxwwxxeubu/Build/Products/Release-iphoneos.

I feel like what I have done here is kinda a huge hack, and it would still be nice with some clarification on how you are supposed to do this. :slight_smile: