🗑️

XcodeプロジェクトでSwift Package ManagerとCocoaPodsを両方使うときのハマりどころ

2022/09/20に公開

アプリの機能をSwiftPackageを利用してマルチモジュール化する作業の最中は、プロジェクトが一時的にSwiftPackageとCocoaPodsの両方を使う設定になってしまうケースがあると思います。
そのようなときに、不用意に実装するとアプリがRuntimeErrorを吐いて強制終了するケースがあるので、気をつけようね、という記事です。

プロジェクトの想定状況

この記事ではプロジェクトが下記のような状況になっていることを想定しています

よくあるケースとしては、

  1. SomeSPMLibraryの機能で利用するためにRxSwiftに依存
  2. プロジェクトでは、CocoaPodsのWorkspaceを通じてRxSwiftに依存

しているような状況です。

この状況で、RxSwiftの機能を利用する

この状況下でXcodeProjectでRxSwiftの機能を利用しようとすると

このような感じでRuntimeErrorが投げられアプリが強制終了し、コンソールには下記のようなログが流れます。

objc[4264]: Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37970) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9218). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift9AtomicInt is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37628) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb4d10). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwiftP33_7413E6CD8B22AEAFB6AE58B0BDB57F5716BinaryDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37bc0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9468). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift17BooleanDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37c70) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9518). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift19CompositeDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37e58) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9700). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift32ConcurrentDispatchQueueScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37f60) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9808). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift23ConcurrentMainScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38008) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb98b0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwiftP33_419FF70AD395FC204AF1C5A95696ACDD30CurrentThreadSchedulerQueueKey is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37730) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb4e18). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift22CurrentThreadScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38120) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb99c8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift10DisposeBag is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38338) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9be0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift11DisposeBase is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f383e8) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9c90). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift13MainScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38758) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba000). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift23OperationQueueScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38978) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba220). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwiftP33_B4E79ED897163AA84B94CE0A507A463012SinkDisposer is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38a78) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba320). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift18RefCountDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38be0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba488). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift23RefCountInnerDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38c98) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba540). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift22SynchronizationTracker is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38dd8) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba680). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift19ScheduledDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38ec8) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba770). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift28SerialDispatchQueueScheduler is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f38f80) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba828). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift16SerialDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f39030) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cba8d8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxSwift26SingleAssignmentDisposable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f39158) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbaa00). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoa13ControlTarget is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105865d88) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb4fe8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_C4A5AA2E6C0BB4C2CAE530F540A96C3317MessageDispatcher is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x10586a008) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbaf00). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_10C538EC0CCB612AAE329C1334BA068720DelegateProxyFactory is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x10586a0f0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbafe8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_F7515DBB13B60709A3CB25DD19EDD11D17DeallocatingProxy is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x10586a490) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbb360). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_F7515DBB13B60709A3CB25DD19EDD11D16MessageSentProxy is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x10586a530) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbb400). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_F7515DBB13B60709A3CB25DD19EDD11D17DeallocObservable is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x10586a5d8) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cbb4a8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_F7515DBB13B60709A3CB25DD19EDD11D11KVOObserver is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105865f18) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb5178). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_1D7F28C0BC36C8B8C7CB8510607FD1E238CollectionViewPrefetchDataSourceNotSet is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105866088) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb52e8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_2ADB08E9160D445433E8E5D8F8310FA330CollectionViewDataSourceNotSet is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x1058664d0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb5730). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoa40_RxCollectionViewReactiveArrayDataSource is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105867090) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb62f0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_FB4C281AAF6E1668013116978721EA1626PickerViewDataSourceNotSet is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105867570) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb67d0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_66BD5B10906B2163BD624F723B1A5D1633TableViewPrefetchDataSourceNotSet is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105867db0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb7010). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoaP33_06826BEE2B81AAA313DB990EB530417025TableViewDataSourceNotSet is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105867f60) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb71c0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoa35_RxTableViewReactiveArrayDataSource is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105868b40) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb7da0). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoa8RxTarget is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105868c48) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb7ea8). One of the two will be used. Which one is undefined.
objc[4264]: Class _TtC7RxCocoa19BarButtonItemTarget is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105869c68) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb8ec8). One of the two will be used. Which one is undefined.
objc[4264]: Class _RXDelegateProxy is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105865bf0) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb8fa8). One of the two will be used. Which one is undefined.
objc[4264]: Class _RXKVOObserver is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105865c40) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb8ff8). One of the two will be used. Which one is undefined.
objc[4264]: Class RXObjCRuntime is implemented in both /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxCocoa.framework/RxCocoa (0x105865c90) and /Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9048). One of the two will be used. Which one is undefined.
failed to demangle superclass of MapSink from mangled name '\317e': subject type x does not conform to protocol ObserverType
2022-09-20 22:10:04.931124+0900 RxSwiftSPMCocoaPodsTest[4264:41317] failed to demangle superclass of MapSink from mangled name '\^B\M-Oe\^A': subject type x does not conform to protocol ObserverType
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode 13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/User/Library/Developer/Xcode/DerivedData/RxSwiftSPMCocoaPodsTest-hgwlqgdvymgcpxajschhyrvtzgfh/Build/Products/Debug-iphonesimulator:/Applications/Xcode 13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode 13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode 13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode 13.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/User/Library/Developer/Xcode/DerivedData/RxSwiftSPMCocoaPodsTest-hgwlqgdvymgcpxajschhyrvtzgfh/Build/Products/Debug-iphonesimulator:/Users/User/Library/Developer/Xcode/DerivedData/RxSwiftSPMCocoaPodsTest-hgwlqgdvymgcpxajschhyrvtzgfh/Build/Products/Debug-iphonesimulator/PackageFrameworks
failed to demangle superclass of MapSink from mangled name '�e': subject type x does not conform to protocol ObserverType
CoreSimulator 857.7 - Device: iPhone 13 Pro (8BC993D9-EE0E-4E00-9159-97157543F704) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
(lldb) 

