objective-c Xcode 6 Swift 代码完成不起作用

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

Xcode 6 Swift code completion not working

objective-cxcodeswift

提问by Mitchell Hudson

Using Xcode 6 GM seed my code completion has stopped working. It was working the other day. I was trying to get the unwind segue work around to work. I had made an Objc header file and assigned it as a header for a Swift class.

使用 Xcode 6 GM 种子我的代码完成已停止工作。前几天还在工作。我试图让 unwind segue 工作正常工作。我制作了一个 Objc 头文件并将其分配为 Swift 类的头文件。

At this point I get code completion with an Objective-c project. But, not with a Swift project.

在这一点上,我获得了一个 Objective-c 项目的代码完成。但是,不适用于 Swift 项目。

I have tried restarting Xcode, making a new empty project.

我尝试重新启动 Xcode,创建一个新的空项目。

回答by Ali Raza

Just go in user->Library->Developer->Xcode->DerivedDataand deletethe Data of folder(Derived data) and restartXcode.

只需进入user->Library->Developer->Xcode->DerivedData删除文件夹的数据(派生数据)并重新启动Xcode。

回答by Anuj

This fix from apple dev forums works for me. I have had autocomplete issues with Xcode 6.1/Yosemite.

来自苹果开发论坛的这个修复对我有用。我在 Xcode 6.1/Yosemite 上遇到了自动完成问题。

  1. Quit Xcode.
  2. Restart the computer (this is to clear any in-memory caches).
  3. Delete the contents of the DerivedData folder (~/Library/Developer/Xcode/DerivedData), precisely run, a) cd ~/Library/Developer/Xcode/DerivedData/
    b) rm -rf *
  1. 退出 Xcode。
  2. 重新启动计算机(这是为了清除所有内存缓存)。
  3. 删除DerivedData文件夹(~/Library/Developer/Xcode/DerivedData)的内容,精确运行,a) cd ~/Library/Developer/Xcode/DerivedData/
    b) rm -rf *


  1. (Try this if Steps 1-3 dont really work as it rebuilds the cache later on restart which takes time) Delete the contents of folder ~/Library/Caches/com.apple.dt.Xcode, i.e.,
    a) cd ~/Library/Caches/com.apple.dt.Xcode
    b) rm -rf *
  1. (如果步骤 1-3 不起作用,请尝试此操作,因为它稍后会在重新启动时重建缓存,这需要时间)删除文件夹 ~/Library/Caches/com.apple.dt.Xcode 的内容,即
    a) cd ~/Library /Caches/com.apple.dt.Xcode
    b) rm -rf *

Now launch Xcode once more…

现在再次启动 Xcode…

回答by NSBob

I experienced a serious breakdown of code completion because I had some 'notes' after the @end statement of my .m file which were as follows:

我遇到了严重的代码完成故障,因为我在 .m 文件的 @end 语句之后有一些“注释”,如下所示:

/*
 NSAlertFirstButtonReturn, NSAlertSecondButtonReturn, NSAlertThirdButtonReturn
 */

These lines can appear before the @end statement without destroying code completion.

这些行可以出现在@end 语句之前,而不会破坏代码完成。

回答by Oren

There's an easier way to delete the Derived Data from within Xcode (no need to open finder or restart):

有一种更简单的方法可以从 Xcode 中删除派生数据(无需打开 finder 或重新启动):

Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data

Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data

回答by Ronaldoh1

I just recently had this problem. Autocomplete did not work ...and when i typed for example tableView.... it did not give me the different functions available.

我最近刚遇到这个问题。自动完成不起作用……当我输入例如 tableView 时……它没有给我可用的不同功能。

I tried the following and it worked for me.

我尝试了以下方法,它对我有用。

  1. Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data

  2. delete the file ~/Library/Developer/Xcode/DerivedData/ModuleCache

  3. Restart xcode

  1. Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data

  2. 删除文件 ~/Library/Developer/Xcode/DerivedData/ModuleCache

  3. 重启xcode

Hope this works

希望这有效

回答by Donn

Another possible reason why it isn't working is because it's not part of the target membership. To fix this, select the file you're working on. Then, go to the File Inspector and in the Target Membership section, make sure your project is checked.

它不起作用的另一个可能原因是它不是目标成员的一部分。要解决此问题,请选择您正在处理的文件。然后,转到 File Inspector 并在 Target Membership 部分中,确保选中您的项目。

Target Membership

目标会员

回答by Timm Kent

Try the following - as silly as it may sound: Change Device to iPhone 6, close Xcode, Reopen Xcode and wait for the indexing to finish.

尝试以下操作 - 尽管听起来很愚蠢:将设备更改为 iPhone 6,关闭 Xcode,重新打开 Xcode 并等待索引完成。

回答by spaceMonkey

I had the same issue but under different circumstances, I have 2 projects in my workspace

我遇到了同样的问题,但在不同的情况下,我的工作区中有 2 个项目

  1. Swift framework for iOS and OSX
  2. iOS Project (which uses the swift framework)
  1. 适用于 iOS 和 OSX 的 Swift 框架
  2. iOS 项目(使用 swift 框架)

My code completion works fine in iOS but it keeps failing in the swift framework. I tried all the about solution and had no luck and was killing my productivity.

我的代码完成在 iOS 中运行良好,但在 swift 框架中一直失败。我尝试了所有关于解决方案但没有运气并且正在扼杀我的生产力。

Finally i figured out the solution to this problem.

最后我想出了解决这个问题的方法。

  1. Select the file you are editing (in the framework )
  2. Select the 'utilities' tab on the right
  3. uncheck the Mac target (just keep the target you are working for currently)
  1. 选择您正在编辑的文件(在框架中)
  2. 选择右侧的“实用程序”选项卡
  3. 取消选中 Mac 目标(只保留您当前正在使用的目标)

Thats it, this solved my problem. hope it helps someone who is in this kinda situation.

就是这样,这解决了我的问题。希望它可以帮助处于这种情况的人。

回答by MRizwan33

user/Library/Developer/Xcode/DerivedData Delete all the files shown in this folder. after that go to your project name and clean project then come back to the file where you wanna see suggestions. Type any word and its done.

user/Library/Developer/Xcode/DerivedData 删除此文件夹中显示的所有文件。之后,转到您的项目名称并清理项目,然后返回到您想要查看建议的文件。输入任何单词并完成。

回答by ossamacpp

Go to Xcode menu, then Window -> Organizer, then select Projects. Pick your project and press on delete button beside dervied data Then restart Xcode

转到 Xcode 菜单,然后选择 Window -> Organizer,然后选择 Projects。选择您的项目并按下导出数据旁边的删除按钮然后重新启动Xcode

That solution worked with me on Xcode 6.1

该解决方案在 Xcode 6.1 上与我一起使用