xcode 关于如何手动安装 XMPPFramework 的最新说明?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9091767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:10:26  来源:igfitidea点击:

Up to date instructions on how to install XMPPFramework manually?

iphoneiosxcodexmppframework

提问by user798719

I'm having a really tough time getting XMPPFramework to work. I've followed every direction written on the net, and XCode is not finding any of my XMPPFramework classes.

我真的很难让 XMPPFramework 工作。我遵循了网上写的每一个方向,而 XCode 没有找到我的任何 XMPPFramework 类。

Expected specifier-qualifier-list before 'XMPPStream' XMPP.h: No such file or directory XMPPRoster.h: No such file or directory

“XMPPStream”之前的预期说明符限定符列表 XMPP.h:没有这样的文件或目录 XMPPRoster.h:没有这样的文件或目录

I have XMPPFramework copied into my project's root directory. Why can't these files be seen? Is there something that I need to do under Header Search Paths or Library Search Paths?

我已将 XMPPFramework 复制到我的项目的根目录中。为什么看不到这些文件?在 Header Search Paths 或 Library Search Paths 下有什么我需要做的吗?

I've set those entries to $(inherited) and $(SRCROOT) and XCode 4.2 auto-fills in my project's root directory and still doesn't find my files.

我已将这些条目设置为 $(inherited) 和 $(SRCROOT) 并且 XCode 4.2 自动填充我的项目根目录,但仍然找不到我的文件。

I'm quite sure that I'm not the only one having this issue, and it is a showstopper. Any ideas?

我很确定我不是唯一一个遇到这个问题的人,它是一个引人注目的问题。有任何想法吗?

采纳答案by Future2020

At the XMPPFramework gitHub wiki 1there is a step by step instruction that helps setting up XMPPFramework for your project.

在 XMPPFramework gitHub wiki 1 中有一个分步说明,可帮助为您的项目设置 XMPPFramework。

In fact the error you have mentioned is close to what is also indicated by the instructions.

事实上,您提到的错误与说明中指示的错误很接近。

"However, upon importing an XMPPFramework class, such as by calling '#import XMPP.h' will cause XCode to show an error 'XMPP.h' not found. It appears that XCode is not finding any of the XMPPFramework files."

“但是,在导入 XMPPFramework 类时,例如通过调用 '#import XMPP.h' 将导致 XCode 显示错误 'XMPP.h' not found。看起来 XCode 没有找到任何 XMPPFramework 文件。”

I hope this gives you enough information to solve this issue you are facing, even though the instructions are not targeted specifically to iOS-5.

我希望这为您提供了足够的信息来解决您面临的这个问题,即使这些说明不是专门针对 iOS-5 的。

回答by Brian

The wiki on github is out of date. Here is how I installed XMPPFrameworkmanually.

github 上的 wiki 已经过时了。这是我XMPPFramework手动安装的方法。

Step 1

第1步

Clone the XMPPFramework repositoryto somewhere on your machine and drag the needed folders in somewhere/XMPPFrameworkto your Xcode project.

XMPPFramework 存储库克隆到您机器上的某个位置,并将所需的文件夹拖到somewhere/XMPPFramework您的 Xcode 项目中。

The necessary folders are:

必要的文件夹是:

  • Vendor/CocoaAsyncSocket
  • Vendor/CocoaLumberHyman
  • Vendor/KissXML
  • Vendor/libidn
  • Authentication
  • Categories
  • Core
  • Utilities
  • 供应商/CocoaAsyncSocket
  • 供应商/可可伐木工人
  • 供应商/KissXML
  • 供应商/性欲
  • 验证
  • 类别
  • 公用事业

You may also need Extensions, it's optional though.

您可能还需要Extensions,但它是可选的。

It's important to select the checkbox/radio buttons exactly like this image when dragging folders to your Xcode:

将文件夹拖到 Xcode 时,选择与此图像完全相同的复选框/单选按钮很重要:

enter image description here

在此处输入图片说明

Step 2

第2步

a) Drag Sample_XMPPFramework.hto your Xcode and select the checkbox/radio buttons like step 1

