为什么git会反复添加和删除Storyboard <classes>部分?

eri*_*ert 19 git xcode ios uistoryboard

保存故事板并将更改提交给git时,整个<classes>部分将被删除或添加到源代码控制(git)的可能性很大.我在命令行上使用git,而不是XCode集成UI.

首先它看起来像这样:

+    <classes>
+        <class className="CPTGraphHostingView" superclassName="UIView">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/CPTGraphHostingView.h"/>
+        </class>
...
+    </classes>
Run Code Online (Sandbox Code Playgroud)

在下一次提交中它看起来像这样:

-    <classes>
-        <class className="CPTGraphHostingView" superclassName="UIView">
-            <source key="sourceIdentifier" type="project" relativePath="./Classes/CPTGraphHostingView.h"/>
-        </class>
...
-    </classes>
Run Code Online (Sandbox Code Playgroud)

为什么这样,更重要的是:我怎么能阻止它?

use*_*136 10

(这个答案是基于个人经验,而不是正式的)

xml文件中的classes部分.storyboard列出了项目中的所有视图控制器

  1. 当您在Interface Builder中选择UI元素时,允许Assistant Editor显示正确的源文件
  2. 允许Identity Inspector(右侧面板)显示Custom Class的选项.

我猜这个部分是一个缓存,当上面列出的两种用途都没有使用一段时间时,它就会退役.

事实上,这一部分首先出现意味着可以安全地忽略,因为它是在需要时自动生成的.如果您已经提交了它,并且随后在diff上显示为已删除,请打开Identity Inspector,下拉Custom Class下可用的类列表,然后再次查看整个部分是如何存在的.