Xcode 9 自动完成不工作 100% - 部分工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46504286/
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
Xcode 9 Autocomplete Not Working 100% - Partially Working
提问by Ernie
采纳答案by Ernie
Deleting the DERIVED DATA folder seemed to fix my issue. Thanks to this post: swift println() not showing autocomplete options while writting code
删除 DERIVED DATA 文件夹似乎解决了我的问题。感谢这篇文章:swift println() 在编写代码时不显示自动完成选项
回答by Lal Krishna
Try:
尝试:
- Go to Xcode > Preferences > Text Editing
- Under Code completion - Uncheck 'Suggest completions while typing'
- Quit out of Xcode and then relaunch Xcode.
- Go to Xcode > Preferences > Text Editingagain
- Quit out of Xcode and then relaunch Xcode.
- Now go to Code completion and check'Suggest completions while typing'.
- Try typing library function or enum and enjoy!
- 转到Xcode > 首选项 > 文本编辑
- 在代码完成下 - 取消选中“键入时建议完成”
- 退出 Xcode,然后重新启动 Xcode。
- 再次转到Xcode > Preferences > Text Editing
- 退出 Xcode,然后重新启动 Xcode。
- 现在转到代码完成并选中“键入时建议完成”。
- 尝试输入库函数或枚举并享受!
回答by Sethmr
Things to try:
尝试的事情:
1
1
Run this command in the project directory if you use cocoapods:
如果使用 cocoapods,请在项目目录中运行此命令:
rm -rf ~/Library/Caches/CocoaPods;
rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*;
pod deintegrate; pod setup; pod install;
2
2
Clean Cached Data
清理缓存数据
Clean the Project -> Cmd+Shift+K
清理项目 -> Cmd+Shift+K
Clean the Build Folder -> Cmd+Shift+Option+K
清理构建文件夹 -> Cmd+Shift+Option+K
If you skipped step one:
Delete Derived DataXcode Preferences
-> Locations
->
Arrow Symbol Takes you to DerrivedData
-> Delete Folder
如果您跳过了第一步:
删除派生数据Xcode Preferences
-> Locations
->
箭头符号将您带到DerrivedData
-> 删除文件夹
3
3
Check your Build Phase's Compile Sources.
检查您的构建阶段的编译源。
Every .swift
and .m
file in the project should be in this list or it won't autocomplete in those files.
项目中的每个.swift
和.m
文件都应该在这个列表中,否则它不会在这些文件中自动完成。
4
4
Optimize your Editor:
优化您的编辑器:
Use fileprivate on every class property and function that you can to reduce the scope of the Compilers work per item.
对每个类属性和函数使用 fileprivate 可以减少每个项目的编译器工作范围。
Write modular/OOP code so you have less code for the compiler to read.
编写模块化/OOP 代码,以便编译器读取更少的代码。
Avoid using Type Inferance when the result is a complex calculation, and try to break down complex calculations into let this = smallerOperation
statements
当结果是复杂计算时避免使用类型推断,并尝试将复杂计算分解为let this = smallerOperation
语句
回答by Kostiantyn Bykhkalo
Xcode Version 11.0 (11A420a)
Xcode 版本 11.0 (11A420a)
I have tried the solution from Lal Krishnafor Xcode V11.0. It worked a few times but later I got no result.
我已经尝试过Lal Krishna为 Xcode V11.0 提供的解决方案。它工作了几次,但后来我没有结果。
I found one solution. You must delete two files:
我找到了一种解决方案。您必须删除两个文件:
- Library/Developer/Xcode/Derived Data (as described before)
- Library/Developer/Xcode/UserData/IDEEditorInteractivityHistory
- 库/开发人员/Xcode/派生数据(如前所述)
- 库/开发人员/Xcode/UserData/IDEEditorInteractivityHistory
That solution helps me now. May be useful for others
该解决方案现在可以帮助我。可能对其他人有用
回答by Isaiah Turner
This can happen when the file is not a member of the Target. Open the file where autocomplete is not working and show the the "Utilities" tab in the top right of Xcode (blue in the screenshot below).
当文件不是目标的成员时,可能会发生这种情况。打开自动完成功能不工作的文件,并在 Xcode 的右上角显示“Utilities”选项卡(下面屏幕截图中的蓝色)。
Ensure your Target (typically your app's name) is checked. Autocomplete should work almost instantly without restarting Xcode, cleaning, or deleting Derived Data.
确保您的目标(通常是您的应用程序名称)已选中。自动完成应该几乎立即工作,而无需重新启动 Xcode、清理或删除派生数据。
If it is already checked, make sure to uncheck and recheck it again. For me, it did the trick.
如果已选中,请确保取消选中并重新选中。对我来说,它成功了。
回答by Gent Berani
I'm using Xcode 10.2and I had the same issue.
我正在使用Xcode 10.2,但我遇到了同样的问题。
This answerfrom axelhelped me to fix.
这个答案从阿克塞尔帮我解决。
Anyway, I'm going to describe a bit more:
无论如何,我要多描述一点:
- Go to
YourProject.xcodeproj
by clicking with Right Mouse Click and openShow Package Contents
- Go to
xcuserdata
and delete youryouruser.xcuserdatad
YourProject.xcodeproj
通过单击鼠标右键单击转到并打开Show Package Contents
- 转到
xcuserdata
并删除您的youruser.xcuserdatad
If you have also the xcworkspace
(if you already have any podsinstalled) then do step 3&4, if not then just skip step 3&4:
如果您还安装了xcworkspace
(如果您已经安装了任何Pod),则执行第 3 步和第 4 步,如果没有,则跳过第 3 步和第 4 步:
- Go to
YourProject.xcworkspace
by clicking with Right Mouse Click and openShow Package Contents
Go to
xcuserdata
and delete youryouruser.xcuserdatad
Quit Xcode
- Delete Derived Databy using Terminal:
YourProject.xcworkspace
通过单击鼠标右键单击转到并打开Show Package Contents
转到
xcuserdata
并删除您的youruser.xcuserdatad
退出 Xcode
- 使用终端删除派生数据:
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData
- Open Xcode and check if it works.
- 打开Xcode并检查它是否有效。
回答by ScottyBlades
This can also happen if you redundantly named your files. For example,
如果您对文件进行了冗余命名,也会发生这种情况。例如,
Data.swift
Data.swift
Data.swift
Data.swift
回答by Martin Jun
Removing the file from the Test Targets fixed my problem.
从测试目标中删除文件解决了我的问题。
回答by abhimuralidharan
Please try doing this:
请尝试这样做:
Select the file>> check if the file is added to UITesting or UnitTesting targets (File inspector -> Target Membership). If so, please uncheck those two and make sure only the project target is selected. Then build and try if autocomplete is working fine.
选择文件>> 检查文件是否已添加到 UITesting 或 UnitTesting 目标(文件检查器 -> 目标成员资格)。如果是这样,请取消选中这两个并确保只选择了项目目标。然后构建并尝试自动完成是否正常工作。
This worked for me. Hope it help someone.
这对我有用。希望它可以帮助某人。
回答by Xcoder
After a long time of searching, I finally fixed the issue for me. In Xcode > Preferences > Text Editing, in "Code Completion", I had "Use Escape key to show completion suggestions" checked for some reason. As soon as I unchecked this box, auto completion worked like a charm, without even needing to restart Xcode! (Xcode 10)
经过长时间的搜索,我终于为我解决了这个问题。在 Xcode > 首选项 > 文本编辑中,在“代码完成”中,我出于某种原因选中了“使用 Escape 键显示完成建议”。一旦我取消选中这个框,自动完成就像一个魅力,甚至不需要重新启动 Xcode!(Xcode 10)