a) 拖动Sample_XMPPFramework.h到您的 Xcode 并选择复选框/单选按钮,如步骤 1

b) rename it to XMPPFramework.h

b) 将其重命名为 XMPPFramework.h

c) customize the content of XMPPFramework.hbased on your needs. (I didn't change anything)

c)XMPPFramework.h根据您的需要自定义内容。(我没有改变任何东西)

The file structure should look like this in Xcode project navigator after doing step 1 and 2:

执行第 1 步和第 2 步后,Xcode 项目导航器中的文件结构应如下所示:

enter image description here

在此处输入图片说明

Step 3

第 3 步

link following frameworks and libraries

链接以下框架和库

  • CFNetwork.framework
  • Security.framework
  • libxml2.dylib
  • libresolv.dylib
  • libidn.a
  • CFNetwork.framework
  • 安全框架
  • libxml2.dylib
  • libresolv.dylib
  • 性欲

enter image description here

在此处输入图片说明

Step 4

第四步

Added these 2 lines to Build Settings:

将这两行添加到Build Settings

  • other linker flags = -lxml2 enter image description here
  • HEADER SEARCH PATHS = /usr/include/libxml2 enter image description here
  • 其他链接器标志 = -lxml2 在此处输入图片说明
  • 标头搜索路径 = /usr/include/libxml2 在此处输入图片说明

You should be good after these 4 steps. However, please notice that you usually need to #import <UIKit/UIKit.h>before using XMPPFramework

完成这 4 个步骤后,您应该会很好。但是,请注意您通常需要#import <UIKit/UIKit.h>在使用前XMPPFramework

回答by jk7

Additional information related to the instructions in @Brian's answer.

与@Brian 回答中的说明相关的其他信息。

Addition to Step 3:
If a lib file such as libxml2.dylib is not available in the "Choose frameworks and libraries to add" window, follow these steps to find it:

除了步骤 3:
如果在“选择要添加的框架和库”窗口中没有 libxml2.dylib 等 lib 文件,请按照以下步骤查找:

  1. Click Add Other...
  2. In the file selection window, COMMAND+SHIFT+G(Go to folder)
  3. Type /usr/liband then Enteror click Go
  4. Select the .dylib file you need and click Open
  1. 点击 Add Other...
  2. 在文件选择窗口中,COMMAND+SHIFT+G(转到文件夹)
  3. 键入 /usr/lib然后Enter或单击Go
  4. 选择你需要的 .dylib 文件并点击 Open

After Step 4:
Also note that XMPPFramework and its dependencies use ARC. If your app primarily uses MRR instead of ARC, either convert your app to ARC or perform step 5.

第 4 步之后:
还要注意 XMPPFramework 及其依赖项使用 ARC。如果您的应用主要使用 MRR 而不是 ARC,请将您的应用转换为 ARC 或执行步骤 5。

Step 5

第 5 步

Add -fobjc-arccompiler flag to the XMPPFramework files.

-fobjc-arc编译器标志添加到 XMPPFramework 文件。

In Xcode, for each target that will use XMPPFramework,

在 Xcode 中,对于每个将使用 XMPPFramework 的目标,

  • Go to the target's settings
  • Go to Build Phases
  • Expand Compile Sources
  • Select all the XMPPFramework-related files in the list
  • Press Enterto open the edit window for compilers flags
  • Type -fobjc-arc
  • Enteragain to save the change.
  • 转到目标的设置
  • Build Phases
  • 扩张 Compile Sources
  • 选择列表中所有与 XMPPFramework 相关的文件
  • 按下Enter可打开编译器标志的编辑窗口
  • 类型 -fobjc-arc
  • Enter再次保存更改。

The Compile Sourceslist is unsorted, so it is helpful to use the search field to filter the list on XMPPand then on XEP. That finds most of the files, but there are still some that have to be picked out from the full list of files.

Compile Sources列表是未排序的,因此使用搜索字段在XMPP和 上过滤列表会很有帮助XEP。这会找到大部分文件,但仍有一些文件需要从完整的文件列表中挑选出来。