apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.21k stars 87 forks source link

PlatformChecks emits error when compiling for MacCatalyst #523

Closed lennartkerkvliet closed 3 months ago

lennartkerkvliet commented 3 months ago

Description

When attempting to compile the Swift OpenAPI Generator on MacCatalyst, code that compiles perfectly on iOS will not run as it will fail on the PlatformChecks. This is unexpected.

Reproduction

Use the same instructions as used in https://developer.apple.com/wwdc23/10171 but enable the MacCatalyst target in the project settings. The project will compile fine for iOS but when targeting mac, the following error will be emitted:

OpenAPIGeneratorCore is only to be used by swift-openapi-generator itself—your target should not link this library or the command line tool directly.

Package version(s)

1.2.0

Expected behavior

I would have expected this to work fine without extra adjusments.

Environment

macOS Sonoma Xcode 15.2

Additional information

I suspect that it has to do with the behaviour of MacCatalyst. When compiling the app normally targetEnvironment(macCatalyst) will be true while os(macOS) will be false which is already confusing by itself but with good reason. Perhaps the build tool plug-in is ran in a similar environment?

It looked like from my limited testing that when disabling this check it will not include the runtime, so the setup should be correct.

czechboy0 commented 3 months ago

Hi @lennartkerkvliet,

yeah that's possible, I don't believe we've tested this with macCatalyst. Would you be willing to open a PR fixing the issue? 🙏

simonjbeaumont commented 3 months ago

@lennartkerkvliet thanks for filing the issue and for the contribution!

It should now be available in the 1.2.1 release: https://github.com/apple/swift-openapi-generator/releases/tag/1.2.1