Console warnings when using a Swift Package in multiple projects in the same workspace

Hi All,

I've created a Swift Package with some shared code to be my core for some projects. I am creating an iOS app, so I have a workspace with the iOS app project in it. The core package is a remote dependency of the app. At this point, everything is setup and working great.

I've created a new framework project to add to the same workspace. I wanted to do another Swift Package, but I need some assets, so I'm doing a framework for now until SPM works with assets. I also need some of the core functionality in this framework, so I added the package as a dependency to it as well. The framework is then linked to the iOS app project.

At this point, everything builds fine, and I can use code from core in both the app and framework projects. I can also use code from the framework in the app. However, when I build and run in the simulator, I get console warnings about some of the classes in the core being implemented multiple times and which one being used is undefined.

The app still works properly, so it seems it's just the console output that is the issue. The two classes being warned are set to internal in the package. All the public objects seem to be fine. Is there a proper way to link the dependency between the framework and app to make things continue to work properly but without the console warnings?

Thanks

Having similar problem in my app, but in my scenario, it is crashing when I run my unit tests. Current situation is I have project A that has a dependency to a third-party framework that I'm using SPM for it. Then I have another framework in my workspace, framework B, that has dependencies to both A and third-party framework. When I build I get:

Class Foo is implemented in both A and third-party-framework. One of the two will be used. Which one is undefined.

If I remove third-party framework from my B project SPM list, then everything works fine. I'm trying to also see if there's any way to force Xcode to use the dynamic version of the framework so I can prevent issues like this in my other dependencies. I found following line in SPM repo:

    /// Create a library product to allow clients that declare a dependency on this package
    /// to use the package's functionality.
    ///
    /// A library's product can either be statically or dynamically linked.
    /// If possible, don't declare the type of library explicitly to let 
    /// the Swift Package Manager choose between static or dynamic linking based
    /// on the preference of the package's consumer.
    ///
    /// - Parameters:
    ///     - name: The name of the library product.
    ///     - type: The optional type of the library that is used to determine how to link to the library.
    ///         Leave this parameter unspecified to let to let the Swift Package Manager choose between static or dynamic linking (recommended).
    ///         If you do not support both linkage types, use `.static` or `.dynamic` for this parameter. 
    ///     - targets: The targets that are bundled into a library product.
    public static func library(name: String, type: PackageDescription.Product.Library.LibraryType? = nil, targets: [String]) -> PackageDescription.Product

However, I couldn't find any examples or a way to force using dynamic framework in both Xcode 11 beta 7 or through command line.

Terms of Service

Privacy Policy

Cookie Policy