-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Sargon build, preparing for iOS example.
- Loading branch information
Showing
12 changed files
with
10,520 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
tarpaulin-report.html | ||
.vscode | ||
.idea | ||
.build | ||
build_rs_cov.profraw | ||
cobertura.xml | ||
jna-*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Swift | ||
|
||
## Build script | ||
Ah nevermind the build script in [uniffi-starter/../build-ios.sh](https://github.com/ianthetechie/uniffi-starter/blob/main/rust/build-ios.sh) already contained code to update checksum. | ||
|
||
[Blog post about automating checksum update in Package.swift](https://blog.eidinger.info/distribute-binary-frameworks-in-swift-packages-and-how-to-automate-the-process) and here is a [Github Gist which looks nice](https://gist.github.com/litoarias/23bca22bb6161625484b4fb8cd245fe8) | ||
|
||
This would allow for us to use a similar pattern like [`ferrostar`'s `Package.swift`](https://github.com/stadiamaps/ferrostar/blob/main/Package.swift) which has a nice `useLocalFramework` setup, and when NOT local uses SPM's setup: | ||
|
||
```swift | ||
let releaseTag = "0.1.0" | ||
let releaseChecksum = "deadbeefdeadbeef..." | ||
.binaryTarget( | ||
name: "SargonCoreRS", | ||
url: "https://github.com/radixdlt/sargon/releases/download/\(releaseTag)/libsargon-rs.xcframework.zip", | ||
checksum: releaseChecksum | ||
) | ||
``` | ||
|
||
The advantage of this over what we are [doing today in Swift-Engine-Toolkit](https://github.com/radixdlt/swift-engine-toolkit/blob/main/Package.swift#L23C3-L23C78) is that the .xcframework files need not be part of Git! They can be put in Github! This will allow for much much faster git clone! | ||
|
||
# Android | ||
[See `uniffi-starter`](https://github.com/ianthetechie/uniffi-starter) (also contains Swift, but `@IanTheTech` has also created `ferrostar` which contains more advanced Swift setup). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let sargonBinaryTargetName = "SargonCoreRS" | ||
let binaryTarget: Target | ||
let useLocalFramework = true | ||
|
||
if useLocalFramework { | ||
binaryTarget = .binaryTarget( | ||
name: sargonBinaryTargetName, | ||
// IMPORTANT: Swift packages importing this locally will not be able to | ||
// import SargonCore unless you specify this as a relative path! | ||
path: "./target/ios/libsargon-rs.xcframework" | ||
) | ||
} else { | ||
let releaseTag = "0.1.0" | ||
let releaseChecksum = "4716b9370ed6cc848c2ae7435f7daeeb0528647b4e23ffd843e1ef6381c7b2c6" | ||
binaryTarget = .binaryTarget( | ||
name: sargonBinaryTargetName, | ||
url: | ||
"https://github.com/radixdlt/sargon/releases/download/\(releaseTag)/libsargon-rs.xcframework.zip", | ||
checksum: releaseChecksum | ||
) | ||
} | ||
|
||
let package = Package( | ||
name: "Sargon", | ||
platforms: [ | ||
.iOS(.v15) | ||
], | ||
products: [ | ||
.library( | ||
name: "Sargon", | ||
targets: ["Sargon"] | ||
) | ||
], | ||
targets: [ | ||
binaryTarget, | ||
.target( | ||
name: "SargonUniFFI", | ||
dependencies: [.target(name: sargonBinaryTargetName)], | ||
path: "apple/Sources/UniFFI" | ||
), | ||
.target( | ||
name: "Sargon", | ||
dependencies: [.target(name: "SargonUniFFI")], | ||
path: "apple/Sources/Sargon" | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[files] | ||
extend-exclude = ["tarpaulin-report.html", "tests/vectors/fixtures/*.json"] | ||
extend-exclude = [ | ||
"apple/Sources/UniFFI/Sargon.swift", | ||
"tarpaulin-report.html", | ||
"tests/vectors/fixtures/*.json", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@_exported import SargonUniFFI |
1 change: 1 addition & 0 deletions
1
apple/Sources/Sargon/Extensions/Methods/Decimal192+Methods.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extension Decimal192: Comparable {} |
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
extension Decimal192: Sendable {} | ||
extension Decimal192: ExpressibleByStringLiteral, | ||
ExpressibleByFloatLiteral | ||
{} | ||
extension Decimal192: SignedNumeric /* Numeric, ExpressibleByIntegerLiteral AdditiveArithmetic */ | ||
{} | ||
*/ |
Oops, something went wrong.