在Xcode中构建时保存Interface Builder更改 [英] Saving Interface Builder Changes when building in Xcode

查看:149
本文介绍了在Xcode中构建时保存Interface Builder更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你们中的许多人都遇到了同样的情况,你们正在敲打墙壁,想知道你的应用程序出了什么问题,却发现你忘了保存Interface Builder的更改。

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.

嗯,这从来没有发生在我身上,因为出于某种原因,Xcode会在我构建时提示我保存Interface Builder中的任何更改。一位同事和我正试图弄清楚如何在他的机器上改变这一点,但没有成功。我必须在iphone开发生命的早期阶段做一些事情来配置它。

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.

有没有人知道如何将IB与Xcode链接,以便在构建期间提示保存对IB文件的更改?

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

推荐答案

这对我来说也很完美,但是停止了使用Xcode 3.0。我确定必须有一些隐藏的设置,因为它适用于某些人,可能是那些在Xcode 2.x中激活它的人,但我还没有找到它。

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.

对于那些感兴趣的人,我有一个解决方法,涉及调用一个简单的AppleScript来保存所有开放的IB文档。以下是步骤:

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

1)按照以下方式创建Apple脚本:

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)将其保存为脚本(在我的示例中 / Users /myself/Programming/SaveIBFiles.scpt

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

3)在您的项目中,创建一个新目标。这是菜单Project»New Target ...,选择Other»Shell Script Target。我将其命名为保存IB文件

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)展开新目标,它已包含运行脚本阶段。调出此运行脚本阶段的信息,常规选项卡,将Shell保留在 / bin / sh ,并按脚本编写:

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)现在选择原来的目标,打电话将其信息添加到常规选项卡中,并将新目标添加为直接依赖项。

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

现在,无论何时构建应用程序,都会调用脚本,保存打开IB文件,然后编译您的主要目标。
请注意,如果您不创建新目标并仅向主目标添加运行脚本构建阶段,则保存似乎发生得太晚。

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.

希望这有帮助!

这篇关于在Xcode中构建时保存Interface Builder更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