处理 iOS 框架项目的依赖项 [英] handling dependencies for iOS Framework project

查看:35
本文介绍了处理 iOS 框架项目的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这种方法创建了 iOS 框架项目:https://github.com/jverkoey/iOS-框架

I've created iOS Framework project using this method: https://github.com/jverkoey/iOS-Framework

工作得非常整洁,但我有点困惑如何包含我的框架工作所需的库/框架,特别是如何做到这一点,以便万一使用我的框架的 3rd 方客户端应用程序可以包括这些库也没有冲突.

Works pretty neat but I'm a little confused on how to include libraries/frameworks that are needed by my framework to work and, in particular, how to do it so that in case 3rd party client app that uses my framework can include these libs as well without conflicts.

假设我的框架代码需要这两件事:

Let's say my framework code needs these two things:

  • FacebookSDK.framework
  • libFlurry.a

第一个是 iOS 框架.当我将它添加到我的框架中的使用库链接二进制文件"阶段并尝试编译使用我的框架的 客户端项目 时,链接器抱怨缺少符号 - 我需要将 FacebookSDK 添加到客户端项目中太好了:如果客户端应用程序想要使用 Facebook,则不会发生冲突.

The first one is an iOS Framework. When I add it to "Link Binary With Libraries" phase in my Framework and try compile the client project that uses my framework the linker complains about missing symbols - I need to add FacebookSDK to the client project which is great: there is no possibility of conflicts if client apps wants to use Facebook.

但是,当我对 Flurry 静态库执行相同操作时,在编译客户端项目时出现重复符号错误.这让我有点困惑,因为 FacebookSDK.framework 不只是一个打包的静态库吗?

However when I do the same with Flurry static library I get duplicate symbols error when compiling client project. Which confuses me a bit, because isn't FacebookSDK.framework just a packaged static library?

ukaszs-iMac:FacebookSDK.framework lukasz$ file Versions/A/FacebookSDK 
Versions/A/FacebookSDK: Mach-O universal binary with 3 architectures
Versions/A/FacebookSDK (for architecture i386): current ar archive random library
Versions/A/FacebookSDK (for architecture armv7):    current ar archive random library
Versions/A/FacebookSDK (for architecture cputype (12) cpusubtype (11)): current ar archive random library

所以我的问题是:

  1. 为什么嵌入在框架中的库(如 Facebook)没有链接到我的框架项目产品,而包含为 .a 文件的库是?
  2. 如何在我的框架中包含 .a 文件,这样当使用我的框架的客户端应用也需要这个特定的静态库时,它不会产生重复符号错误?

推荐答案

对于您描述的用例,您应该从您的应用程序链接到这些外部库,而不是您自己的框架.它可以是其中之一,但不能同时是两者.

For the use case you are describing, you should be linking to these external libraries from your application, NOT your own framework. It can be one or the other, but it can't be both.

如果您决定这些依赖项属于应用程序的责任,您将从Link Binary With Libraries"和任何其他显式链接配置中删除它们,并且只需使用这些框架和库的路径来投影您的框架项目,以便它可以在编译时找到符号(但不能链接到它们)(即库的路径应该包含在 LIBRARY_SEARCH_PATHS 中).

If you decide that these dependancies belong as the responsibility of the application, you would remove them from "Link Binary With Libraries" and any other explicit linking configuration, and just project your framework project with the path to these frameworks and libraries so it can find the symbols (but not link against them) at compile time (i.e. the path to the libraries should be included LIBRARY_SEARCH_PATHS).

这篇关于处理 iOS 框架项目的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