<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<!--
SFML - Simple and Fast Multimedia Library
Copyright (C) 2007-2024 Marco Antognini (antognini.marco@gmail.com),
                        Laurent Gomila (laurent@sfml-dev.org)

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented;
   you must not claim that you wrote the original software.
   If you use this software in a product, an acknowledgment
   in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such,
   and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.
-->

<!--
     This template can create a SFML Bundle Application project.
 -->

<plist version="1.0">
    <dict>
        <!--
             BASIC INFO
         -->
        <key>Identifier</key>
        <string>org.sfml-dev.app</string>

        <key>Concrete</key>
        <true />

        <key>Description</key>
        <string>This template creates a SFML Application Bundle.</string>

        <key>Kind</key>
        <string>Xcode.Xcode3.ProjectTemplateUnitKind</string>

        <key>Ancestors</key>
        <array>
            <string>org.sfml-dev.bundle</string>
            <string>org.sfml-dev.compiler</string>
            <string>org.sfml-dev.linker</string>
        </array>

        <!--
             FILES
         -->
        <key>Nodes</key>
        <array>
            <string>ResourcePath.mm</string>
            <string>ResourcePath.hpp</string>
            <string>main.cpp</string>
            <string>background.jpg</string>
            <string>doodle_pop.ogg</string>
            <string>tuffy.ttf</string>
            <string>icon.png</string>
        </array>

        <!--
             DEFINITIONS
         -->
        <key>Definitions</key>
        <dict>
            <!-- RESOURCE PATH -->
            <key>ResourcePath.mm</key>
            <dict>
                <key>Path</key>
                <string>ResourcePath.mm</string>
            </dict>
            <key>ResourcePath.hpp</key>
            <dict>
                <key>Path</key>
                <string>ResourcePath.hpp</string>
                <key>TargetIndices</key>
                <array /> <!-- don't copy it to "Resources" ! -->
            </dict>

            <!-- MAIN -->
            <key>main.cpp</key>
            <dict>
                <key>Path</key>
                <string>main.cpp</string>
            </dict>

            <!-- RESOURCES -->
            <key>background.jpg</key>
            <dict>
                <key>Path</key>
                <string>background.jpg</string>
                <key>Group</key>
                <string>Resources</string>
            </dict>

            <key>doodle_pop.ogg</key>
            <dict>
                <key>Path</key>
                <string>doodle_pop.ogg</string>
                <key>Group</key>
                <string>Resources</string>
            </dict>

            <key>tuffy.ttf</key>
            <dict>
                <key>Path</key>
                <string>tuffy.ttf</string>
                <key>Group</key>
                <string>Resources</string>
            </dict>

            <key>icon.png</key>
            <dict>
                <key>Path</key>
                <string>icon.png</string>
                <key>Group</key>
                <string>Resources</string>
            </dict>
        </dict>

        <!--
             COPY LIBRARY PHASE
         -->
        <key>Targets</key>
        <array>
            <dict>
                <key>BuildPhases</key>
                <array>
                    <dict>
                        <key>Class</key>
                        <string>ShellScript</string>

                        <key>ShellPath</key>
                        <string>/bin/sh</string>

                        <key>ShellScript</key>
                        <string># This shell script simply copies required SFML dylibs/frameworks into the application bundle frameworks folder.
# If you're using static libraries (which is not recommended) you should remove this script from your project.

# SETTINGS
SFML_DEPENDENCIES_INSTALL_PREFIX="@SFML_DEPENDENCIES_INSTALL_PREFIX@"
CMAKE_INSTALL_FRAMEWORK_PREFIX="@CMAKE_INSTALL_PREFIX@"
CMAKE_INSTALL_LIB_PREFIX="@CMAKE_INSTALL_PREFIX@/lib"
FRAMEWORKS_FULL_PATH="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/"

# Are we building a project that uses frameworks or dylibs?
case "$SFML_BINARY_TYPE" in
    DYLIBS)
        frameworks="false"
        ;;
    *)
        frameworks="true"
        ;;
esac

# Echoes to stderr
error () # $* message to display
{
    echo $* 1>&amp;2
    exit 2
}

assert () # $1 is a boolean, $2...N is an error message
{
    if [ $# -lt 2 ]
    then
        error "Internal error in assert: not enough args"
    fi

    if [ $1 -ne 0 ]
    then
        shift
        error "$*"
    fi
}

force_remove () # $@ is some paths
{
    test $# -ge 1
    assert $? "force_remove() requires at least one parameter"
    rm -fr $@
    assert $? "couldn't remove $@"
}

copy () # $1 is a source, $2 is a destination
{
    test $# -eq 2
    assert $? "copy() requires two parameters"
    ditto "$1" "$2"
    assert $? "couldn't copy $1 to $2"
}

require () # $1 is a SFML module like 'system' or 'audio'
{
    dest="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/"

    if [ -z "$1" ]
    then
        error "require() requires one parameter!"
    else
        # clean potentially old stuff
        force_remove "$dest/libsfml-$1"*
        force_remove "$dest/sfml-$1.framework"

        # copy SFML libraries
        if [ "$frameworks" = "true" ]
        then
            source="$CMAKE_INSTALL_FRAMEWORK_PREFIX/sfml-$1.framework"
            target="sfml-$1.framework"
        elif [ "$SFML_LINK_DYLIBS_SUFFIX" = "-d" ]
        then
            source="$CMAKE_INSTALL_LIB_PREFIX/libsfml-$1-d.dylib"
            target="`readlink $source`"
        else
            source="$CMAKE_INSTALL_LIB_PREFIX/libsfml-$1.dylib"
            target="`readlink $source`"
        fi

        copy "$source" "$dest/$target"

        # copy extra dependencies
        if [ "$1" = "audio" ]
        then
            # copy "FLAC" "ogg" "vorbis" "vorbisenc" "vorbisfile" frameworks too
            for f in "FLAC" "ogg" "vorbis" "vorbisenc" "vorbisfile"
            do
                copy "$SFML_DEPENDENCIES_INSTALL_PREFIX/$f.framework" "$dest/$f.framework"
            done
        elif [ "$1" = "graphics" ]
        then
            copy "$SFML_DEPENDENCIES_INSTALL_PREFIX/freetype.framework" "$dest/freetype.framework"
        fi
    fi
}

if [ -n "$SFML_SYSTEM" ]
then
    require "system"
fi

if [ -n "$SFML_AUDIO" ]
then
    require "audio"
fi

if [ -n "$SFML_NETWORK" ]
then
    require "network"
fi

if [ -n "$SFML_WINDOW" ]
then
    require "window"
fi

if [ -n "$SFML_GRAPHICS" ]
then
    require "graphics"
fi

                </string>

                        <key>RunOnlyForDeploymentPostprocessing</key>
                        <string>NO</string>
                    </dict>
                </array>
            </dict>
        </array>
    </dict>
</plist>
