3

Problem

I am developing a Framework (let's name it MyFramework) which I want to use in a host iOS application. MyFramework depends on several other 3rd party libraries (Alamofire, ZIPFoundation, etc.) which I have added as Swift Package Manager dependencies in the MyFramework project.

After creating MyFramework.xcframework and adding it to the host iOS application, I get a compilation error saying No such module 'Alamomfire'. As suggested in this thread I have added Alamofire as SPM dependency in the host iOS Application as well, which resolves the compilation error. But during runtime I get a console message saying Class _TtC9Alamofire21CompositeEventMonitor is implemented in both <HOME>/Library/Developer/Xcode/DerivedData/DevSample-frwzbtlatwjedobzfossixhbtork/Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework (0x10346eb98) and <HOME>/Library/Developer/CoreSimulator/Devices/D17DA122-DB76-4447-B8FD-14FC8405A856/data/Containers/Bundle/Application/F68CBE06-CC7F-40AA-ACA8-2210048CA495/DevSample.app/DevSample (0x102ed31f8). One of the two will be used. Which one is undefined.

Questions

Is this expected behavior? As mention in this Apple Doc creating Umbrella Frameworks is discouraged. How to get rid of those runtime warnings/errors then?

Janakan
  • 61
  • 2
  • 1
    Xcframework is used usually when you have binary code with headers, so that wrapping it in a Xcframework you can include it in your target. You could try a normal framework (New:Project:Framework) as the container framework. To avoid "is implemented in both..", make sure that the transitive dependencies ARE NOT embedded in your container framework, but embedded on the app target only. – Sardorbek Ruzmatov Jun 11 '21 at 15:56
  • 1
    @SardorbekRuzmatov could you please provide a sample project or explain it a little bit in more detail? – Nominalista Jun 13 '21 at 09:19

1 Answers1

0

@Nominalista I have created a similar app-and-modules setup in this way: I created the app, and the framework within the same directory, and then I dragged this framework's .xcodeproj inside my app. Inside the framework, I have added Swift packages as Alamofire, ZIPFoundation. I can use either of these 2 transitive dependencies both from the framework itself, and the app target as well with a simple ie, "import Alamofire".

I am using Xcode 12.5 and I am explicitly adding Alamofire as Swift package both to the framework and the app, I am not getting "..is implemented in both..." warnings. So can I ask you how your project is being setup?