Adding EXCLUDED_ARCHS settings in Package.swift

Hi guys!
I need to add the following build settings option:

EXCLUDED_ARCHS[sdk=iphonesimulator*]=arm64

I tried using the following option:

// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "IndomioCore",
    platforms: [
        .iOS(.v14)
    ],
    products: [
        .library(
            name: "IndomioCore",
            targets: ["IndomioCore"])
    ],
    dependencies: [
    	.package(name: "IndomioCommons", path: "../IndomioCommons"),
    ],
    targets: [
        .target(
            name: "IndomioCore",
            dependencies: [
                .product(name: "IndomioCommons", package: "IndomioCommons"),
            ],
            swiftSettings: [
                .define("EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64")
            ]
        )
    ]
)

but it does not work, it does not appear. What I'm missing?
Thanks

EXCLUDED_ARCHS is an Xcode-specific build setting, SwiftPM has no support for setting it. In contrast, the defines API is a way for passing a -D flag to the Swift compiler.

If you pass overriding build settings to xcodebuild, those will apply to packages as well, so that might be a way to do what you're trying to do, but I am not sure if that supports conditionals and also it won't apply to builds in the Xcode IDE.

Is this still the case @NeoNacho? One of the framework that my library depends on doesn’t support x86_64 simulator. When distributing my library, I can provide config in my podspec:

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => '$(inherited) x86_64' }

to prevent x86_64 build being picked up by Xcode, in case of ONLY_ACTIVE_ARCH is set as NO. Is there no such alternative for SPM other that app developers having to modify these flag on their application target?

1 Like