iOS 框架问题:类在两者中都实现 [英] iOS Framework issue: Class is implemented in both

查看:33
本文介绍了iOS 框架问题:类在两者中都实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用第三方框架类的 iOS 框架项目,因此我在链接的框架和库部分下添加了第三方框架.

I'm working on an iOS framework project which is using a third-party framework classes so I added third-party framework under Linked frameworks and libraries section.

当我在 iOS 应用项目中添加自定义框架时,每个类都会收到此警告

When I add my custom framework in my iOS app project, I'm getting this warning for each class

objc[3139]: 类 'class_name' 在两者中都实现/private/var/containers/Bundle/Application/C131AF0F-7CF8-4360-8716-3E8A595169D6/'app_name'.app/Frameworks/'framework_name'.framework/'framework_name'和/var/containers/Bundle/Application/C131AF0F-7CF8-4360-8716-3E8A595169D6/'app_name'.app/'app_name'.将使用两者之一.哪个是未定义的.

objc[3139]: Class 'class_name' is implemented in both /private/var/containers/Bundle/Application/C131AF0F-7CF8-4360-8716-3E8A595169D6/'app_name'.app/Frameworks/'framework_name'.framework/'framework_name' and /var/containers/Bundle/Application/C131AF0F-7CF8-4360-8716-3E8A595169D6/'app_name'.app/'app_name'. One of the two will be used. Which one is undefined.

iOS 应用项目也与该第三方框架相关联.所以我觉得这个问题是因为我的框架也包含第三方框架的编译版本.

iOS app project is also linked with that third-party framework. So I think getting this issue because my framework also contains compiled version of third-party framework.

我没有找到任何合适的解决方案.谁能告诉我如何摆脱这个?

I didn't find any proper solution for this. Can anyone tell me how to get rid of this?

有什么办法可以让它工作吗?

Is there any way i can make it work?

推荐答案

tl;dr 不要在应用程序目标的构建阶段中链接第三方框架.改用自动链接框架.

tl;dr Don't link the third-party framework in your application target's Build Phases. Use Link Frameworks Automatically instead.

为了更清楚地说明这一点,让我举个例子.有一个名为 CrashReporter.framework 的第三方框架.自定义框架称为 HockeySDK.framework(链接到 CrashReporter.framework).然后我的应用程序名为 WeatherApp(链接到 HockeySDK.framework).

To make this a little more clear, let me give an example. There is a third-party framework called CrashReporter.framework. The custom framework is called HockeySDK.framework (which links to CrashReporter.framework). Then I have my application called WeatherApp (which links to HockeySDK.framework).

CrashReporter.framework  <---
    ^                        |
    |                        |
    |                      X X X   NO! DONT'T LINK THIS!
HockeySDK.framework          |
    ^                        |
    |                        |
    |                        |
WeatherApp  -----------------

在 WeatherApp 目标中构建阶段Link Binary With Libraries部分中链接 CrashReporter.framework(即使 Weather 应用程序需要 CrashReproter.framework 来构建).我转到 WeatherApp 目标的 Build Settings 并确保 Link Frameworks Automatically(和 Enable Modules (C and Objective-C) 如果在 iOS 上)) 设置为 Yes.

I do not link CrashReporter.framework in the Link Binary With Libraries section of Build Phases in the WeatherApp target (even though Weather app needs CrashReproter.framework to build). I go to the Build Settings of the WeatherApp target and ensure Link Frameworks Automatically (and Enable Modules (C and Objective-C) if on iOS) is set to Yes.

这篇关于iOS 框架问题:类在两者中都实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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