现在的位置: 首页 > 综合 > 正文

ios 使用XMPPFramewok:添加XMPPFramework(XCode 4.6.2)

2017年08月14日 ⁄ 综合 ⁄ 共 1750字 ⁄ 字号 评论关闭

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

转载自:http://www.cnblogs.com/dyingbleed/archive/2013/05/09/3069145.html

抱歉!评论已关闭.