如何解决Cocoa touch框架中的符号名冲突 [英] How to resolve symbol name conflict in a Cocoa touch framework

查看:125
本文介绍了如何解决Cocoa touch框架中的符号名冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个Cocoa touch框架,并且遇到了嵌入其中的第三方静态框架类的问题。

I developed a Cocoa touch framework and am having problems with third party static framework classes which are embedded inside of it.

问题是消费者项目使用时的符号冲突我的框架,还导入我的框架使用的第三方静态框架。

The problem is symbol collisions when consumer projects use my framework and also import the third party static framework which my framework uses.

我最终想从我的框架中删除这些类,因为它们与主机项目类冲突使用相同的第三方框架),并以某种方式告诉我的框架依赖主项目第三方框架(我将指示devs导入框架),
或者,我将添加一个前缀到这些类,以便在托管项目嵌入我的框架和使用相同的第三方框架作为我自己的框架它不会得到符号冲突

I eventually want to remove these classes from my framework since they are conflicting with host project classes (they use same third party framework) and somehow tell my framework to rely on main project third party framework (I will instruct devs to import the framework), Or alternatively I will add a prefix to these classes so that when hosting projects embed my framework and use the same third party framework as my own framework it won't get a symbol collisions

任何帮助或方向将欢迎!

Any help or direction will be welcomed!

推荐答案

CocoaPods 可帮助您解决重复符号的问题。

下面我详细说明了如何实现:

CocoaPods can help you to resolve the problem with duplicate symbols.
Below I provided detailed explanations for how to make it happen:

定义

让我们做一些简单的解释的定义:

MyFramework - 你正在开发的框架。

MyApplication 。。 在 MyFramework MyApplication 中使用的第三方框架。

Definitions
Let's make some definitions for simpler explanations:
MyFramework - framework that you are developing.
MyApplication - application that uses MyFramework.
OtherFramework - third-party framework that is used in MyFramework and MyApplication.

问题

根据我的理解,问题是Xcode无法使用重复符号 c $ c> OtherFramework 。

解决方案

以下是您需要满足的条件要解决这个问题:

Solution
Here are conditions that you need satisfy to fix that problem:

1) MyFramework 必须引用 OtherFramework CocoaPods:

1) MyFramework has to refer to OtherFramework by CocoaPods:

// MyFramework Podfile
use_frameworks!
pod "OtherFramework"

2) MyApplication 必须引用CocoaPods的 OtherFramework

2) MyApplication has to refer to OtherFramework by CocoaPods:

// MyApplication Podfile
use_frameworks!
pod "OtherFramework"

3) MyApplication 可以使用任何机制来引用 MyFramework (由CocoaPods或Drag& Drop框架到项目)。

3) MyApplication can use any mechanism to refer to MyFramework (by CocoaPods or by Drag&Drop framework to project).

4) OtherFramework 必须使用CocoaPods构建。

如果它不是用CocoaPods构建的,你可以自己做。 b $ b为了这个目标,你需要创建 OtherFramework.podspec 并且可选地将它提交到CocoaPods私人仓库。如果你有源文件或只是 OtherFramework.framework bundle没有关系。有关构建CocoaPod的详细信息,请此处

4) OtherFramework has to be built with CocoaPods.
If it's not built with CocoaPods yet, you can make it yourself.
For this goal you need to create OtherFramework.podspec and optionally submit it to CocoaPods private repository. It doesn't matter if you have source files or just OtherFramework.framework bundle. More details for building CocoaPod here.

这篇关于如何解决Cocoa touch框架中的符号名冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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