tags:

views:

1022

answers:

9

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?

+1  A: 

Not sure but do you have the most recent versions of Apple's development environments installed? Mine was preset.

vinnybad
I am running Leopard and have installed 3.1.2 iphone dev environment with Xcode.
Tony Eichelberger
+1  A: 

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.

Stephen Darlington
That may be the case with snow leopard, but I was in an iPhone class last year and I was the only one in the class that had xcode and IB integration working. We were all on the same version of xcode and the same version of Leopard. The instructor did not know why mine was working and nobody else's was.
Tony Eichelberger
I'm on Snow Leopard with Xcode 3.2.2, and this solution didn't work for me. I tried using both the Apple menu and Finder.
Senseful
+1  A: 

Maybe the setting is not getting propagated properly through an install or upgrade. Have you tried toggling the "For Unsaved Files" setting on an off? (XCode -> Preferences -> Building)

blueberryfields
Tried that and it didn't seem to make a difference. thanks anyway.
Tony Eichelberger
+1  A: 

Prior to SnowLeopard, IB used to automatically save my changes when I built. Now I have to manually save or else it doesn't use my latest changes. In addition, IB does not maintain or update its "Open Recent" File menu (it's empty). Check with your buddy to see if he's on SnowLeopard with Xcode 3.2.

mahboudz
Yes, my coworker is on snow leopard and xcodd 3.2.
Tony Eichelberger
+1  A: 

I think it's related to xCode prefrences.

See "xCode" -> "Preferences" -> "Building" -> "For unsaved files" -> option

Pavel Yakimenko
Yes, this would be the obvious place to start, unfortunately, we both have that set to prompt to save before building. It problem lies in the Interface Builder integration somewhere.
Tony Eichelberger
+1  A: 

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!

Pascal
we will try this if no other solutions come up. Still have a few days left on the bounty so I want to see what other things come up. Thanks.
Tony Eichelberger
Yes, a "native" solution to this would indeed be nice.
Pascal
well, nothing native seemed to surface after trying all the suggestions, so I will give you the points for coming up with this.
Tony Eichelberger
Thanks. I hope it at least is a passable solution to your problem.
Pascal
+1  A: 

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.

Ken
+1  A: 

Try opening your xcode project from the finder window. After I upgraded to snow leopard the link between xcode and IB broke if the project is loaded from the Recent Files option.

This answer may be related Interface Builder and Xcode integration not working

I'm on Snow Leopard with Xcode 3.2.2, and this solution didn't work for me.
Senseful
A: 

Ready for the final added functions and it wouldn't save from interface builder. Opening from finder or apple icon worked. I then had the firsttime bugfree (my bugs) run. So, at least for now all is forgiven- apple. Thanks so much for posting the simple solution.(on Leopard still)

amanda more