Hello, I am new here and have spent the last 3 days trying to get SDL to integrate into Xcode 10.
I have followed 3 different tutorials (which were all geared to previous versions of Xcode) with no success. I can add the framework all I want but as soon as I try to “#include <SDL2/SDL.h>” in my project, I get an error that says the file doesn’t exist. Ive never been able to get past this and can’t start using the SDL.
Any help would be appreciated.
Did you install SDL2 as a framework or as a traditional Unix package? If you go into a terminal and type
sdl2-config --cflags what does it say?
As per the OS X FAQ,
When installed as a Framework, all SDL files (the library and the header files) are aggregated into a .framework bundle, and installed together into /Library/Frameworks/ or ~/Library/Frameworks/. There, Xcode can find it. But packages which want to use SDL but employ a Unix-style build system are usually not able to find SDL there (there are a few exceptions where people hand modified their configure scripts to allow using Frameworks on OS X, but those are rare).
When installing Unix-style, SDL gets installed into /usr/local/bin, /usr/local/include and /usr/local/lib (the exact path can vary, for example the Fink SDL package will use /sw instead of /usr/local by default). This way, build system tuned to support generic Unix systems are able to find them.
It says “command not found”.
The tutorials I followed only said to make a directory and put the framework in it, then link it via Xcode under project settings.
The ReadMe.txt file says this…
Copy the SDL2.framework to /Library/Frameworks
I am not experiencing any problems building my app with command line tools, despite it using the SDL2 frameworks.
/Library/Frameworks to your framework search path in Xcode.
something like Target -> Build Setting -> Search Path-> Framework Search Paths
Edit: Run the command
codesign -f -s - SDL2 after copying to the /Library/Frameworks directory before doing anything in Xcode.
I tried and got this…
“SDL2: bundle format unrecognized, invalid, or unsuitable”
I download the newest 2.0.9
Ok got it this time. That Terminal Command worked once I typed in the full path, including the “.framework”.
For anyone else needing this, I manually copied the SDL2.framework file into the Library/Framework folder (I had to create the Framework folder because I did not have one already there). Next, in Terminal, I navigate to the Library/Framework directory and entered the following terminal command…
codesign -f -s - SDL2.framework
It seemed to do something and then I simply started a new Xcode project->console application, C++, went to the project navigator->Build settings and added the framework to “Link Binaries with Libraries” using the plus button and finding the Library/Framework folder I had copied the SDL2.framework file to.
Now it works as advertised.
Thank you all for your help.