停止 xcode 索引

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

Stopping xcode from indexing

xcode

提问by CBredlow

I've been working with xCode 4.5.2, and have noticed that if you are indexing, you need to stop everything and let it do it's job, or else you'll get bogged down. It's become a bit of a problem, as the project is a large one, and indexing has been taking a long time to do, and it will do it constantly. One instance was it indexed the entire project, after I worked a little bit on the project it started to re-index almost 75% of the project. I checked with source control, and there had been no changes to the project in the amount of time I worked on it.

我一直在使用 xCode 4.5.2,并注意到如果你正在编制索引,你需要停止一切并让它完成它的工作,否则你会陷入困境。这已经成为一个问题,因为项目很大,而且索引需要很长时间才能完成,并且会不断地进行。一个例子是它索引了整个项目,在我对这个项目做了一点工作之后,它开始重新索引几乎 75% 的项目。我检查了源代码管理,在我处理它的时间内没有对项目进行任何更改。

Is there any way to stop the indexing entirely, or reduce the amount of times it indexes? Are there any downsides of turning off indexing? I had read in previous questions where it was said it prevented auto-complete and searching through the project.

有什么办法可以完全停止索引,或者减少索引的次数?关闭索引有什么缺点吗?我在之前的问题中读到过,据说它阻止了自动完成和搜索项目。

回答by Josiah

Just run this command in the terminal to turn off Indexing:

只需在终端中运行此命令即可关闭索引:

defaults write com.apple.dt.XCode IDEIndexDisable 1

To turn it back on, run this:

要重新打开它,请运行以下命令:

defaults write com.apple.dt.XCode IDEIndexDisable 0

(Note: Apparently you need to delete this key in order for the change to take affect, however, I used simply the above command and it worked fine. So if doing the above doesn't work, try deleting the key)

(注意:显然您需要删除此密钥才能使更改生效,但是,我仅使用了上面的命令并且效果很好。因此,如果执行上述操作不起作用,请尝试删除该密钥)

EDIT

编辑

Sorry, missed part of the question. Yes, it will make it so searching does not work as fast. Perhaps auto-complete will get disabled. Indexing is what allows Xcode to quickly remember what you have done. Turning it off will make it slightly harder to work with, but it improves loading time.

抱歉,漏掉了一部分问题。是的,它会使搜索速度变慢。也许自动完成会被禁用。索引使 Xcode 能够快速记住您所做的事情。关闭它会使它更难使用,但它会缩短加载时间。

回答by Darko

Whatever is your reason to want this (mine is "An internal error occurred. Editing functionality may be limited") for Xcode 10.1:

无论您想要这个的原因是什么(我的原因是“发生内部错误。编辑功能可能受到限制”)用于Xcode 10.1

defaults write com.apple.dt.Xcode IDEIndexDisable -bool true

Close Xcode, run this, open Xcode.

关闭Xcode,运行它,打开Xcode。

回答by kalmiya

If you are working on a large project and generate the xcodeproj with cmake, you will get into problems when you add large binaries into it. If cmake doesn't recognize the extension it tags them as 'sourcecode' by default!

如果您正在处理一个大型项目并使用 cmake 生成 xcodeproj,则在向其中添加大型二进制文件时会遇到问题。如果 cmake 无法识别扩展名,则默认情况下会将它们标记为“源代码”!

... and those binaries will then be indexed by xcode, meaning your machine is constantly indexing ( and start from scratch each time you regenerate the workspace ). Also find-in-files won't work (it just hangs).

...然后这些二进制文件将由 xcode 索引,这意味着您的机器会不断索引(并且每次重新生成工作区时都从头开始)。查找文件也不起作用(它只是挂起)。

One easy solution is to tag your binaries and tell xcode to ignore them, e.g. like this ( cmake 3.2 and higher, otherwise XCODE_EXPLICIT_FILE_TYPE isn't supported ) :

一种简单的解决方案是标记您的二进制文件并告诉 xcode 忽略它们,例如像这样(cmake 3.2 及更高版本,否则不支持 XCODE_EXPLICIT_FILE_TYPE):

# fill cmake-variable with some files
file(GLOB MYGAME_BINARIES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "binaries/*")
# tag them as "not-sourcecode" ( maybe there is sth better than 'compiled', but it worked for my purpose)
set_source_files_properties( ${MYGAME_BINARIES} PROPERTIES XCODE_EXPLICIT_FILE_TYPE "compiled" )