2016-05-17 70 views
0

我爲套接字編程創建了一個Objective-C項目,並且其工作正常,現在我想將它導入到我使用JSQmessageViewController進行chating的Swift項目中。我複製了「AsyncSocket.h」和「AsyncSocket.m」到我的swift項目中,並將它們導入到橋接頭中,但是當我嘗試在我的「ViewController.swift」中使用它們時,它給了我錯誤 我的橋接頭工作正常因爲我可以在我的「ViewController.swift」中使用JSQmessageViewController而沒有任何問題。這是我的橋接報無法使用橋接頭將Objective-C文件導入到Swift項目

enter image description here

構建設置似乎沒什麼問題

enter image description here

但仍收到此錯誤

enter image description here

+1

將.h文件添加到橋接頭後,不需要向swift文件添加「import」語句;目標c類將自動可用。 – Paulw11

+0

引用此鏈接,它可能會幫助你http://stackoverflow.com/questions/29500227/xcode-no-such-module-error-but-the-framework-is-there和http://stackoverflow.com/questions/31106411/no-such-module-on-xcode-7-beta-2 –

+0

謝謝@ Paulw11 –

回答

0

號不導入你的Objective-C文件直接傳送到你的swift文件。寫點像

let asyncSocketInstance:AsyncSocket = AsyncSocket() 

。確保AsyncSocket出現在Compile Sources of Build Phases下,並且其頭文件被導入到橋接頭文件中。

+0

哦,我明白了,現在讓你覺得它工作得很好。其他方面,我正在考慮將我的JSQmessageViewController項目融入Objective-C,因爲我無法在Objective-C中找到任何JSQmessageViewController教程 –

相關問題