iOS XMPP:添加XMPPFramework及其他架構(三)

來源:互聯網
上載者:User

標籤:

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及其他架構(三)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.