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:
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
“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.
revisiting this a few years later i realize no modification to OFCore is needed, it can all be done in the project config.
so, new instructions:
grab OF_CORE_LIBS from CoreOf.xcconfig, paste it into Project.xcconfig and get rid of everything you don’t like. You can even add “-Wl,-s” to the end of OF_CORE_LIBS to strip unused symbols (be careful, this also strips debug symbols!)
Beautiful thanks for sharing. I myself was experiment with similar ideas.
Nice idea of overwriting things per project in Project.xcconfig
one suggestion is do that as a include, like app.xcconfig, so your changes will survive projectGenerator changes.
i think something along the lines of disabling certain large parts would be neat (e.g i often don’t use freetype, and sometimes not even freeimage) but… i think most people don’t care about a few megabytes plus/minus. also i realized suggesting “-Wl,-s” is a bad idea as general setting, because it strips debug symbols making debugging impossible.
Yes, I think the same.
In a fork I use to test some different stuff I even separated everything in different xcconfig files to be included (or not) separately