Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving Interface Builder Changes when building in Xcode

Tags:

xcode

iphone

I know many of you have experienced the same the scenario, where you are banging your head against the wall wondering what is wrong with your app only to find that you have forgotten to save your Interface Builder changes.

Well, this never happens to me, because for some reason Xcode will prompt me to save any changes in Interface Builder whenever I build. A coworker and I are trying to figure out how to change this on his machine, with no success. I must have done something in the very early stages of my iphone development life to configure this.

Does anyone know how to link IB with Xcode so that it will prompt to save changes to IB files during a build?

like image 565
Tony Eichelberger Avatar asked Oct 12 '09 18:10

Tony Eichelberger


3 Answers

Someone else asked pretty much the same question (link from @balanon). The answer by irsk:

Bizarrely, it seems to be caused by opening your project using the File > Open Recent Project menu in Xcode, or by using the Recent Documents list in the Xcode welcome screen.

If I double-click the project file in the Finder to open it or choose the project from the Recent Items menu in the Apple menu, Xcode's connection to Interface Builder is intact.

Here's my original answer:

Do you both have the same version of Xcode? I note that since I moved to Snow Leopard and Xcode 3.2 the link between Xcode and Interface Builder is not as robust as it was with earlier versions. This seems fairly widespread -- I've seen quite a few complains on Twitter at least -- and so hope that Apple fix this.

like image 64
Stephen Darlington Avatar answered Sep 28 '22 03:09

Stephen Darlington


Are you perhaps running 32 bit while he is running 64 bit?

I seem to recall an issue with IB's AppleEvent-based communication with Xcode in 64 bit.

like image 37
Ken Avatar answered Sep 28 '22 02:09

Ken


This used to work flawlessly for me, too, but stopped working with Xcode 3.0. I'm sure there must be some hidden setting since it works for some, presumably those that had it activated in Xcode 2.x, however I haven't found it.

For those interested, I have a workaround that involves calling a simple AppleScript which saves all open IB documents. Here are the steps:

1) Create the Apple Script, something along these lines:

tell application "Interface Builder"
 set num to count of documents
 if num > 0 then
  repeat with i from 1 to num
   tell document i to save
  end repeat
 end if
end tell

2) Save it as Script (in my example /Users/myself/Programming/SaveIBFiles.scpt)

3) In your project, create a new Target. That is menu "Project" » "New Target...", there choose "Other" » "Shell Script Target". I named it "Save IB Files"

4) Expand the new target, it already contains a "Run Script" phase. Call up the info for this Run Script phase, "General" tab, leave Shell at /bin/sh and as Script write:

if [ -f "/Users/myself/Programming/SaveIBFiles.scpt" ]; then
 osascript "/Users/myself/Programming/SaveIBFiles.scpt"
fi

5) Now select your original target, call up its info, "General" tab, and add the new target as a direct dependency.

Now, whenever you build your app, the script gets called, saves your open IB files and then compiles your main target. Note that if you don't create a new target and merely add a "Run Script" build phase to your main target, the saving seems to occur too late.

Hope this helps!

like image 30
Pascal Avatar answered Sep 28 '22 03:09

Pascal