聲明OC的頭文件在Swift中使用實際上分為兩種情況:
一種是對于一個應(yīng)用本身(App Target),我們需要聲明 Objective-C Bridging Header
- In your Objective-C bridging header, import every Objective-C header you want to expose to Swift.
In Build Settings, in Swift Compiler - Code Generation, make sure the Objective-C Bridging Header build setting has a path to the bridging header file. The path should be relative to your project, similar to the way your Info.plist path is specified in Build Settings. In most cases, you won't need to modify this setting.
另一種是作為一個靜態(tài)庫(Framework Target),我們需要使用 Umbrella Header,這樣所有的Swift文件就會自動識別所有被聲明的 OC 頭文件,并且Swift文件不需要再次引入聲明 "import statements"
Under Build Settings, in Packaging, make sure the Defines Module setting for the framework target is set to Yes.
- In the umbrella header, import every Objective-C header you want to expose to Swift.
更多詳細的信息可以參考 Importing Objective-C into Swift

