Xcode (using dylibs)

If you want to use frameworks instead of dylibs, then check out the Xcode framework 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 dylibs, then don't let CMake find the SFML Frameworks because your program will simply not work.

You can now change some of the options if you want. To build dylibs, keep TGUI_SHARED_LIBS checked and TGUI_BUILD_FRAMEWORK unchecked. 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

Go to the Build Settings.

XCode Build Settings

Under “Linking” in “Other Linker Flags”, add “-ltgui” or “-ltgui-d”.
If you don’t see the “Linking” section, then you might need to select “All” instead of “Basic”.

XCode Linker Flags

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.