gpt4 book ai didi

ios - CocoaPods - 当应用程序和框架共享依赖项时重复符号

转载 作者:行者123 更新时间:2023-11-28 05:44:14 26 4
gpt4 key购买 nike

我正在编写一个 iOS 应用程序,使用 CocoaPods 1.6.0 作为我的依赖项管理器。我的项目包括一个 iOS 应用程序项目 (myapp-ui),以及 3 个 iOS 框架项目 (myapp-common, myapp-modelmyapp-editor)。我还利用 Fabric.io 进行崩溃报告和应用指标。我的 myapp-uimyapp-model 项目都使用了 FabricCrashlytics 框架。我的 Pods 文件如下所示:

platform :ios, '11.0'
workspace 'MyApp.xcworkspace'

project 'myapp-ui/myapp-ui.xcodeproj'
project 'myapp-common/myapp-common.xcodeproj'
project 'myapp-model/myapp-model.xcodeproj'
project 'myapp-editor/myapp-editor.xcodeproj'

target 'myapp-ui' do
use_frameworks!

project 'myapp-ui/myapp-ui.xcodeproj'

# Pods for myapp-ui
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'
pod 'KeychainSwift', '~> 13.0'

target 'myapp-uiTests' do
inherit! :search_paths
# Pods for testing
end

end

target 'myapp-common' do
use_frameworks!

project 'myapp-common/myapp-common.xcodeproj'

# Pods for myapp-common
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'KeychainSwift', '~> 13.0'

end

target 'myapp-model' do
use_frameworks!

project 'myapp-model/myapp-model.xcodeproj'

# Pods for myapp-model
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'

end

target 'myapp-editor' do
use_frameworks!

project 'myapp-editor/myapp-editor.xcodeproj'

# Pods for myapp-editor

end

Pod 安装很好,我的应用程序构建也没有问题。但是,当我运行它时,我在控制台中看到大量错误,看起来像这样:

objc[62607]: Class CLSInternalReport is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f960) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f2831e8). One of the two will be used. Which one is undefined.
objc[62607]: Class Crashlytics is implemented in both <SOME LOCATION>/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f9b0) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283238). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSFileManager is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa00) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283288). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSAlert is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa78) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283300). One of the two will be used. Which one is undefined.

有没有办法解决这些警告?我尝试将它们从 myapp-ui 中删除,认为 myapp-ui 使用了 myapp-model (因此会继承依赖项)但这没有用。我不知道如何解决这个问题。想法?

最佳答案

我收到了与您看到的相同的警告,我花了一些时间才找到修复方法。事实证明,当您有预编译的依赖项时会发生这种情况,例如 FabricCrashlytics。我认为这是因为它们被复制了两次。

我所做的是仅将这些 pod 添加到应用程序目标。我的 Podfile 最终看起来有点像这样

def pods
pod 'CGMath'
...
end

def app
pod 'Crashlytics'
pod 'Fabric'
end

target 'FrameworkTarget' do
pods
end

target 'AppTarget' do
pods
app
end

关于ios - CocoaPods - 当应用程序和框架共享依赖项时重复符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55503636/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com