xcode 故事板不会在模拟器中更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14648871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:41:32  来源:igfitidea点击:

Storyboard won't update in simulator

iosxcodestoryboardios-simulator

提问by user1892540

I have a working app in Xcode, however when I try to build and run it the simulator displays an older version of the storyboard I was working on. I had changed some of the design on the storyboard but this does not reflect in the simulator, nothing is updated.

我有一个可以运行的应用程序Xcode,但是当我尝试构建和运行它时,模拟器显示我正在处理的故事板的旧版本。我改变了故事板上的一些设计,但这并没有反映在模拟器中,没有任何更新。

Does anyone have any ideas?

有没有人有任何想法?

回答by T0m_Twt

  1. Delete the App on the simulator.

  2. Clean

  3. List item

  4. Build & Run

  1. 删除模拟器上的App。

  2. 干净的

  3. 项目清单

  4. 构建和运行

Use NSLog(@"")in your controller to check code execution.

NSLog(@"")在您的控制器中使用以检查代码执行情况。

回答by Brenden

I just spent at least 6 hours on this. I have a solution, but I also submitted a technical support ticket to apple to try to get more info on the cause and proper solution.

我只花了至少 6 个小时在这上面。我有一个解决方案,但我也向 Apple 提交了技术支持票,以尝试获取有关原因和正确解决方案的更多信息。

Simply remove the references to your storyboard files and add them back in the same file group.

只需删除对故事板文件的引用,然后将它们重新添加到同一文件组中即可。

