Xcode 6 Beta 无法编译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24310246/
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 05:06:48  来源:igfitidea点击:

Xcode 6 Beta not compiling

xcodeios7compilation

提问by Luca

I've got the following problem: I've written my first Swift App (for iOS7) and it worked fine. After changing some minor detail (adding a string somewhere) it wouldn't compile anymore, even if I changed everything back how it was before.

我遇到了以下问题:我编写了我的第一个 Swift 应用程序(适用于 iOS7)并且运行良好。在更改了一些小细节(在某处添加一个字符串)之后,它不会再编译了,即使我将所有内容都改回了以前的样子。

There is no error message or anything like it, it says that it's building the project (Compiling Swift Source Files) but it's not progressing at all, even after hours of "building".

没有错误消息或类似的东西,它说它正在构建项目(编译 Swift 源文件),但它根本没有进展,即使经过数小时的“构建”。

I've tried it with Xcode 6 b1 and b2 and with both it's the same: all the other projects are compiling without any problems, this one get's stuck.

我已经用 Xcode 6 b1 和 b2 试过了,两者都是一样的:所有其他项目都在编译没有任何问题,这个项目卡住了。

Does anyone have a clue what might be the problem and how to solve it?

有没有人知道可能是什么问题以及如何解决它?

回答by Zhenshan Yu

Debug the code manually works for me.

手动调试代码对我有用。

Finally I find the root cause of my problem is too many string concatenation in one line.

最后我发现我的问题的根本原因是一行中有太多的字符串连接。

Bug code:

错误代码:

var string = string1 + string2 + string3 + string4 + string5 + string6 + string7 + string8 

Fixed code:

固定代码:

var string = string1
string += string2
string += string3
string += string4
string += string5
string += string6
string += string7
string += string8

回答by vntstudy

Xcode 6 Beta sometimes does not show any error but there will be some errors in your code. Because of that it does not compile.

Xcode 6 Beta 有时不会显示任何错误,但您的代码中会出现一些错误。因此它不会编译。

Try to comment different parts of code and then try to compile. You have to find out the error manually.

尝试注释代码的不同部分,然后尝试编译。您必须手动找出错误。

I had this issue because I had some errors in my code but it was not showing.

我遇到这个问题是因为我的代码中有一些错误,但没有显示。

Debug it manually. All the best.

手动调试。祝一切顺利。

回答by Sam

Xcode 6 Beta 5 went into a tailspin for me immediately after I wrote out an expression to concatenate 3 strings and an NSDate object with the "+" operator.

在我写出一个用“+”运算符连接 3 个字符串和一个 NSDate 对象的表达式后,Xcode 6 Beta 5 立即陷入了混乱。

Wouldn't compile and got stuck indexing.

不会编译并陷入索引编制。

Search your code for long string concats and remove for now. This is clearly a bug.

在您的代码中搜索长字符串连接并暂时删除。这显然是一个错误。

回答by Anton

Several things you can try:

您可以尝试几件事:

  1. Clean the project: Product -> Clean
  2. Go to Product try other options such as Analyze or Profile, see if it still stuck on build.
  3. Restart xcode
  4. Reboot System
  5. Open system console and try to trace the problem.
  6. Last but most importantly, really, because they are beta version, there will be some unexpected bugs. If it still cannot be solved, please report it to Apple and expect it to be fixed in beta 3.

  7. Based on your comment, go to Terminal and type in: defaults write com.apple.dt.XCode IDEIndexDisable 1

  1. 清理项目:产品 -> 清理
  2. 转到产品尝试其他选项,例如分析或配置文件,看看它是否仍然停留在构建上。
  3. 重启xcode
  4. 重启系统
  5. 打开系统控制台并尝试跟踪问题。
  6. 最后但最重要的是,真的,因为它们是测试版,所以会有一些意想不到的错误。如果仍然无法解决,请向Apple报告,并期待在beta 3中修复。

  7. 根据您的评论,转到终端并输入: defaults write com.apple.dt.XCode IDEIndexDisable 1

回答by Mitsuaki Ishimoto

This bug will relate to our project state and source code. I rolled back some commits of my project, xcode succeeded indexing my project.

此错误将与我们的项目状态和源代码有关。我回滚了我的项目的一些提交,xcode 成功地索引了我的项目。

In my case, xcode failed to index, when my project has a declaration of large dictionary. (I succeed indexing after removing it.)

在我的例子中,当我的项目有一个大字典的声明时,xcode 未能建立索引。(删除它后我成功建立索引。)