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(jans-cedarling): create uniffi binding for cedarling with sample ios app using it #10816

Merged
merged 26 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b53e0fd
feat: initial commit for ios binding
duttarnab Feb 9, 2025
5a37e67
feat: commiting remaining files
duttarnab Feb 9, 2025
55aa63d
feat: pushing uniffi-bindgen.rs file
duttarnab Feb 9, 2025
6265650
feat: adding Gluu's copyright and software license
duttarnab Feb 9, 2025
38e73ab
feat: adding android section in README
duttarnab Feb 10, 2025
c7a1ae9
feat: restoring python binding
duttarnab Feb 10, 2025
c981cd5
feat: update README and add fix to prevent WASM test failure
duttarnab Feb 11, 2025
63121bb
feat: correct typo in README
duttarnab Feb 11, 2025
00ad00d
feat: resolving review comments
duttarnab Feb 16, 2025
e3c4099
feat: resolving review comments
duttarnab Feb 16, 2025
d0e1f76
feat: adding uniffi binding docs
duttarnab Feb 16, 2025
b0d1f64
feat: adding uniffi binding docs
duttarnab Feb 16, 2025
de0997d
feat: adding missing files
duttarnab Feb 16, 2025
42b6747
feat: remove unused imports
duttarnab Feb 16, 2025
c52bb5c
feat: add demo video in docs
duttarnab Feb 16, 2025
6572058
feat: correct typo
duttarnab Feb 16, 2025
b61ed3f
fix: export uniffi::uniffi_bindgen_main
duttarnab Feb 17, 2025
b9b1556
fix: export uniffi::uniffi_bindgen_main
duttarnab Feb 17, 2025
deae330
fix: fixing wasm build error
duttarnab Feb 17, 2025
af9dfe3
fix: fixing wasm build error
duttarnab Feb 17, 2025
9966c04
feat: adding title to logs
duttarnab Feb 17, 2025
989d8ea
feat: resolving clippy error about missing function
duttarnab Feb 18, 2025
65cf3b0
feat: resolving clippy error about missing function
duttarnab Feb 18, 2025
0a6d218
feat: resolving clippy error about missing function
duttarnab Feb 18, 2025
7ea6a3b
Merge branch 'main' into jans-cedarling-issue-9432_2
duttarnab Feb 18, 2025
66d11b8
feat: resolving clippy error about empty line above main function
duttarnab Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jans-cedarling/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ docs/_build/

# Pyenv
.python-version

# allow commit of cedarling_native_apps bindings
!/bindings/cedarling_native_apps/src/bin
23 changes: 23 additions & 0 deletions jans-cedarling/bindings/cedarling_native_apps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "cedarling_native_apps"
version = "0.1.0"
edition = "2021"

[lib]
crate_type = ["cdylib", "staticlib"]
name = "mobile"

[dependencies]
Copy link
Contributor

@olehbozhok olehbozhok Feb 10, 2025

Choose a reason for hiding this comment

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

To avoid error in compile wasm tests you can use

# dependency for NOT wasm target
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

instead of [dependencies] like here

and don't forget to add this in lib.rs

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

cedarling = { workspace = true, features = ["blocking"]}
jsonwebtoken = "9.3.0"
openssl = { version = "0.10.35", features = ["vendored"] }
once_cell = "1.20.2"
uniffi = { version = "0.29.0", features = [ "cli" ] }
uniffi_macros = "0.29.0" # Procedural macros support
serde = { workspace = true }
serde_json = { workspace = true }
thiserror.workspace = true

[dev-dependencies]
# is used in testing
test_utils = { workspace = true }
55 changes: 55 additions & 0 deletions jans-cedarling/bindings/cedarling_native_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Cedarling Native Apps

This module is designed to build cedarling bindings for iOS and android apps.

## iOS

### Building

1. Build the library:

```bash
cargo build
```

In target/debug, you should find the libmobile.dylib file.

2. Generate the bindings:

```bash
cargo run --bin uniffi-bindgen generate --library ./target/debug/libmobile.dylib --language swift --out-dir ./bindings/cedarling_native_apps/output
```

3. Building the iOS binaries and adding these targets to Rust.

```bash
rustup target add aarch64-apple-ios-sim aarch64-apple-ios
```

4. Build the library for Swift.

```bash
cargo build --release --target=aarch64-apple-ios-sim
cargo build --release --target=aarch64-apple-ios
```

You should have two binaries target/aarch64-apple-ios-sim/release/libmobile.a and target/aarch64-apple-ios/release/libmobile.a.

5. The XCFramework will allow us to import the library with zero effort in Xcode. First, we need to rename the file ./bindings/cedarling_native_apps/output/mobileFFI.modulemap to ./bindings/cedarling_native_apps/output/module.modulemap.

Then, we can create the XCFramework:

```bash
xcodebuild -create-xcframework \
-library ./target/aarch64-apple-ios-sim/release/libmobile.a -headers ./bindings/cedarling_native_apps/output \
-library ./target/aarch64-apple-ios/release/libmobile.a -headers ./bindings/cedarling_native_apps/output \
-output "ios/Mobile.xcframework"
```

6. Open ./jans-cedarling/bindings/cedarling_native_apps/iOSApp in Xcode. Import both the XCFramework Mobile.xcframework and the Swift file bindings bindings/Mobile.swift files into your project (drag and drop should work).

7. Run iOS project on simulator.

## Android

- WIP...
62 changes: 62 additions & 0 deletions jans-cedarling/bindings/cedarling_native_apps/iOSApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
Loading
Loading