標籤:
XMPPFramework
GitHub: https://github.com/robbiehanson/XMPPFramework
擷取原始碼
git clone https://github.com/robbiehanson/XMPPFramework.git
checkout XMPPFramework 一個最新的 branch
添加依賴
> 拷貝 <XMPPFramework>/Vendor/CocoaLumberjack 到項目根目錄下,add files...,選擇 CocoaLumberjack 檔案夾
> 同樣的步驟,拷貝 CocoaAsyncSocket 和 KissXML 並添加到項目中
CocoaAsyncSocket 依賴 CFNetwork.framework 和 Security.framework,在 TARGETS -> Build Phases -> Link Binary With Libraries 添加
KissXML 使用了 libxml2 解析 XML,所以
首先,我們需要在 TARGETS -> Build Phases -> Link Binary With Libraries 添加 libXML2.dylib
然後,在 TARGETS -> Build Settings -> Other Linker Flags 添加 -lxml2,TARGETS -> Build Settings -> Header Search Paths 添加 /usr/include/libxml2
> 拷貝 <XMPPFramework>/Vendor/libidn 到項目根目錄下,添加靜態庫檔案 libidn.a 和標頭檔 idn-int.h 和 stringprep.h
添加 XMPPFramework
拷貝源碼目錄下的 Authentication Categories Core 和 Utilities 到項目根目錄下並添加到項目中
此外,需要添加動態串連庫 libresolv.dylib ,在 TARGETS -> Build Phases -> Link Binary With Libraries 添加
添加擴充
你可以根據自己的需要,添加 <XMPPFramework>/Extensions 的擴充到項目中
你可能遇到的問題:
> "XMPPFramework.h" file not found
XMPPFramework.h 內容如下,可根據實際使用模組進行刪改:
#import "XMPP.h"// List the modules you‘re using here.#import "XMPPReconnect.h"#import "XMPPRoster.h"#import "XMPPRosterCoreDataStorage.h"#import "XMPPvCardTempModule.h"#import "XMPPvCardAvatarModule.h"#import "XMPPvCardCoreDataStorage.h"#import "XMPPCapabilities.h"#import "XMPPCapabilitiesCoreDataStorage.h"#import "XMPPMUC.h"#import "XMPPRoomCoreDataStorage.h"
還有一些問題,是由於沒有添加Extension需要的依賴庫所產生的
可在 TARGETS -> Build Phases -> Link Binary With Libraries 添加
CoreData.framework SystemConfiguration.framework CoreLocation.framework
其他可能導致error的,設定如下:
ARC 警告
XMPPFramework 使用 ARC,如果你的項目沒有使用 ARC,build 之後你會得到許許多多的 ARC 警告。
不要忽視這些警告,它會導致你的程式因 memory leak 而崩潰……
Edit -> Refactor -> convert to Objective-C ARC,消滅這些警告!
iOS XMPP:添加XMPPFramework及其他架構(三)