gpt4 book ai didi

swift - 不同项目中的 SPM 依赖

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

我有两个项目的 iOS 工作区:

Core - 是一个带有框架的项目。它还通过 swift 包管理器具有 RxSwift 依赖性。

App - 是一个将 Core.framework 作为嵌入依赖项并将 RxSwift 作为 swift 包管理器依赖项的应用程序。

我在应用运行时收到这些警告:

objc[8296]: Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both /Users/andrey/Library/Developer/Xcode/DerivedData/App-dypyskhwoifkwagjjvtjblqppdnd/Build/Products/Debug-iphonesimulator/Core.framework/Core (0x10e092400) and /Users/andrey/Library/Developer/CoreSimulator/Devices/53D234F9-F917-46BA-B376-F28BA905EE9D/data/Containers/Bundle/Application/D4C69694-8515-44CF-B077-0CB3256D1F84/App.app/App (0x10bf95430). One of the two will be used. Which one is undefined.

但如果我尝试访问 MainScheduler.instance 这是一个静态变量,我将得到 EXC_BAD_ACCESS 堆栈崩溃:

#0  0x000000010e7d5c07 in swift_checkMetadataState ()
#1 0x000000010e7d9a17 in checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18::operator()(swift::TargetMetadata<swift::InProcess> const*) const ()
#2 0x000000010e7d97ac in bool findAnyTransitiveMetadata<checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18&>(swift::TargetMetadata<swift::InProcess> const*, checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*)::$_18&) ()
#3 0x000000010e7d96a6 in checkTransitiveCompleteness(swift::TargetMetadata<swift::InProcess> const*) ()
#4 0x000000010e7da278 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#5 0x000000010e7d0078 in swift_getSingletonMetadata ()
#6 0x000000010b3bb9b8 in type metadata accessor for MainScheduler ()
#7 0x000000010af4b1c5 in static RxSchedulers.mainScheduler.getter

修复此崩溃的可能方法是什么?

最佳答案

问题是 App 模块有两个 RxSwift 依赖项,它们相互冲突。第一个是来自 Core.framework 的传递依赖,第二个是在 App 模块中。它导致了这次崩溃。

另一个迹象表明你有两个相同的依赖关系的问题可能是警告应用程序启动。就像这个:

objc[8296]: Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both /Users/andrey/Library/Developer/Xcode/DerivedData/App-dypyskhwoifkwagjjvtjblqppdnd/Build/Products/Debug-iphonesimulator/Core.framework/Core (0x10e092400) and /Users/andrey/Library/Developer/CoreSimulator/Devices/53D234F9-F917-46BA-B376-F28BA905EE9D/data/Containers/Bundle/Application/D4C69694-8515-44CF-B077-0CB3256D1F84/App.app/App (0x10bf95430). One of the two will be used. Which one is undefined.

对于这种情况,可能的解决方法是从 App 模块中删除 RxSwift 依赖项。它不会破坏代码,因为 RxSwift 是传递依赖,并且将在 App 模块中可用。

关于swift - 不同项目中的 SPM 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58223845/

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