Xcode is a large app and when you install it from the Mac App Store, it tends to download a little slowly. Often users are tempted to install it via a torrent but that’s not a good idea as it might have been tampered with. To that end, do not use any other source other than the Mac App Store to download Xcode.
- Sep 11, 2021 Xcode needs to be compatible with macOS, and lower versions of Xcode cannot run on higher versions of macOS. How to get an old version of Xcode application from apple? Apple stores many release version of Xcode install file on their server, and we can access and download from the properly link.
- C Build Failed on Xcode OSX with multiple errors File IO. Is unavailable: introduced in macOS 10.15 Hot Network Questions Is this math font available in Latex?
Example
1. Install GLFW
First step is to create an OpenGL window. GLFW is an Open Source, multi-platform library for creating windows with OpenGL, to install GLFW first download its files from www.glfw.org
Extract the GLFW folder and its contents will look like this
Download and install CMake to build GLFW. Goto www.cmake.org/download/, download CMake and install for MAC OS X
Xcode Download Free Mac Os
If Xcode is not installed. Download and install Xcode from Mac App Store.
Create a new folder Build inside the GLFW folder
Open CMake, click on Browse Source button to select the GLFW folder (make sure that CMakeLists.txt) is located inside that folder. After that, click on Browse Build button and select the newly created Build folder in previous step.
Xcode Download Free
Now Click on Configure button and select Xcode as generator with Use default native compilers option, and click Done.
Tick on BUILD_SHARED_LIBS option and then click on Configure button again and finally click Generate button.
After generation CMake should look like this
Xcode Download Free
Now Open Finder and goto /usr, create a folder name local if not already there. Open the local folder and create two folders include and lib if not already there.
Now open the GLFW folder and goto Build (where CMake had built the files). Open GLFW.xcodeproj file in Xcode.
Select install > My Mac and then click on run (Play shaped button).
It is now successfully installed (ignore the warnings).
To make sure Open Finder and goto /usr/local/lib folder and three GLFW library files will be already present there (If not then open Build folder inside GLFW folder and go to src/Debug copy all files to /usr/local/lib)
Open Finder and goto /usr/local/include and a GLFW folder will be already present there with two header files inside it by name of glfw3.h and glfw3native.h
2. Install GLEW
GLEW is a cross-platform library that helps in querying and loading OpenGL extensions. It provides run-time mechanisms for determining which OpenGL extensions are supported on the target platform. It is only for modern OpenGL (OpenGL version 3.2 and greater which requires functions to be determined at runtime). To install first download its files from glew.sourceforge.net
Extract the GLFW folder and its contents will look like this.
Now open Terminal, navigate to GLEW Folder and type the following commands
Now GLEW is successfully installed. To make sure its installed, Open Finder, go to /usr/local/include and a GL folder will be already present there with three header files inside it by name of glew.h, glxew.h and wglew.h
Open Finder and go to /usr/local/lib and GLEW library files will be already present there
3. Test and Run
Now we have successfully installed GLFW and GLEW. Its time to code. Open Xcode and create a new Xcode project. Select Command Line Tool then proceed next and select C++ as language.
Xcode will create a new command line project.
Click on project name, and under Build Settings tab switch from Basic to All, under Search Paths section, add /usr/local/include in Header Search Paths and add /usr/local/lib in Library Search Paths
Click on project name, and under Build Phases tab and under Link With Binary Libraries add OpenGL.framework and also add recently created GLFW and GLEW libraries from /usr/local/lib
Now we are ready to code in Modern Open GL 4.1 on macOS using C++ and Xcode. The following code will create an OpenGL Window using GLFW with Blank Screen Output.