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.45k stars 120 forks source link

HTTPTypes linker error if multiple targets use open API generator #579

Closed smoser90 closed 4 months ago

smoser90 commented 5 months ago

Question

Hi,

I'm currently facing an issue if I want to build my project that contains two targets, which both are using open API generator. I always get HTTPType linker errors. If I remove one of those two targets from my project everything works as intended.

Each target has its own openapi-generator-config.yaml and openapi.yaml and both targets are used in the main project in different locations via import "TargetName"

Is there anything specific to be aware of if I want to use multiple targets?

Thanks in advance.

brg

Screenshot 2024-06-25 at 15 52 11
czechboy0 commented 5 months ago

Hi @smoser90,

you might need to explicitly depend on the HTTPTypes packages, for example see here: https://github.com/apple/swift-openapi-generator/blob/f6d37bb2fb6747ab5e3b5ff13d4befce91225999/Examples/auth-client-middleware-example/Package.swift#L24

smoser90 commented 4 months ago

Hi @czechboy0, thanks for your fast response. It kinda solved my issue. I had to apply it as library in every target then it worked