libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.18k stars 1.86k forks source link

Request for more information on using SDL2 with Xcode #10752

Open automaciej opened 2 months ago

automaciej commented 2 months ago

Hello,

I'm new to macOS development. I'm trying to use Xcode to compile a small program with SDL. I wrote it in Linux and I can compile it on macOS using a simple Makefile. I'm now working on getting it to build with Xcode.

I have a question regarding this line here:

https://github.com/libsdl-org/SDL/blob/090e30dbca3379a32097652a73ba77116e25a417/docs/README-macos.md?plain=1#L174

I'm guessing that the instructions refer to the SDL2-2.30.7.dmg file. When I download it an open it, I don't see the Xcode.tar.gz file there, only the SDL2.framework directory.

Instructions then say "To Install: Copy the SDL2.framework to /Library/Frameworks". I'm working as a regular user with regular user privileges. Trying to copy the directory naively into /Library/Frameworks fails with an error message that I don't have write permissions there.

mv: rename SDL2.framework to /Library/Frameworks/SDL2.framework: Permission denied

I moved the directory to /Library/Frameworks using sudo, but then it wasn't clear to me what I can do next. Instructions then say that I can simply open the project and build it, but when I try to open SDL2.framework with Xcode, I'm getting an error saying "Could not open file. (/Users/.../SDL2.framework)".

Looking for other sources I found this tutorial here: https://lazyfoo.net/tutorials/SDL/01_hello_SDL/mac/xcode/ -- but that also doesn't work. It seems like Xcode thinks that SDL2.framework is a file rather a directory.

Screenshot 2024-09-07 at 15 11 36

That's really strange, because it is a directory, I can see it, and I can cd into it and see the files and symlinks inside. I'll keep on trying, but there's something non-obvious here, could you elucidate what kind trap am I falling into?

slouken commented 2 months ago

This is a good question for SDL forums: https://discourse.libsdl.org/c/sdl-development/6

slouken commented 2 months ago

I'm also moving this to the 3.2 milestone so we can update the documentation with the answer to this.