Search code examples
swiftxcodeswift-package-managertuist

Specify build build settings for dependencies in Tuist 4


In Tuist 4 the system has changed and instead of Dependencies.swift the developer is supposed to use the SPM (Package.swift; swift package manager) to generate the Xcode project.

In Dependencies.swift there was a way to specify additional build settings for third-party dependencies like this:

targetSettings: [
    "CrashReporter": ["USE_HEADERMAP": "YES"]
]

Now that this approach has been replaced by SPM, how can I set the same settings on this target? When done manually in Xcode all works (as per screenshot below) but this needs to be generated by Tuist 4. enter image description here


Solution

  • You can do that with the Package.swift that suppose to replace the Dependencies.swift.

    TL;DR

    // swift-tools-version: 5.10
    import PackageDescription
    
    #if TUIST
        import ProjectDescription
        import ProjectDescriptionHelpers
    
        let packageSettings = PackageSettings(
            targetSettings: [
               "CrashReporter": ["USE_HEADERMAP": "YES"]
            ],
            projectOptions: [
                "LocalSwiftPackage": .options(disableSynthesizedResourceAccessors: false),
            ]
        )
    
    #endif
    
    let package = Package(
        name: "PackageName",
        dependencies: [
            .package(url: "https://github.com/Alamofire/Alamofire", exact: "5.8.0"),
    .....
    

    The fixtures folder under the tuist GitHub project has so many examples - specific here is the one with spm and how to set those settings