Auto import for Xcode

2019-06-14 22:56发布

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

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".

5条回答
姐就是有狂的资本
2楼-- · 2019-06-14 22:59

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

查看更多
该账号已被封号
3楼-- · 2019-06-14 23:00

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 here and here

查看更多
时光不老,我们不散
4楼-- · 2019-06-14 23:00

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.

查看更多
可以哭但决不认输i
5楼-- · 2019-06-14 23:09

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.

查看更多
Lonely孤独者°
6楼-- · 2019-06-14 23:13

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.

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

查看更多
登录 后发表回答