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

Add section on using library in Swift #26

Merged

Conversation

xtremekforever
Copy link
Contributor

@xtremekforever xtremekforever commented Jul 13, 2024

This adds some documentation on how to get started using the testcontainers-c library in Swift.

What does this PR do?

Describes with examples on how to setup a CTestContainers module in Swift that imports the testcontainers-c header and library, and shows off how to run the generic wiremock demo in Swift as well.

Why is it important?

Users of Swift may be interested in using this library in the future as it develops. This gives a good idea of how to use it without having to be an expert in C interop.

Related issues

N/A

How to test this PR

Follow the instructions in the Swift README at docs/swift/README.md to verify that the steps work correctly as described.

@xtremekforever
Copy link
Contributor Author

xtremekforever commented Jul 13, 2024

This is a starting point for documenting "Getting Started" with this library using Swift. The section is somewhat large, so I wonder if it wouldn't be better to include an entire demo project for Swift with this README content instead. Either way, let me know.

 - Contains a full working example that should work out of the box.
@xtremekforever xtremekforever force-pushed the feature/usage-in-swift branch from 0f85c92 to 3320745 Compare July 13, 2024 02:04
Copy link
Collaborator

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move it under docs/swift/README.md right away so that contributor history is not lost on the page. I am working on the document restructure and the MkDocs site, so I will incorporate it there

README.md Outdated

This module can then be imported and used from inside the application. However, the only challenge is dealing with C-style strings that are typically utf8 and are null terminated, so they require a bit of extra support for translation in Swift.

Here is the `generic-containers` demo translated into Swift, with an exstension to properly translate a `String` to a utf8 string for C:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it will get easier if we have a C++ binding header with std::string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that. Also, Swift has some decent C++ interop these days, so it would make things much smoother to have a C++ interface with std::string being used.

@oleg-nenashev
Copy link
Collaborator

@xtremekforever I will merge #27 once the build passes. If you could copy over the content to the Swift stub and reference it from README, it would be appreciated!

@xtremekforever
Copy link
Contributor Author

@oleg-nenashev updated the pull request with the latest from testcontainers-c main and moved all the content for Swift to docs/swift/README.md!

Copy link
Collaborator

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@oleg-nenashev oleg-nenashev merged commit 91cf47f into testcontainers:main Jul 14, 2024
2 checks passed
@oleg-nenashev oleg-nenashev added the documentation Improvements or additions to documentation label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants