XMPPFramework(一定要获取最新的代码)
GitHub: https://github.com/robbiehanson/XMPPFramework
下面我们要做三步:
1.拷贝xmpp里面的文件到项目
2.添加依赖库
3.添加扩展
你可以根据自己的需要,添加 <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