Sometimes Unity iPhone build fails, then XCode launches the previously installed build. Can either be avoided?

When I build my app in Unity iPhone (1.5.1), it builds the XCode project, launches XCode (version 3.1.4). XCode compiles the app, sends it to the device, and runs it.

However, often the XCode build triggered by Unity fails outright with an error, something about there being no target selected. Two issues: 1) Instead of stopping, XCode goes ahead and runs the last build that I transferred to the device. If I'm not paying attention I might think that it's running the new build, not the old one. 2) When I click on Build & Go in XCode, the app builds with no errors, transfers to the device, and all is well.

I would like to avoid this phantom build error if possible. But it wouldn't be a big deal if XCode aborted instead of running the version of the app that's already installed on the device. So help with either of these issues would be appreciated.

I had similar problems prior to 1.5.1, are you doing Build and Run or going through Build Settings?

I have found that my problems occurred when using Build and Run, so to get around that I go through Build Settings and then override everything in the folder (or create a new folder each time).

Hope that helps!

==

I have found this to be the case every time. I tend to just clean my build from within Xcode before telling Unity iPhone to build. This seems to work all the time, though each time I do this, I get an error saying it doesn't have architecture build info or something for arm6, and yes I am building against the device ;) I just hit build form within Xcode at that point. More steps then I would like, but also something that I know that works.