Adding Xcode SDL2 Library (C++) Tutorial

Writing Xcode for SDL2
I have prepared a tutorial article about Xcode SDL2. In this article, I will talk about how you can add and run the SDL2 framework in Xcode.
First we go to the SDL (Simple DirectMedia Layer) website to download SDL2.
We go to the download page by clicking on“SDL 2.0″ in the“Download” section in the lower left corner or“Get the current stable SDL version 2.0.3” in the upper right corner.
From here, we download the file to our computer by clicking the “SDL2-2.0.3.dmg (Intel 10.5+)” link from the“Development Binaries” section. Then we open the file by double-clicking it. After the file named SDL2 is displayed on our desktop in the /Volumes folder, we open it by double-clicking it.
The file named SDL2.framework in the folder:
“/ Applications/Xcode.app/Contents/ Developer/Platforms/ MacOSX.platform/Developer/ SDKs/MacOSX10.10.sdk/ System/Library/ Frameworks”
“~/Library/Frameworks”
paths.
Then we need to sign both files for the library to work. Otherwise the codes we wrote will not work. Click here for detailed information.
For Signing for Xcode SDL2, we open a terminal window and write the following codes:
1- sudo codesign -f -s – /Applications/Xcode.app /Contents/Developer/ Platforms/MacOSX.platform/ Developer/SDKs/ MacOSX10.10.sdk/System/ Library/Frameworks /SDL2.framework/SDL2
2- codesign -f -s – ~/Library/Frameworks/ SDL2.framework/SDL2
Now we can use the Xcode SDL2 library. You can write a test code and see if it works. To do this, start Xcode;
Creating an Xcode Project
We say“Create a new Xcode project“. Then, as in the picture, we select“Command Line Tool” by saying OSX>Application from the template options on the left side to select the type of the project and click next:
In the second step we select the name of the project and the author and the language to be used(C++).
Next, we choose where to save our project. You don’t need to create a folder for the project, Xcode itself will create a folder where your project files will be in with the project name you entered. After your project is ready, Xcode will open the“Build Settings” tab as below.
From here we click on the“Build Phases” tab to add SDL2.framework to our project.
In this tab, click on the small arrow next to“Link Binary With Libraries” to expand it. What we will do here is to link the library with the binary. For this, we open the following window by clicking on the(+) plus icon in the lower left corner.
We find the library named SDL2.framework, which we added as a framework in the first part of the article, from this list and click the“Add” button.
Now we can write a test code in the main.cpp file, as you can see in the window below, to internalize the library we write“#include <SDL2/SDL.h>“, that is, we write a foreslash after the name of the library and the name of the header we want to use.
To run the code you can press the play button in the top left corner or Product>Run or compile and build with the(⌘+R) key combination.