trinhngocthuyen / cocoapods-spm

A CocoaPods plugin to add SPM dependencies to CocoaPods-based projects
MIT License
53 stars 10 forks source link

[Bug] can not use 'MessageKit', #95

Closed gongxiaokai closed 5 months ago

gongxiaokai commented 5 months ago

What happened?

When using spm_pkg "MessageKit", :git => "https://github.com/MessageKit/MessageKit.git", :tag => "4.2.0" an error occurs: MessageKit/resource_bundle_accessor.swift:44: Fatal error: unable to find bundle named MessageKit_MessageKit Below is the part of the code located by the breakpoint:

extension Foundation.Bundle {
    /// Returns the resource bundle associated with the current Swift module.
    static let module: Bundle = {
        let bundleName = "MessageKit_MessageKit"

        let overrides: [URL]
        #if DEBUG
        // The 'PACKAGE_RESOURCE_BUNDLE_PATH' name is preferred since the expected value is a path. The
        // check for 'PACKAGE_RESOURCE_BUNDLE_URL' will be removed when all clients have switched over.
        // This removal is tracked by rdar://107766372.
        if let override = ProcessInfo.processInfo.environment["PACKAGE_RESOURCE_BUNDLE_PATH"]
                       ?? ProcessInfo.processInfo.environment["PACKAGE_RESOURCE_BUNDLE_URL"] {
            overrides = [URL(fileURLWithPath: override)]
        } else {
            overrides = []
        }
        #else
        overrides = []
        #endif

        let candidates = overrides + [
            // Bundle should be present here when the package is linked into an App.
            Bundle.main.resourceURL,

            // Bundle should be present here when the package is linked into a framework.
            Bundle(for: BundleFinder.self).resourceURL,

            // For command-line tools.
            Bundle.main.bundleURL,
        ]

        for candidate in candidates {
            let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
            if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
                return bundle
            }
        }
        fatalError("unable to find bundle named MessageKit_MessageKit")
    }()
}

some logs: candidates = [ file:///private/var/containers/Bundle/Application/77FFEB30-6CA7-4DB3-B33D-8E6957598BE9/DemoApp.app/, file:///private/var/containers/Bundle/Application/77FFEB30-6CA7-4DB3-B33D-8E6957598BE9/DemoApp.app/, file:///private/var/containers/Bundle/Application/77FFEB30-6CA7-4DB3-B33D-8E6957598BE9/DemoApp.app/ ]

CocoaPods environment

cocoapods (1.15.2, 1.12.1, 1.11.3) cocoapods-core (1.15.2, 1.12.1, 1.11.3) cocoapods-deintegrate (1.0.5) cocoapods-downloader (2.1, 1.6.3) cocoapods-plugins (1.0.0) cocoapods-search (1.0.1) cocoapods-spm (0.1.4, 0.1.1) cocoapods-trunk (1.6.0) cocoapods-try (1.2.0)

Anything else?

No response

trinhngocthuyen commented 5 months ago

Sorry for the late response. The issue should be fixed by #96. Kindly help try again with the latest on main. Thanks for reporting the issue!