Search code examples
iosswiftopenapiswift-package-managerxcode-cloud

How to Fix 'OpenAPIGenerator is Disabled' Error in Xcode Cloud?


I'm using SPM in my project and am trying to integrate Apple/swift-openapi-generator. My project is divided into several modules, for which I'm using SPM. To manage dependencies, I have a Package.swift file:

// swift-tools-version:5.8

import Foundation
import PackageDescription

let openAPIRuntime = Target.Dependency.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime")
let openAPIURLSession = Target.Dependency.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession")
let openAPIGenerator = Target.PluginUsage.plugin(name: "OpenAPIGenerator", package: "swift-openapi-generator")

let targets: [Target] = [
    .target(
        name: "OpenAPIClient",
        dependencies: [openAPIRuntime, openAPIURLSession],
        plugins: [openAPIGenerator]
    ),
    //...
    ]

let package = Package(
    name: "Modules",
    platforms: [.iOS("16.0"), .macOS(.v11)],
    products: targets.filter { !$0.isTest }.map { .library(name: $0.name, targets: [$0.name]) },
    dependencies: [
        .package(url: "https://github.com/apple/swift-openapi-generator", from: "0.1.0"),
        .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
        .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
        //...
    ],
    targets: targets
)

As demonstrated, I've added openAPIRuntime and openAPIURLSession products and the openAPIGenerator plugin to this file. As a result, I'm able to successfully build the project locally. However Xcode cloud fails with the following error message:

“OpenAPIGenerator” is disabled.

enter image description here

How to fix this issue?


Solution

  • The workaround is to add a file named ci_scripts/ci_post_clone.sh to your project, with the following content:

    #!/usr/bin/env bash
    set -euo pipefail
    
    defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES
    

    Check here fore more infos about custom build scripts.