'How can I define more than 1 framework for a platform target in 1 single XCFrameworks?

I want to know how can I define 2 deferent Framework's for same platform and make 1 single XCFramework of it?

For example I define a iOSSimulator framework and user can access EmojiView() which is a simple view after importing the CustomXCFramework.

like this:

Import SwiftUI
Import CustomEmoji // ---> from CustomXCFramework

struct ContentView: View {
    var body: some View {
        EmojiView() // ---> from CustomEmoji
    }
}

So here is the question: As you can see I used CustomEmoji from CustomXCFramework, let say I want include another custom code to CustomXCFramework which give another custom view called MyView(), so I need to know how I can build my XCframework to make this possible:

Import SwiftUI
Import CustomEmoji // ---> from CustomXCFramework
Import CustomView  // ---> from CustomXCFramework

struct ContentView: View {
    var body: some View {
        EmojiView() // ---> from CustomEmoji
        MyView()    // ---> from CustomView
    }
}

I do not want MyView be accessible from CustomEmoji that is the why I am trying to use CustomView, also I do not want use 2 deferent XCFramework for them as well. I watched WWDC 19-20 video's about it, they say it is possible but they did not showed an example to make it.

So what I tried was trying to build the XCFramework that contain that 2 framework, but Xcode does not build and make error in Terminal, and say more than 1 framework found for same platform!!!

 xcodebuild -create-xcframework \
-framework ~/Desktop/Emoji_iOS_iOSSimulator.xcarchive/Products/Library/Frameworks/Emoji_iOS.framework \
-framework ~/Desktop/CustomView_iOS_iOSSimulator.xcarchive/Products/Library/Frameworks/CustomView_iOS.framework \
-output ~/Desktop/CustomXCFramework.xcframework

Terminal Error:

A library with the identifier 'ios-arm64_x86_64-simulator' already exists.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source