For the header search path, it should be set to FRAMEWORK_DIRCTORY/SDL2.framework/Headers/
, or you can use FRAMEWORK_DIRCTORY/SDL2.framework
and turn on recursive
search.
Then you should be able to use it with just #include <SDL.h>
.
Edit:
After some investigation, seems like my original answer was more of a workaround. The proper way of including SDL library in your code should be using just #include <SDL2/SDL.h>
, however it wasn't working.
The reason of that is when compiling the code, Xcode would attempt to copy the library to the product folder, so the compiled executable can have easy access to it. However, for some reason, Xcode copied the framework without the header folder (the reason is probably that Xcode is moving towards using Swift only, which doesn't really have a "header" thing).
By default, when you try to run the code, and it sees there is a SDL2.framework
folder located in the product folder, it would use that framework, even if it doesn't have the header folder located in it. But since it doesn't actually have the header folder in it, it doesn't actually run.
To solve it, the easiest way is to remove it from the Targets/Build Phases/Embed Frameworks
.
By default when you add a framework to your project, it would also be added here. By removing it from the Embed Frameworks
, it won't copy the framework to product folder. And it will only attempt to search SDL framework from whatever you have put in the Build Settings/Framework Search Path
.
In the same time, you won't need to have anything for Build Settings/Header Search Path
, as it will look for Headers
folders in your frameworks first.
And with you code, you can just use #include <SDL2/SDL.h>
.
Even better, you can add the framework to Build Phases/Copy Files
, and set the Destination
to Frameworks
, empty the Subpath
, and potentially uncheck Copy only when installing
, for better cross device usabilities.