Autmatically add the resources to the Apple Targets

Hello guys,

I have been annoyed recently by the fact that I have to add the resources manually to the Mac Xcode project, and iOS Xcode project (because the project file has to be updated to include the copy bundle resources stuff…). Luckily, I have stumbled upon some project that has a very interesting solution.

The idea is mainly based on the “Run Script” field in the Build Phases of the target. What you do is add a script that simply copies all the files it finds in a directory to the app bundle. The script that I have for now is:
@
find ~~L “${SRCROOT}/Resources” ~~type f notname “.*” | xargs tI {} cp {} “${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}”@

I haven’t optimized it for cocos2d-x, yet, but that should be fairly simple to pull off.

Hope this helps reduce the painful multiplatform development process a bit by taking your head off a few steps!

— Maz

I just joined the forum after experiencing this issue with cocos2d-x. It looks like resources are still hard-coded in the xcodeproject file. Since this post is pretty old, I was curious if there is a more up-to-date solution or if this is supposed to be working.

My current build/ide set up is CLion and using “cocos run -p mac” from the terminal (build fails in clion, will work on that issue next). Only the template project resources are showing up in the build output, so the app crashes when I try to load a non-existing resource.