とりあえず一番最後のログを読んで見る

クラッシュの一番最後に書いてあるログを見ると下記のように書いてあるため、'�e' が ObserverTypeを継承しているかよくわからないのでクラッシュしているらしいということがわかります。

failed to demangle superclass of MapSink from mangled name '�e': subject type x does not conform to protocol ObserverType
CoreSimulator 857.7 - Device: iPhone 13 Pro (8BC993D9-EE0E-4E00-9159-97157543F704) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro

とりあえず、一番上のログを読んで見る

一番上のログには下記のように書かれています

objc[4264]: 
Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable is implemented in both 
/Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37970) 
and
/Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9218). 

One of the two will be used. Which one is undefined.

和訳するとこんな感じ

Class _TtC7RxSwiftP33_AB3B9E8806A71B46FB498A7594F5E0D919AnonymousDisposable が下記2箇所で実装されています
/Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/Frameworks/RxSwift.framework/RxSwift (0x105f37970) 
と、
/Users/User/Library/Developer/CoreSimulator/Devices/8BC993D9-EE0E-4E00-9159-97157543F704/data/Containers/Bundle/Application/47E61C67-B9EE-4A31-848D-2A4CE533C59C/RxSwiftSPMCocoaPodsTest.app/RxSwiftSPMCocoaPodsTest (0x104cb9218)
です。

2つのうち1つが利用され、どちらかが未定義になります

とのことです。

Prefixがついていますが、ここで言及されている AnnonymousDisposable はRxSwiftではここのように定義されています

この定義が「未定義」になる、そのため、前段のような型が定義されているかよくわかりません、というエラーが起きているようです

対応方法

Xcodeプロジェクトの構成を下記のようにし、プロジェクトから直接RxSwiftに依存させることで対応可能です。

このようにすることで、CocoaPodsでの2重Frameworkの定義がなくなるため、前述の問題が発生しなくなります。

終わりに

現在SwiftPackageを利用してアプリのコア機能をマルチモジュール化しているプロジェクトを進めていますが、思わぬところで落とし穴にハマりました。

同様の状態になられた方には参考にしていただけますと幸いです。

Discussion