Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swift5): allow to swift build in linux #15060

Merged
merged 4 commits into from
Aug 12, 2023

Conversation

gierschv
Copy link
Contributor

@gierschv gierschv commented Mar 27, 2023

This PR adds the import of FoundationNetworking to the swift 5 templates so we can build the generated code in linux machines & CI.

I noticed that Alamofire recently released to added the linux as well, so it's great to be able to test in our linux CI if the generated code actually builds and has no syntax error (that happens sometimes).

docker run --rm -v $(pwd):/app -it swift:5.7-jammy bash -c "cd /app/samples/client/petstore/swift5/alamofireLibrary && swift build"

[...]
Build complete! (16.33s)

I'm not sure if this project have any Linux CI process to test the generated code, but we could add those swift build if any

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date.sh
    
    Commit all changed files.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Aug 2, 2023

@gierschv thanks for the PR. I wonder if you've time to setup a github workflow to test the Swift 5 petstore sample(s) similar to .github/workflows/samples-php8.yaml

This can help ensure the swift client built on linux as well as part of this PR.

@gierschv gierschv force-pushed the fix/swift-linux-build branch from 9a8de28 to bf9dff8 Compare August 7, 2023 20:09
@gierschv gierschv requested a review from jimschubert as a code owner August 7, 2023 20:21
@gierschv gierschv force-pushed the fix/swift-linux-build branch 7 times, most recently from 271a94c to e6d2c18 Compare August 7, 2023 20:45
@gierschv gierschv force-pushed the fix/swift-linux-build branch from 1a3e820 to 0458366 Compare August 7, 2023 21:36
@gierschv
Copy link
Contributor Author

gierschv commented Aug 7, 2023

@wing328 Sure, done!

I tried adding the CI for the other samples on OSX, but ran into some issues importing CoreServices and stuff around mime types (e.g. UTTypeCreatePreferredIdentifierForTag in URLSessionImplementations.swift) that seems to be proprietary on OSX/iOS - and looks like they need to have probably XCode installed. This code looks also a bit deprecated since iOS 15, but the new replacing code had the same build issue without XCode.

I ended up only sticking with adding AlamoFire in the CI that have the platform support for Linux.

@gierschv gierschv force-pushed the fix/swift-linux-build branch 7 times, most recently from aec9241 to deafc2b Compare August 8, 2023 08:31
@gierschv
Copy link
Contributor Author

gierschv commented Aug 8, 2023

@wing328 I think we are good to merge. The swift5 samples are now built on OSX + swift5/alamofireLibrary that is also built on ubuntu: https://github.com/OpenAPITools/openapi-generator/actions/runs/5794631894?pr=15060

Except swift5/vaporLibrary that I didn't put in the CI config for now as this doesn't even swift build for me on my macbook (on master or on this PR). That could be for another PR to fix this client implementation later if needed.

@gierschv gierschv force-pushed the fix/swift-linux-build branch from deafc2b to 7d09e81 Compare August 8, 2023 08:48
@wing328 wing328 added this to the 7.0.0 milestone Aug 12, 2023
@wing328
Copy link
Member

wing328 commented Aug 12, 2023

Agreed that issue has nothing to do with this PR.

Thanks for the PR, which has been merged.

Have a nice weekend.

@wing328 wing328 merged commit 604239a into OpenAPITools:master Aug 12, 2023
@gierschv gierschv deleted the fix/swift-linux-build branch August 12, 2023 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants