SPM compiler flags passed to main app target

Linker flag specified in Package.swift as unsafe flag is passed to main app target. steps:

  1. create empty package and add linkerSettings: [.unsafeFlags(["-Wl,-make_mergeable"])] to target
import PackageDescription

let package = Package(
    name: "TestPackage",
    products: [
        // Products define the executables and libraries a package produces, making them visible to other packages.
        .library(
            name: "TestPackage",
            type: .dynamic,
            targets: ["TestPackage"]),
    ],
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .target(
            name: "TestPackage",
            linkerSettings: [.unsafeFlags(["-Wl,-make_mergeable"])]
        ),
        .testTarget(
            name: "TestPackageTests",
            dependencies: ["TestPackage"]),
    ]
)
  1. create empty Xcode iOS app project and add package to project via Add Files

3 add package as a framework dependency to the main app

in the result, build fails with error:

ld: -make_mergeable can only be used when creating a dynamic library

package itself builds with -mergable_library and that is fine

It sounds like your goal here is to report a bug. If so, the place to do that is Feedback Assistant. See Bug Reporting: How and Why? for a bunch of hints and tips on that topic.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

SPM compiler flags passed to main app target
 
 
Q