Bundling OSX app without GLUT and without Fmodex [nasty!]


#1

Ok, this is really really horrible, but it’ll make your app a lot lighter.
Tested in OF0.9.3

These instructions come in two parts, you must modify your OF install, and every project. If you forget to tweak a project both libs will be included, but not linked (you can delete them from the app bundle manually).

The weak is done in a way so that your xcode files will still work on an unmodified OF install.

So, here it goes:

Remove the setting FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/glut/lib/osx\"" (you can find it through xcode cmd+shift+f search)

Then, in CoreOF.xcconfig, redefine LIB_FMODEX and remove glut from OF_CORE_FRAMEWORKS:

// disable fmodex!
LIB_FMODEX = -Wl,-U,_FMOD_System_Close
REMOVED_DEPS = yes

OF_CORE_FRAMEWORKS = -framework Accelerate -framework AGL -framework AppKit -framework ApplicationServices -framework AudioToolbox -framework AVFoundation -framework Cocoa -framework CoreAudio -framework CoreFoundation -framework CoreMedia -framework CoreServices -framework CoreVideo -framework IOKit -framework OpenGL -framework QuartzCore -framework QuickTime -framework QTKit //-framework GLUT

Now go into the project config, build phases, run scripts, and wrap the glut and fmodex entries in an if:

if [ REMOVED_DEPS -ne "yes"]
then
    # Copy libfmod and change install directory for fmod to run
    rsync -aved ../../../libs/fmodex/lib/osx/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/";
    install_name_tool -change @executable_path/libfmodex.dylib @executable_path/../Frameworks/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";
    # Copy GLUT framework (must remove for AppStore submissions)
    rsync -aved ../../../libs/glut/lib/osx/GLUT.framework "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/"
fi

#2

Why does glut need to be removed for appstore submissions? I was relying on it due to a bug in glfw.


#3

google is your friend :slight_smile:

“The application bundle may not contain tools or frameworks provided by Apple, or using bundle identifiers in the ‘com.apple’ namespace. Invalid bundle: [AppName.app/Content/Frameworks/GLUT.framework], with bundle identifier ‘com.apple.glut’.”

p.s. i myself am not submitting to the appstore. i just want the binaries to be as light as possible.