This seems to include the storyboard files back into the app bundle generated during build(which can be seen in the

这似乎将故事板文件重新包含在构建期间生成的应用程序包中(可以在

DerivedData/APPNAME/Build/Products/Debug-iphonesimultator/APPNAME.app 

From here I can see my changes reflected from the storyboards as expected.

从这里我可以看到我的更改按预期从故事板中反映出来。

PS - Are you using localization at all? I was.

PS - 你在使用本地化吗?我曾是。

回答by xaphod

I lost 2 hours to this.

我为此损失了2个小时。

Solution was braindead simple: delete app, turn OFFthe iPhone 5S (iOS 7.1.1), and turn it bavk on.

解决方案很简单:删除应用程序,关闭iPhone 5S (iOS 7.1.1),然后打开 bavk。

回答by wtorsi

When you turn on localization, xcode moves storyboard file in localization folder (ex. Base.lproj/name.storyboard). When you build and run project on simulator, xcode copy name.storyboard into "derivedData"/Base.lproj/name.storyboard, but previous, created before localization "derivedData"/name.storyboardstill exists. In this case simulator uses the file which can be found easier, i.e simulator uses old file "derivedData"/name.storyboardto operate.

当您打开本地化时,xcode 会在本地化文件夹(例如Base.lproj/name.storyboard)中移动故事板文件。当您在模拟器上构建和运行项目时,xcode 将 name.storyboard 复制到"derivedData"/Base.lproj/name.storyboard 中,但之前在本地化之前创建的"derivedData"/name.storyboard仍然存在。在这种情况下,模拟器使用更容易找到的文件,即模拟器使用旧文件“derivedData”/name.storyboard进行操作。

Solution:Just rename the storyboard file, in navigator and in targets/general.

解决方案:只需在导航器和目标/常规中重命名故事板文件即可。

回答by methodcalls

This error happened to me for the first time when I had multiple copies of a project on my computer. For whatever reason, the fact that there were multiple copies were making it look as if the storyboard had not been updated between copies and in some cases the code was not updated. I thought I had forgotten to throw the right copy on my flash drive before going home, but it turned out it's an XCode error.

当我的计算机上有一个项目的多个副本时,这个错误第一次发生在我身上。无论出于何种原因,存在多个副本的事实使它看起来好像在副本之间没有更新故事板,并且在某些情况下没有更新代码。我以为我在回家之前忘记将正确的副本扔到我的闪存驱动器上,但结果证明这是一个 XCode 错误。

Delete any multiple copies using the same name, restart XCode and open your most recent copy. Extremely bizarre, but I will probably use BitBucket or GitHub from now on instead of throwing it on a flash drive.

删除使用相同名称的任何多个副本,重新启动 XCode 并打开您最近的副本。非常奇怪,但从现在开始我可能会使用 BitBucket 或 GitHub,而不是将它扔到闪存驱动器上。

回答by SOOHEE SONG

Deleting

删除

~/Library/Developer/Xcode/derivedData/

〜/图书馆/开发人员/Xcode/衍生数据/

worked for me!

对我来说有效!

回答by D Sun

I just have the same problem after localizationMy solution is clicking Product, Clean build folder. Then it will be fine

本地化后我遇到了同样的问题我的解决方案是单击产品,清理构建文件夹。然后就好了

回答by Rob Glassey

I get this too when using localized storyboards - Runin Xcode just refuses to install the latest version of the compiled storyboard. I think it is something to do with the way Runcopies changed resources across to the device - it does it differently than other forms of on device app installation.

使用本地化的故事板时我也得到了这个 -在 Xcode 中运行只是拒绝安装最新版本的已编译故事板。我认为这与Run副本更改资源到设备的方式有关 - 它与其他形式的设备应用程序安装不同。

The quickest way to get past this without deleting the app and losing any datais to:

不删除应用程序和丢失任何数据的情况下解决此问题的最快方法是:

  • Generate an Archivebuild in Xcode
  • Export this for Adhocdeployment
  • Double-click on the generated IPAto add it to iTunes
  • From the device page in iTunes force an updateto that app
  • 在 Xcode 中生成存档版本
  • 导出此用于临时部署
  • 双击生成的IPA将其添加到 iTunes
  • 从 iTunes 中的设备页面强制更新该应用程序

In order for iTunes to see that you have a new version your app build numberwill need to be incremented (if you don't do that already), before generating the archive.

为了让 iTunes 看到您有一个新版本,在生成存档之前,您的应用程序内部版本号需要增加(如果您还没有这样做)。

I find this method means you don't have to delete an app off the device, you're just forcing it to install the entire install package rather than a diff which is what I think Runis doing.

我发现这种方法意味着你不必从设备上删除一个应用程序,你只是强迫它安装整个安装包而不是我认为Run正在做的差异。

I'm not sure what causes this, if it is a localized resources bug or what, but this is still a problem in Xcode 7 for me.

我不确定这是什么原因造成的,如果是本地化资源错误还是什么,但这对我来说仍然是 Xcode 7 中的一个问题。

回答by Ken

I found this same thing happened with Xcode 6.1.1 if I happened to have copied a project; the new project run in the simulator was actually still reflecting the old, originalproject.

如果我碰巧复制了一个项目,我发现 Xcode 6.1.1 也会发生同样的事情;在模拟器中运行的新项目实际上仍然反映了旧的原始项目。

In my case the problem was with how the default area was set up for derived data (essentially the location where the binary files go for a build). Mine was set to legacy and the simulator was using the wrong project, even after a clean. The solution was to go to Preferences->Locations, press Advanced, and change the location from Legacyto Unique.

就我而言,问题在于如何为派生数据设置默认区域(本质上是二进制文件用于构建的位置)。我的设置为旧版并且模拟器使用了错误的项目,即使在清理之后也是如此。解决方案是转到Preferences-> Locations,按Advanced,然后将位置从Legacy更改为Unique

回答by Yingpei Zeng

I find that removing and adding storyboard file back doesn't work in my case, also it has side effects like it will automatically add a main nib entry into App's plist file (which subsequently makes the App fails to launch in iPhone simulator).

我发现删除和添加故事板文件在我的情况下不起作用,它也有副作用,比如它会自动将一个主要的 nib 条目添加到应用程序的 plist 文件中(这随后导致应用程序无法在 iPhone 模拟器中启动)。

I don't want to try to delete the application from the simulator since I have many files under the Document directory of the App.

我不想尝试从模拟器中删除应用程序,因为我在应用程序的文档目录下有很多文件。

At last I find another way that works well: simply delete the "/Users/$username/Library/Application Support/iPhone Simulator/7.1/Applications/$app/$yourapp.app" file. The files under Documents directory are untouched.

最后我找到了另一种有效的方法:只需删除“/Users/$username/Library/Application Support/iPhone Simulator/7.1/Applications/$app/$yourapp.app”文件。Documents 目录下的文件未受影响。

(I have localized my storyboard as well.)

(我也本地化了我的故事板。)