码迷,mamicode.com
首页 > 移动开发 > 详细

【iOS XMPP】使用XMPPFramewok(一):添加XMPPFramework(XCode 4.6.2)

时间:2014-11-27 17:41:44      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   os   使用   sp   strong   文件   

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

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 内容如下,可根据实际使用模块进行删改:

bubuko.com,布布扣
#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"
bubuko.com,布布扣

 

还有一些问题,是由于没有添加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)

标签:blog   http   io   ar   os   使用   sp   strong   文件   

原文地址:http://www.cnblogs.com/wangpei/p/4126540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!