我有两个项目的iOS工作区:
Core
-是一个带有框架的项目。另外,它通过swift软件包管理器具有RxSwift
依赖性。
App
-是具有Core.framework
作为嵌入依赖关系和RxSwift
作为快速包管理器依赖关系的应用程序。
我在运行应用程序时收到以下警告:
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
解决此崩溃的可能方法是什么?
答案 0 :(得分:3)
问题是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.
在这种情况下,可能的解决方法是从RxSwift
模块中删除App
依赖性。它不会破坏代码,因为RxSwift
是传递依赖项,将在App
模块内部可用。