SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

Missing required module 'SDWebImage' when using an XCFramework deployed through spm with dependencies

Open Yoojin99 opened this issue 10 months ago • 0 comments

Hi, all.

I have a xcframework that has a dependency on 'SDWebImageSwiftUI'. I deployed it through SPM, and I downloaded it with SPM in another project.

When I build it, it shows 'Missing required module 'SDWebImage'' error at the xcframework's swiftinterface file.

Below picture is a swiftinterface file of my xcframework.

Image

Steps to reproduce

  1. Create project that depends on 'SDWebImageSwiftUI'.
  2. Create xcframework from that project.
xcodebuild archive \
    -workspace SimpleFramework.xcworkspace \
    -scheme "SimpleFramework" \
    -destination "generic/platform=iOS" \
    -archivePath "./SimpleFramework-iphoneos.xcarchive" \
    -sdk iphoneos \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -workspace SimpleFramework.xcworkspace \
    -scheme "SimpleFramework" \
    -archivePath "./SimpleFramework-iphonesimulator.xcarchive" \
    -sdk "iphonesimulator" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild -create-xcframework \
    -framework "./SimpleFramework-iphoneos.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \
    -framework "./SimpleFramework-iphonesimulator.xcarchive/Products/Library/Frameworks/SimpleFramework.framework" \
    -output "./SimpleFramework.xcframework"
  1. Embed xcframework in Swift package and deploy.
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "SimplePackage",
    platforms: [.iOS(.v16)],
    products: [
        .library(
            name: "SimplePackage",
            targets: ["SimplePackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/SDWebImage/SDWebImageSwiftUI", from: "3.1.3"),
    ],
    targets: [
        .binaryTarget(
            name: "SimpleFramework", // My Framework that has dependency on SDWebImageSwiftUI
            path: "Sources/SimpleFramework.xcframework"
        ),
        .target(
            name: "SimplePackage",
            dependencies: [
                "SimpleFramework",
                
                "SDWebImageSwiftUI"

            ]
        )
    ]
)
  1. Download swift package from another project and import my framework.

I've checked 'SDWebImage' is downloaded. How can I fix this? Is there anything wrong with the setup? I also tried adding depdency of 'SDWebImage' in Package.swift file, but error remains same.

Image

Yoojin99 avatar Mar 13 '25 06:03 Yoojin99