Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
637 views
in Technique[技术] by (71.8m points)

objective c - Did the way how to globally import files change in Xcode 6 / iOS 8?

I used to do my global imports (i.e. imports that would be visible to all source files in my Xcode project) in the file AppName-prefix.pch.

However, now in an Xcode 6 (and iOS 8) environment, after having created a new project, this file is not automatically generated any more.

My question is how to properly do global imports in Xcode 6? Can I just create my own AppName-prefix.pch and use this one eventually?

Note: When using Cocoapods, a file called Pods-AppName-Bolts-prefix.pch is generated. But global imports won't be working with this one.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Apple finally understood that having global dependency is a Very Very bad practice. Ideally you need to stop using PCH files, because it makes other files very messy, and breaks code reusing.

Anyway, here is solution

  1. Add new PCH file to the project - New file > Other > PCH file

  2. At the project 'Build Settings' option - set the value of 'Prefix Header' to your PCH file name, with the project name as prefix - i.e. for project named 'TestProject' and PCH file named 'MyPrefixHeaderFile', add the value 'TestProject/MyPrefixHeaderFile.pch' to the plist.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...