简体   繁体   English

Xcode:与第3方框架的链接和编译

[英]Xcode: Linking and compiling with 3rd party framework

In a nutshell 简而言之

In order to compile and link my C++ iOS code with Amazon AWS SDK I had to modify the structure of the AWS framework directory. 为了将我的C ++ iOS代码与Amazon AWS开发工具包链接在一起,我不得不修改AWS框架目录的结构。 I'm trying to understand what I did incorrectly. 我试图了解我做错了什么。

In detail 详细

I have an Xcode C++ project for iOS that needs to be integrated with Amazon's AWS SDK. 我有一个用于iOS的Xcode C ++项目,该项目需要与Amazon的AWS开发工具包集成。 I downloaded the latest version of the SDK. 我下载了最新版本的SDK。 The SDK is distributed as a framework. SDK作为框架分发。 According to Amazon's article Getting Started with the AWS SDK for iOS , all I had to do was: 根据Amazon的文章《 适用于iOS的AWS开发工具包入门》 ,我要做的就是:

Control-click Frameworks Group, then click Add files to < project name > 按住Control键并单击Frameworks Group,然后单击“将文件添加到<项目名称>”。

From other Internet resources and my personal knowledge I knew that adding the framework to the project's "Build Binary With Libraries" build phase should work too. 根据其他Internet资源和我的个人知识,我知道将框架添加到项目的“使用库构建二进制文件”构建阶段也应该可行。

None of the two methods worked. 两种方法均无效。 The compiler couldn't find the header files and the linker couldn't find the binary. 编译器找不到头文件,链接器找不到二进制文件。 Moreover, when the framework appeared in the project navigator, expanding the node showed nothing, while other frameworks usually contain their resources and include files. 此外,当框架出现在项目导航器中时,扩展节点什么也没有显示,而其他框架通常包含其资源并包含文件。

Sniffing around I noticed that the directory structure of the framework is: 我四处张望,发现框架的目录结构是:

AWSiOSSDK.framework/
   Versions/
      A/
         Headers/
         Resources/ 
         AWSiOSSDK

Which is, as far as I understand, not exactly as Apple requires it to be. 据我了解,这并不完全符合苹果公司的要求 So, in a desperate attempt I removed the Versions/A part; 因此,我不顾一切地尝试删除了Versions/A部分。 ie, put all the content of the framework immediately under AWSiOSSDK.framework directory. 即,将框架的所有内容立即放在AWSiOSSDK.framework目录下。

Surprisingly that solved all the problems - the headers are found, the binaries are linked, everything works. 出人意料的是,这解决了所有问题-找到了标头,链接了二进制文件,一切正常。 Now I wonder why. 现在我想知道为什么。 I assume a framework distributed by such a respected company as Amazon should have a correct form. 我假设由像亚马逊这样的受人尊敬的公司分发的框架应该具有正确的形式。 Then why didn't it work? 那为什么不起作用呢? Why my modified structure works? 为什么我的修改结构有效? Are there frameworks with different structures? 是否有结构不同的框架? How do I tell the compiler and the linker to accept the original form? 如何告诉编译器和链接器接受原始格式? Or does Amazon distribute a broken bundle? 还是亚马逊分发了损坏的捆绑包?

Have you stored the unzipped AWS SDK for iOS on a Windows machine or a Windows based file server? 您是否已将用于iOS的解压缩AWS开发工具包存储在Windows机器或基于Windows的文件服务器上? If you unzip the SDK on a Mac, you should get extra symbolic links, but it seems like you don't have any of them. 如果在Mac上解压缩SDK,应该会获得额外的符号链接,但似乎其中没有任何符号链接。 Using non Mac based filesystems may delete these symbolic links. 使用非基于Mac的文件系统可能会删除这些符号链接。

You should download the latest version of the SDK from AWS, unzip it on a Mac and see if you have extra symbolic links. 您应该从AWS下载最新版本的SDK,在Mac上将其解压缩,看看是否还有其他符号链接。 Let me know if you have any issues. 如果您有任何问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM