Xcode (using frameworks)

If you want to use dylibs instead of frameworks, then check out the Xcode dylib tutorial.

CMake

  • You will need to use CMake in order to build TGUI. You can download the latest version here.
  • In order to use CMake, you will need to install the Command Line Tools in Xcode.
    Go to Preferences > Downloads and click on the Install button next to the Command Line Tools.
    If you do not find it there then you should lookup how to download it for your XCode version.
  • Also make sure that you already have sfml on your computer. It would be even better to make sure you have sfml working before trying to use TGUI. If something goes wrong afterwards, you can be sure that the problem does not lie with sfml.
  1. Set the pathname to the TGUI folder that you downloaded.
  2. Set a folder to build TGUI in, usually a new empty folder in the same directory as (1).
  3. Press this button to start configuring.
CMake Build Directory

Next select your compiler.
Just keep the “Use default native compilers” option checked and ignore the other three options.

CMake Select Compiler

Watch out for which SFML version is found. If you are planning on using the SFML frameworks in your project, then don't let CMake find the SFML dylibs because your program will simply not work.

You can now change some of the options if you want. In order to build the framework, keep TGUI_SHARED_LIBS checked and check TGUI_BUILD_FRAMEWORK. After setting the options like you want them you need to press Configure again. Now you should have reached the message “Configuring done” at the bottom. All you have to do now is press Generate.

CMake Generate

Make

You are not done yet.
CMake made a Makefile in the build directory that will build the library.
Open the terminal, go to the directory were the Makefile is and type “make -j4”.
When this is done, type “sudo make install” and enter your password.

Using TGUI

In the previous step, the framework was installed to /Library/Frameworks by default. All you need to do to use it is dragging the TGUI framework into your project.

XCode drag framework

A screen like below will appear where you normally don't need to change anything, just hit "Finish". The "Copy items if needed" can remain unchecked, but it doesn't matter if it is checked.

XCode add framework

You should now be able to use TGUI.

Tip: The sfml example comes with a resourcePath() function which you must set before the paths to load resources. You can use tgui::setResourcePath(resourcePath()) at the beginning of your program so that everything tgui loads starts with that folder.