Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Xcode to ALWAYS copy resources folder on build

OK, the situation is rather simple (though un-solvable...):

  • I have a folder-reference, in my Xcode project, mostly with HTML/JS/CSS resources, changing frequently, using an external editor
  • I want this particular folder re-copied to the app bundle, for every build, without having to clean the project (the project is HUGE so unnecessarily re-compiling is quite a waste of time)

I tried adding a custom Build Phase (run script), either by touching the folder, or by creating a dummy file in the resources folder and deleting it afterwards, but none of that worked.

Any ideas?

like image 887
Dr.Kameleon Avatar asked Sep 18 '14 09:09

Dr.Kameleon


2 Answers

What finally worked for me :

  • Create a "Run" Build Script phase, before Copy Bundle Resources
  • Set the script as follows:

    find "${SRCROOT}/path/to/resources/$1" -type f -print0 | xargs -0 touch
    
like image 157
Dr.Kameleon Avatar answered Oct 23 '22 20:10

Dr.Kameleon


I have tested that if you change the last modification date of a file to now, Xcode will build the newer file in the bundle.

New a new run script build phase with your script, the script must run before Copy Bundle Resources.

enter image description here

In the script, enumerate every resource file and use touch -m filename.

like image 43
KudoCC Avatar answered Oct 23 '22 21:10

KudoCC