I’ve been banging my head against getting this framework working cleanly since upgrading Xcode to 15.x. Three issues were recurring with horrible version-skew and many difficulties when upgrading to newer versions of SDL2. I have sanitized the installation which included one trick. Now I can upgrade to new versions of SDL2 without issue. The 3 issues were:
(1) I want to just replace older SDL2.framework to newer in /Library/Frameworks (as per instructions in distributed .dmg) without having to also install it in my project hierarchy.
(2) Runtime error - “can’t find the library (abort)” (or some similar verbiage)
(3) Cannot find #include <SDL2/SDL.h> at compile time
My sanitized solution (with the “trick”):
(1) After installing SDL2 in /Library/Frameworks (via Finder drag)… do these once only (not necessary every update)… drag SDL2.framework from /Library/Frameworks into the Xcode navigator area. Xcode will create a Frameworks group by default, if it’s not already there. In the “general” settings tab with the relevant “Target” selected, make sure the “Frameworks and Libraries” has an entry for the newly-dragged SDL2.framework with “Embed & Sign” pull-down selected.
(2) Once (1) is done (should only need to do this once and not every time SDL2 is updated), solve the runtime “Abort” issue by adding the SDL2.framework to the, now-available, “Embed Frameworks” “Build Phases” item by: make the triangle for this item point down, hit the newly available “+” in this newly opened section, hit “Add Other…”, Finder-drag SDL2.framework into the newly presented open dialog and hit the “Open” button. Now you should have SDL2.framework in the Embed Frameworks list. My “Code Sign On Co…” (whatever that means) is checked.
(3) Now the trick!!!
Without this silly trick, #include <SDL2/SDL.h> fails at compile time. (double-quote version fails too).
Logged in as an admin, in a terminal shell, do this:
cd /usr/local/include
(if you don’t have this directory; “mkdir -p /usr/local/include; cd /usr/local/include”)
ln -s /Library/Frameworks/SDL2.framework/Headers; mv Headers SDL2
Now in target settings, “Build Settings” tab, find “Header Search Paths” section and add “/usr/local/include” with “recursive” option selected (if it’s not already there). I didn’t need $(PROJECT_DIR) in this section but it should not matter if it’s there (providing you don’t have an additional SDL2.framework installed in your Project Directory (that’s the directory containing your .xcodeproj file)).
I used a symbolic link (-s) for the trick so that the link is not disrupted when you next upgrade your SDL2.framework.
Now, even when you do a Product->Clean Build Folder, the project should build and run without Xcode issues.
Conclusion: Too many moving parts! Thanks Apple for scattering options all over the place with very little helpful automation. I’m sure ChatGPT will mess it up just as easily when asked for help. I now have very few hairs left to pull out!
Additionally, if you’d like to perform “the trick” for SDL2_ttf.framework #include files, do:
cd /usr/local/include
ln -s /Library/Frameworks/SDL2_ttf.framework/Headers; mv Headers SDL2_ttf
in an admin terminal.