I’m doing a Unity-iPhone project, but want to automatically add some native code and relative frameworks and libraries to the XCode 4 project when I get it from Unity. What I know is the basic usage of the script to post-process building in Unity, and some basic knowledge about AppleScript.
Now comes the problem. There are plenty of web pages on the internet (including StackOverflow) about this topic, basic steps of which includes:
- Get the path of the file / framework / lib you want to add to the XCode project.
- Tell XCode and its inner objects to do some preparing work.
- Create file references for what you want to add, and add them to the right phases.
But in the last step, difficulty comes. I follow something like
add myFileRef to compile sources phase of target 1 of project 1
and
add myFrameworkRef to link binary with libraries phase of target 1 of project 1
to really add the files, but when the script is run, these steps just throw errors like
blahblahblah doesn't understand the add message
which drives me mad. According to my searching results, this kind of things work for XCode 3 (but break in XCode 4), so could anyone here please share his/her knowledge about what I’m likely to miss in the AppleScript listed above? or is there any good alternatives to do such things programmatically?
Up till now, I’ve found no way of doing it with AppleScript. So, my only shot is to directly modify the Xcode project file to add what I want to add.