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 Swift wrapper #96

Closed
wants to merge 7 commits into from
Closed

Add Swift wrapper #96

wants to merge 7 commits into from

Conversation

conanoc
Copy link
Contributor

@conanoc conanoc commented Feb 10, 2023

This is a PR to add a Swift wrapper.

  • Modified cbindgen.toml to generate types created with macro. (Fix cbindgen does not generate some types #99)
  • Others are Swift wrapper codes.
  • Note: A Swift package requires the xcframework binary to be uploaded somewhere, so I uploaded it to aries-framework-swift repo. This Swift package will be hosted by this repo, but the xcframework binaries can be hosted by any repo.

Signed-off-by: conanoc <[email protected]>
@conanoc
Copy link
Contributor Author

conanoc commented Feb 14, 2023

Can you review this PR @blu3beri @andrewwhitehead ?

Copy link
Contributor

@berendsliedrecht berendsliedrecht left a comment

Choose a reason for hiding this comment

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

Some minor notes, but mainly the header generation code is important as the next time its generated all the changed will be reverted.

I am not a Swift developer so I did not review the swift code in here :).

@@ -125,7 +127,7 @@ cp ../../$HEADER_PATH/$HEADER_NAME Headers/$FRAMEWORK_LIBRARY_NAME.h
mkdir Modules
touch Modules/module.modulemap
cat <<EOT >> Modules/module.modulemap
framework module $FRAMEWORK_LIBRARY_NAME {
framework module $FRAMEWORK_MODULE_NAME {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changed? I am not too familiar with the module.modulemap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the name of the module used in Objective-C or Swift. I want it to be imported with the name "AriesFramework" instead of "aries_askar". See https://github.com/conanoc/aries-askar/blob/swift_pr/wrappers/swift/Askar/Sources/Askar/Crypto.swift#L2
It's the convention in Swift, and this will not affect other languages.

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 was wrong. Swift does not seem to consult this module name when importing a framework. I'll rollback this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -7,7 +7,7 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a generated file so if something changes here we should make sure that cbindgen generates the file with these changes as this will be overwritten when a new header is generated. Could you make it gets generated with your changes?

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'm not sure if it's possible. I've created an issue (#99) to track this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dependencies: ["Askar"]),
.binaryTarget(
name: "AskarFramework",
url: "https://github.com/hyperledger/aries-framework-swift/releases/download/binary-release-askar-v0.2.7/AskarFramework.xcframework.zip",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this url definitive? There is already an xcframework on the releases of this library. Maybe in the future it can just use that one (right now it also includes Android builds though).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This link should be changed later. I'm thinking of adding a workflow job for this.

@conanoc
Copy link
Contributor Author

conanoc commented Feb 22, 2023

@andrewwhitehead I get the following error on pg_test. What should I do?

error: package csv v1.2.0 cannot be built because it requires rustc 1.60 or newer, while the currently active rustc version is 1.58.0

@andrewwhitehead
Copy link
Member

The build issue should be fixed by #102

@conanoc
Copy link
Contributor Author

conanoc commented Feb 24, 2023

@andrewwhitehead Could you merge this and #102 PR?

@conanoc
Copy link
Contributor Author

conanoc commented Mar 6, 2023

I extracted part of this PR to #110 and I'll close this.

@conanoc conanoc closed this Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cbindgen does not generate some types
3 participants