Proper usage of EditorUserBuildSettings and BuildOptions

Hey all,

I’m trying to automate our build process here a little, and I’m not sure I truly understand the proper usage of EditorUserBuildSettings and BuildOptions. Here is a very basic implementation of what I am trying to achieve, hopefully it is enough to get my point across:

Note: it should be implied that for this example I am functioning under iOS build settings.

    EditorUserBuildSettings.appendProject = true; //if we're building iOS, insure we're always appending and not building fresh every time.
	BuildOptions customBuildOptions =  EditorUserBuildSettings.architectureFlags;
	BuildTarget customBuildTarget=EditorUserBuildSettings.activeBuildTarget;
	string savepath = EditorUtility.SaveFolderPanel("Build "+customBuildTarget,        EditorUserBuildSettings.GetBuildLocation(customBuildTarget), "");
	
	if(savepath.Length != 0)
	{
		string dir=System.IO.Path.GetDirectoryName(savepath); //get build directory
		string[] scenes=new string[EditorBuildSettings.scenes.Length];
	
		for(int i=0;i < EditorBuildSettings.scenes.Length; ++i)
		{
			scenes_=EditorBuildSettings.scenes*.path.ToString();*_

* }*

* //////*
* // Do some preprocess stuff right here*
* //////*

* EditorUserBuildSettings.SetBuildLocation(customBuildTarget,dir); //store new location for this type of build *
* BuildPipeline.BuildPlayer(scenes, savepath, BuildTarget.iPhone, customBuildOptions);*

* //////*
* // Do some posprocess stuff right here*
* //////*

* }*
My expectations are that the XCode project will be appended - however it does not seem like that is the case, it writes a fresh project to my specified directory every time I run the script.
I tried scouring the docs but, as with most of the Editor API, documentation is really non-existant and lacking any form of example.
Thanks in advance
==

for this particular script, I think you could add this line up top:

EditorUserBuildSettings.architectureFlags = EditorUserBuildSettings.architectureFlags | BuildOptions.AcceptExternalModificationsToPlayer;