#import vs @import
在xcode 5 下,為了更易於開發,增加了modules和 auto-linking 這兩個新特性。用 @import 來增加框架 到專案中比用 #import會更有效. 我們來看看為什麼:
"Modules for system frameworks speed build time and provide an alternate means to import APIs from the SDK instead of using the C preprocessor. Modules provide many of the build-time improvements of precompiled headers with less maintenance or need for optimization. They are designed for easy adoption with little or no source changes. Beyond build-time improvements, modules provide a cleaner API model that enables many great features in the tools, such as Auto Linking."
Modules and auto-linking
預設情況下是enabled的。 如果是舊的專案,你可以通過設定"Language - Modules." 來設定Enable Modules 和Link Frameworks Automatically 為Yes。
另外一個使用moudules的好處是你再也不用去連結你的framework到你的專案了。例如,在以前,如果你要使用MapKit這個框架,你要這樣做1) 使用語句 #import <MapKit/MapKit.h> 匯入框架2) 去到專案的build phases 設定項,找到MapKit.framework.並加入到Link Binary With Libraries裡面。如果使用modules的話,只需要加入語句 "@import MapKit;" 你就可以開始使用了,根本不需要連結到你的專案。
當然, @import只能引入以框架形式出現的檔案, 所以, 比如你要引入一個自定義cell的標頭檔案是不能用這個的
相關文章
- #import、#include、@import modules區別Import
- require()、import、import()有哪些區別?UIImport
- Python import相關內容區別介紹( import *** as 、from***import )PythonImport
- from module import 和 import 的區別Import
- SCSS @importCSSImport
- CSS @importCSSImport
- require OR importUIImport
- Import OverImport
- Import DataImport
- export/importExportImport
- Import Error: cannot import name ‘export_saved_modelImportErrorExport
- import tkinter與from tkinter import *的區別Import
- eslint-plugin-import 規則之 Import / OrderEsLintPluginImport
- @import註解Import
- python importPythonImport
- Speedup Datapump ImportImport
- Item Import OverviewImportView
- mysql export & importMySqlExportImport
- Import parameter: STATISTICSImport
- mysql import and exportMySqlImportExport
- python 關閉 vscode 的 auto-importPythonVSCodeImport
- python基礎--自定義模組、import、from......import......PythonImport
- 徹底搞懂Python 中的 import 與 from importPythonImport
- import reload __import__在python中的區別ImportPython
- pycharm import 報錯PyCharmImport
- JavaScript import語句JavaScriptImport
- import moviepy 報錯Import
- 認識Import表Import
- Import表的重建Import
- link和@import引入css 區別,不建議使用@importImportCSS
- 重構smart-importImport
- require 和 import 詳解UIImport
- ImportError: cannot import name parseImportError
- ES6 import exportImportExport
- oracle Export/Import工具使用OracleExportImport
- statistics的export與import!ExportImport
- DB2 export and importDB2ExportImport
- Data Pump with Network importImport