【iOS XMPP】使用XMPPFramewok(一):添加XMPPFramework(XCode 4.6.2)
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
?
ARC 警告
XMPPFramework 使用 ARC,如果你的項目沒有使用 ARC,build 之后你會得到許許多多的 ARC 警告。
不要忽視這些警告,它會導致你的程序因 memory leak 而崩潰……
Edit -> Refactor ->?convert to Objective-C ARC,消滅這些警告!
?
參考:?https://github.com/robbiehanson/XMPPFramework/wiki/GettingStarted_iOS
總結
以上是生活随笔為你收集整理的【iOS XMPP】使用XMPPFramewok(一):添加XMPPFramework(XCode 4.6.2)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS开发之邮件发送代码
- 下一篇: 【iOS XMPP】使用XMPPFram