1
在我斯威夫特2項目,在Xcode 8.2.1中定位iOS 9.2及以上,我有一些代碼,顯示郵件撰寫屏幕,像這樣:爲什麼我能夠在沒有框架引用的情況下使用MessageUI?
if MFMailComposeViewController.canSendMail() {
let composeMailVC = MFMailComposeViewController()
composeMailVC.mailComposeDelegate = self
composeMailVC.setSubject("Test")
// etc
}
本來我不得不把MessageUI.framework
參考我項目屬性,但刪除框架引用和清理項目後,它仍然沒有問題,當我在我的設備上運行代碼時,郵件撰寫窗口仍然顯示,似乎功能齊全。
我在我的.xcodeproj
文件的原始文本中找不到任何明確提及MessageUI.framework
的文件,在我的Objective-C橋接頭文件中也沒有任何內容。
我知道Swift的確提供了一些隱式的框架引用,但我找不到任何暗示MessageUI.framework
就是其中之一的東西。
奇怪的是,當我跳到MFMailComposeViewController
的定義時,XCode在MessageUI
模塊中顯示它。
你是否在你的swift文件的頂部有'import MessageUI'語句? – chengsam
@chengsam是的,我已經在使用'MFMailComposeViewController'的文件的頂部導入了MessageUI'和'import Foundation'。 – Dai
'import'語句在場景後面爲你提供了'MessageUI'框架。有關更詳細的說明,請參見[this](http://stackoverflow.com/questions/30425371/linked-frameworks-and-libraries-in-swift-project)。 – chengsam