Versioning for packages that depend on packages that require -ObjC

Hi all,

I'm currently developing a Swift package that depends on a number of 3rd party frameworks (one example is Firebase) that require the -ObjC linker flag added to be linked correctly.

The problem is, when listing it as a dependency in the Package definition, when I add the -ObjC flag like this, I can no longer use resolution with actual version numbers and resort to branch based resolution.

.target(
    name: "FrameworkName",
    dependencies: [
        .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
        .......
        .......
    ],
    linkerSettings: [
        .unsafeFlags(["-ObjC"])
    ]
),

Is there a way to do this without using unsafeFlags? SPM is really problematic when it comes to updating private packages from our bitbucket account (it frequently fails to update these packages unless we reset the package caches), and not being able to use the version number makes it very difficult to determine whether it actually updated the package or not.

Doing a quick experiment, the following is respecting the version number of 8.15.0. What else is needed to replicate?

import PackageDescription

let package = Package(
    name: "MyTestPackage",
    products: [
        .library(
            name: "MyTestPackage",
            targets: ["MyTestPackage"]),
    ],
    dependencies: [
        .package(url: "https://github.com/firebase/firebase-ios-sdk.git", .upToNextMinor(from: "8.15.0")),
    ],
    targets: [
        .target(
            name: "MyTestPackage",
            dependencies: [
                .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
            ],
            linkerSettings: [
                .unsafeFlags(["-ObjC"])
            ]
        ),
    ]
)

I'm referring to the versioning of my package, not its dependencies.

Following your example, XCode doesn't allow me to add MyTestPackage as a dependency using version numbers as a dependency rule for non-development builds.

It forces me to select either branch or commit from the dependency rule options when adding the dependency to my app.

This is a related post made by someone else on SO.

I'm wondering if there is a solution other than a wrapper framework, which introduces its own set of problems.

1 Like

It doesn't solve your general problem, but recent 10.x versions of FirebaseAnalytics no longer require the usage of -ObjC

That's interesting, because they still include adding that flag among the integration steps. I'll try it though, if the other SDKs are in a similar state.