[DF]
[Dragonfly]

Dragonfly with Xcode

Home Engine Games Tutorial Docs Forum Book Notes

This is a setup guide for developing with (and developing) Dragonfly in Mac OS. This setup guide has been tested as of SFML version 2.3.1 and X Code version 5.1.1.

  1. Install Apple Xcode

    Most, if not all, versions should work. Be sure to install the "command line tools", selected from:

    Xcode → Preferences → Downloads → Components

    Link: https://developer.apple.com/xcode/downloads/

  2. Install SFML

    SFML is free to download and use from the SFML Web site. Download the Mac OS X version.

    Link: http://www.sfml-dev.org/download/sfml/2.3.1/

    Follow the instructions on using SFML with Xcode.

    Link: http://www.sfml-dev.org/tutorials/2.3/start-osx.php

    Briefly:

    1. Extract the downloaded file:
      SFML-2.3.1-osx-clang-universal.tar.gz
    2. Change permissions on the SFML Frameworks directory. Specifically, in a terminal window:
      chmod -R og+rx SFML-2.3.1-osx-clang-universal/Frameworks/*
    3. Copy the SFML frameworks in the Frameworks directory to the system directory. Specifically, in a terminal window:
      sudo cp -p SFML-2.3.1-osx-clang-universal/Frameworks/* /Library/Frameworks
    4. Copy the templates for use by Xcode. The template location depends upon the version of Xcode, but can be found by navigating through the Xcode application located in /Applications/Xcode. e.g., in Xcode 5.1.1, the directory is:
      /applications/Xcode/Contents/Developer/Library/Xcode/Templates/Project Templates
      Then, in a terminal window:
      sudo cp -p SFML-2.3.1-osx-clang-universal/Templates/SFML \
      "Contents/Developer/Library/Xcode/Templates/Project Templates/"
    5. The template build script may need to be patched (SFML developers indicated this would be fixed in SFML 2.3.1, but has not been verified). In a terminal window:
      curl -fsSl \
      https://gist.githubusercontent.com/mantognini/307d63352c136e47b34d/raw/996aa52d60c0e171a435d6b3802abaf1214d572c/template.patch | \
      patch '/Library/Developer/Xcode/Templates/SFML/SFML App.xctemplate/TemplateInfo.plist'
      The *orig, script may need be similarly patched.

  3. Create an SFML Application

    Launch XCode. Select "Create new Xcode Project" and then select "SFML" in the far left pane, and then choose "SFML App". Click "Next" and choose a name for the project (e.g., "game"). The other options can be left as-is.

    Build (hotkey ⌘-b) and run (hotkey ⌘-r) the default application. This should test a "hello, world" for SFML to be sure the above installation steps were done properly. This should pop open an SFML window with a background graphic and play some background music.

  4. Install Dragonfly

    Dragonfly is available via the Dragonfly Web page. The engine zip file contains pre-compiled binaries for Windows (Visual Studio), Linux, and Mac (Xcode).

    Link: http://dragonfly.wpi.edu/engine/index.html#download

    Installation is done by extracting the zip file. Note the location for the next step.

  5. Download and Configure Saucer Shoot, Game 0

    The first Saucer Shoot tutorial file is a basic "hello, world" for Dragonfly. Running it successfully will verify that the development environment is set up properly.

    Link: http://dragonfly.wpi.edu/tutorial/game0.zip

    Steps

    1. Delete main.cpp from the SFML project created in step #3 (i.e., "game").
    2. Extract the zip file and add all the header files (*.h) and class files (*.cpp) to the Xcode project.
    3. Select the Project on the left of the navigator sidebar. The project configuration should appear in the main editor panel.
      1. Set the include path to find the Dragonfly header files. To do this, navigate:
        Build Settings → Search Paths → User Header Search Paths
        Edit to include the path to the Dragonfly header files (e.g., ../dragonfly/include/).
      2. Set the linker path to find the Dragonfly engine. To do this, navigate:
        Build Settings → Search Paths → Library Search Paths
        Edit to include the path to the Dragonfly library (e.g., ../dragonfly/lib/).
      3. Select the Dragonfly engine to link with the game. To do this, navigate:
        Build Phases → Link Binary with Library
        '+' → Add Other
        Browse to select the Dragonfly library (e.g., ../dragonfly/lib/libdragonfly-mac64.a). Click "open".
      4. The XCode architecture default is i386 which will not link with the engine. So, change the architecture to Intel 64-bit. To do this, navigate:
        Build Settings → Architectures
        And select 64-bit Intel (x86_64).
    4. Copy the files df-font.ttf and df-config.txt to the "game" directory.
    5. Set the working directory to the "game" directory.
      Xcode → Preferences → Downloads → Components
      Product → Scheme → Edit Scheme
      Run → Working Directory → Use custom working directory
      Browse to the location of the "game" directory.

  6. Build and Run

    The above steps should allow:

    1. Build (hotkey ⌘-b). The result should report "Build succeeded".
    2. Run (hotkey ⌘-r). A window should appear, playing the Dragonfly splash animation, then closing.

Home Engine Games Tutorial Docs Forum Book Notes

Copyright ©2013-2017, Mark Claypool (claypool [at] cs.wpi.edu) and WPI. All rights reserved.
Copyright ©2015, Mark Claypool (claypool [at] cs.wpi.edu) and WPI. All rights reserved.