Xcode 自动导入

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

Auto import for Xcode

iphonexcodeauto-import

提问by samwize

Is it possible for Xcode to auto import the frameworks and class headers automatically?

Xcode 是否可以自动导入框架和类头文件?

What happens is that every time I build, I will encounter errors due to missing import. I know how to fix, but I felt Xcode can be more intelligent by perhaps giving me an option to "Auto fix imports".

发生的情况是,每次我构建时,都会因为缺少导入而遇到错误。我知道如何修复,但我觉得 Xcode 可以通过给我一个“自动修复导入”选项来更智能。

回答by Stelian Iancu

At the moment it's not possible to do that. I suppose what you want is something like Eclipse's auto-import, i.e. when you first use a class in code, it auto-imports the package.

目前无法做到这一点。我想您想要的是 Eclipse 的自动导入功能,即当您第一次在代码中使用类时,它会自动导入包。

You should open a bug report hereto let the Apple people know about it.

您应该在此处打开错误报告,让 Apple 人员了解它。

回答by Tomasz B?k

I know the question is old, but it is good to know that @import was added to LLVM with XCode 5. It gives you features that you wanted. You can find more hereand here

我知道这个问题很老,但很高兴知道 @import 已通过 XCode 5 添加到 LLVM。它为您提供了您想要的功能。你可以在这里这里找到更多

回答by futureelite7

You can import a class header into all files automatically by adding it in the .pch file. You will still need to add the frameworks manually though.

您可以通过将类头添加到 .pch 文件中来自动将类头导入到所有文件中。不过,您仍然需要手动添加框架。

回答by Moritz

AppCode has the auto import feature. In my opinion it's not an Xcode replacement, but a welcome addition. It has some killer features like multi caret editing, refactoring that actually works, auto import, tabs that don't drive me nuts, structured code view, etc. Give it a try, you owe it to yourself.

AppCode 具有自动导入功能。在我看来,它不是 Xcode 的替代品,而是一个受欢迎的补充。它具有一些杀手级功能,例如多插入符号编辑、实际工作的重构、自动导入、不会让我发疯的选项卡、结构化代码视图等。试一试,你欠自己的。

回答by Tom Schulz

If you install Alcatraz (package manager for xcode) then you can search for "Auto Importer" and you should be good.

如果你安装了 Alcatraz(xcode 的包管理器),那么你可以搜索“Auto Importer”,你应该会很好。