[英]How to manage transitive dependency for local Xcode projects
I have two Objective C dynamic frameworks X and Y and another Objective C app Z. All these frameworks and apps have been created by me locally.我有两个 Objective C 动态框架 X 和 Y 以及另一个 Objective C app Z。所有这些框架和应用程序都是我在本地创建的。 Framework X is the very base framework used by framework Y and the app Z. So the dependency graph is something like the following:
框架 X 是框架 Y 和应用程序 Z 使用的非常基础的框架。因此依赖关系图类似于以下内容:
Y ---> X Y ---> X
Z ---> X Z ---> X
Z ---> Y (---> X) Z ---> Y (---> X)
I want all my targets to be debuggable and to pick the platform tools based on run destination (device/simulator).我希望我的所有目标都是可调试的,并根据运行目标(设备/模拟器)选择平台工具。 So I have added dependencies as sub-projects to the main projects and have linked them with the dependent projects to generate implicit dependencies by Xcode.
因此,我将依赖项作为子项目添加到主项目中,并将它们与依赖项目链接,以通过 Xcode 生成隐式依赖项。
The set up 1 and 2 works great independently.设置 1 和 2 可以独立工作。 But I am struggling with the set up 3 which is creating duplicate build rules for the target X due to transitive dependency on it (target Y and Z both depends on it) and subsequently failing the build process.
但是我正在为设置 3 苦苦挣扎,该设置 3 由于对目标 X 的传递依赖(目标 Y 和 Z 都依赖它)而为目标 X 创建重复的构建规则,随后构建过程失败。
Anyone has any idea on how to deal with this situation?任何人都知道如何处理这种情况? Thanks in advance!
提前致谢!
It seem that in Objective-C, We can't link a dynamic framework to another dynamic framework, or to a command line tool.似乎在 Objective-C 中,我们无法将动态框架链接到另一个动态框架或命令行工具。 It's always raise an exception, when running in production
在生产中运行时总是会引发异常
Dyld Error Message:
Library not loaded: @rpath/XFrameworks.framework/Versions/A/XFrameworks
For your situation, What I think might solve your problem对于您的情况,我认为可能会解决您的问题
Actually there is a way through which I could finally solve the issue of transitive dependency in Xcode.实际上有一种方法可以最终解决 Xcode 中的传递依赖问题。 I have to use Workspace (.xcworkspace) rather than a Xcode project (.xcodeproj).
我必须使用工作区 (.xcworkspace) 而不是 Xcode 项目 (.xcodeproj)。
To get it done use the following steps:要完成它,请使用以下步骤:
This setup works like a charm for me without ever creating duplicate build rules and it spontaneously picked up the dependency as well.这种设置对我来说就像一个魅力,而无需创建重复的构建规则,它也自发地拾取了依赖关系。
Obviously, you can not do this if your independent framework is a static library and in that case it will be linked to both the dependent targets causing duplicate symbols issue during linking.显然,如果您的独立框架是 static 库,则您不能这样做,在这种情况下,它将链接到两个依赖目标,导致链接期间出现重复符号问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.