No such module 'FrameworkName' when archive

I'm trying to using SwiftPM to instead Cocoapods in my project.
but I got an error: No such module 'SFS2XAPIIOS'.
This error only occurs when I archive.

Here is my Package.swift:
Code Block
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
    name: "Test",
    platforms: [.iOS(.v10)],
    products: [
        .library(
            name: "Test",
            targets: ["Test", "SFS2XAPIIOS"]),
    ],
    dependencies: [
    ],
    targets: [
        .target(
            name: "Test",
            dependencies: [
            ],
            path: "Paht"
        ),
        .binaryTarget(name: "SFS2XAPIIOS", path: "Paht/SFS2XAPIIOS.xcframework"),
        .testTarget(
            name: "TestTests",
            dependencies: ["Test"]),
    ]
)



I have added Test Package to the project.
When I use the Debug environment, I can run the project from anywhere.
I can run the project from anywhere, including iPhone devices and x86 emulators.
When I trying to archive, I will always get an error: No such module 'SFS2XAPIIOS'

Can someone help me fix it?
Any ideas? I have the same problem.
I was able to fix it by separating the xcframework to its own Swift Package

Code Block swift
let package = Package(
    name: "TheLibrary",
    products: [
        .library(name: "TheLibrary", targets: ["TheLibrary"]),
    ],
    dependencies: [],
    targets: [
        .binaryTarget(name: "TheLibrary", path: "Sources/TheLibrary.xcframework")
    ]
)


and then including as a dependency in main project.

Code Block swift
let package = Package(
    name: "MainProject",
    platforms: [.iOS(.v11), .macOS(.v10_15)],
    products: [
        .library(name: "MainProject", targets: ["MainProject"])
    ],
    dependencies: [
        .package(url: "../TheLibrary", from: "1.0.0")
    ],
    targets: [
        .target(
            name: "MainProject",
            dependencies: [
                "TheLibrary"
            ]
        )
    ]
)


I hope it helps!
No such module 'FrameworkName' when archive
 
 
Q