OpenAPIGenerator package requirements have a dependency that causes errors

Trying to utilize the new OpenAPI Generator, but after following all of the steps exactly as stated in the video, I get the following errors:

- The package product 'SwiftSyntax' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0

- The package product 'SwiftSyntaxBuilder' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0

- The package product 'SwiftFormat' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0

- The package product 'SwiftFormatConfiguration' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0

under both _OpenAPIGeneratorCore and swift-openapi-generator

I've seen other things online where people have had similar issues, but the fixes haven't been particularly relevant that I could tell.

Accepted Reply

This is likely because you're linking the generator target itself to the iOS app, which is not supported. See Step 7 of https://swiftpackageindex.com/apple/swift-openapi-generator/0.1.3/tutorials/swift-openapi-generator/clientxcode#Configuring-your-target-to-use-the-Swift-OpenAPI-Generator-plugin, which clarifies that the checkboxes to link the generator targets (_OpenAPIGeneratorCore and swift-openapi-generator) should not be linked directly, they're only meant to be used through the plugin.

Only the OpenAPIRuntime and any transport libraries are meant to be linked to your app.

Here is an issue tracking improving the errors when this happens: https://github.com/apple/swift-openapi-generator/pull/87

A way to fix it is: in Xcode, go to the Project Editor -> select your app target -> go to Build Phases -> expand Link Binary with Libraries, and remove _OpenAPIGeneratorCore and swift-openapi-generator. Then try to build again.

  • I'll try that once I get beta 2 installed, thank you so much!

  • You don't have to wait for the new beta, the solution above should work with any recent Xcode.

  • This seems to have worked but I'm having several other issues that are preventing me from knowing for sure. Once I know I'll mark this as correct! Thank you!

Add a Comment

Replies

Are you actually trying to build code that supports all the way back to iOS 12?

Share and Enjoy

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

  • Definitely not, I have my deployment set to 17.0.

  • I should also clarify that the only dependencies I'm currently using are those recommended in the video, namely:

    URLSessionTransportOpenAPIGenerator RuntimeOpenAPIGenerator Plugin

    so I suspect that one of the dependencies loaded by these are the culprit, but I can't tell which one or how I would fix that even if/when I do find it.

Add a Comment

I should also clarify that the only dependencies I'm currently using are those recommended in the video, namely:

so I suspect that one of the dependencies loaded by these are the culprit, but I can't tell which one or how I would fix that even if/when I do find it.

Is your final product a package built with Swift package manager? Or are you trying to use the OpenAPI stuff from an Xcode project?

Share and Enjoy

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

  • How to integrate openapi generator in a package built with Swift package monitor is what I need. Can you please integrate in the docs an example of a Package.swift file. So far I get build failure message:

    Multiple commands produce '..../OpenAPIGenerator/GeneratedSources/Types.swift'

Add a Comment

This is likely because you're linking the generator target itself to the iOS app, which is not supported. See Step 7 of https://swiftpackageindex.com/apple/swift-openapi-generator/0.1.3/tutorials/swift-openapi-generator/clientxcode#Configuring-your-target-to-use-the-Swift-OpenAPI-Generator-plugin, which clarifies that the checkboxes to link the generator targets (_OpenAPIGeneratorCore and swift-openapi-generator) should not be linked directly, they're only meant to be used through the plugin.

Only the OpenAPIRuntime and any transport libraries are meant to be linked to your app.

Here is an issue tracking improving the errors when this happens: https://github.com/apple/swift-openapi-generator/pull/87

A way to fix it is: in Xcode, go to the Project Editor -> select your app target -> go to Build Phases -> expand Link Binary with Libraries, and remove _OpenAPIGeneratorCore and swift-openapi-generator. Then try to build again.

  • I'll try that once I get beta 2 installed, thank you so much!

  • You don't have to wait for the new beta, the solution above should work with any recent Xcode.

  • This seems to have worked but I'm having several other issues that are preventing me from knowing for sure. Once I know I'll mark this as correct! Thank you!

Add a Comment