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/cocoapods #41

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
41 changes: 23 additions & 18 deletions .github/workflows/release-swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,34 @@ jobs:
make compute-rust-checksum
make generate-package-swift

# 7. (Optional) Debug Environment Variables
- name: Debug Environment Variables
# 7. Update Podspec with Version and Download URL
- name: Update Podspec with Version and Download URL
run: |
echo "VERSION: $VERSION"
echo "TARGET_BRANCH: $TARGET_BRANCH"
# Replace the version line in Podspec
sed -i '' "s/^ s\.version *= *.*/ s.version = '${VERSION}'/g" YttriumWrapper.podspec

# 8. (Optional) Check Git Status
- name: Check Git Status
run: git status
# Construct the download URL
DOWNLOAD_URL="https://github.com/reown-com/yttrium/releases/download/${VERSION}/RustXcframework.xcframework.zip"

# 9. (Optional) List Changes in Package.swift
- name: List Changes in Package.swift
run: git diff Package.swift
# Replace the download URL in prepare_command
sed -i '' "s|curl -L -o RustXcframework.xcframework.zip '.*'|curl -L -o RustXcframework.xcframework.zip '${DOWNLOAD_URL}'|g" YttriumWrapper.podspec

# 10. Commit and Push Package.swift
- name: Commit and Push Package.swift
# 8. Commit and Push Package.swift and Podspec
- name: Commit and Push Package.swift and Podspec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Package.swift crates/ffi/YttriumCore/Sources/YttriumCore/*
git add Package.swift crates/ffi/YttriumCore/Sources/YttriumCore/* YttriumWrapper.podspec
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "chore: update Package.swift for version $VERSION"
git commit -m "chore: update Package.swift and podspec for version $VERSION"
git push origin HEAD:$TARGET_BRANCH
fi

# 11. Create Git Tag
# 9. Create Git Tag
- name: Create Git Tag
env:
VERSION: ${{ env.VERSION }}
Expand All @@ -109,7 +107,7 @@ jobs:
# Push the tag to the repository
git push origin "${VERSION}"

# 12. Create a GitHub Release
# 10. Create a GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -121,7 +119,7 @@ jobs:
draft: false
prerelease: true

# 13. Upload Rust XCFramework to the Release
# 11. Upload Rust XCFramework to the Release
- name: Upload Rust XCFramework to Release
uses: actions/upload-release-asset@v1
env:
Expand All @@ -130,4 +128,11 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Output/RustXcframework.xcframework.zip
asset_name: RustXcframework.xcframework.zip
asset_content_type: application/zip
asset_content_type: application/zip

# 12. Publish to CocoaPods Trunk
- name: Publish to CocoaPods Trunk
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push YttriumWrapper.podspec --allow-warnings
10 changes: 3 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,27 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/thebarndog/swift-dotenv.git", from: "2.0.0")
],
targets: [
rustXcframeworkTarget,
.target(
name: "YttriumCore",
dependencies: [
"RustXcframework",
.product(name: "SwiftDotenv", package: "swift-dotenv")
"RustXcframework"
],
path: "crates/ffi/YttriumCore/Sources/YttriumCore"
),
.target(
name: "Yttrium",
dependencies: [
"YttriumCore",
.product(name: "SwiftDotenv", package: "swift-dotenv")
"YttriumCore"
],
path: "platforms/swift/Sources/Yttrium"
),
.testTarget(
name: "YttriumTests",
dependencies: [
"Yttrium",
.product(name: "SwiftDotenv", package: "swift-dotenv")
"Yttrium"
],
path: "platforms/swift/Tests/YttriumTests"
),
Expand Down
27 changes: 27 additions & 0 deletions YttriumWrapper.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Pod::Spec.new do |s|
s.name = 'YttriumWrapper'
s.version = '0.0.0'
s.summary = '4337 implementation'
s.description = '4337 implementation '
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
s.description = '4337 implementation '
s.description = '4337 implementation'

s.homepage = 'https://reown.com'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = 'Reown, Inc.'
llbartekll marked this conversation as resolved.
Show resolved Hide resolved

s.source = { :git => 'https://github.com/reown-com/yttrium.git', :tag => s.version.to_s }

s.platform = :ios, '13.0'

s.swift_version = '5.9'

# Include the Swift source files
s.source_files = 'crates/ffi/YttriumCore/Sources/YttriumCore/**/*.{swift,h}'

# Include the vendored framework
s.prepare_command = <<-SCRIPT
curl -L -o RustXcframework.xcframework.zip 'https://github.com/reown-com/yttrium/releases/download/0.0.0/RustXcframework.xcframework.zip'
unzip -o RustXcframework.xcframework.zip -d crates/ffi/YttriumCore/
rm RustXcframework.xcframework.zip
SCRIPT

s.vendored_frameworks = 'crates/ffi/YttriumCore/RustXcframework.xcframework'
end
2 changes: 0 additions & 2 deletions crates/ffi/YttriumCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/thebarndog/swift-dotenv.git", from: "2.0.0")
],
targets: [
.binaryTarget(
Expand All @@ -27,7 +26,6 @@ let package = Package(
name: "YttriumCore",
dependencies: [
"RustXcframework",
.product(name: "SwiftDotenv", package: "swift-dotenv")
],
path: ".",
exclude: ["RustXcframework.xcframework"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class AccountClient: AccountClientProtocol {

private let entryPoint: String

private let coreAccountClient: YttriumCore.FFIAccountClient
private let coreAccountClient: FFIAccountClient

public convenience init(
ownerAddress: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import YttriumCore

public final class AccountClient7702 {

Expand All @@ -9,7 +8,7 @@ public final class AccountClient7702 {

private let entryPoint: String

private let core7702AccountClient: YttriumCore.FFI7702AccountClient
private let core7702AccountClient: FFI7702AccountClient

public convenience init(
ownerAddress: String,
Expand Down
22 changes: 0 additions & 22 deletions crates/ffi/YttriumCore/Sources/YttriumCore/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,13 @@ extension Endpoints {
}
}

import SwiftDotenv

extension Config {

public static func local() -> Self {
Config(endpoints: .local())
}

static func pimlico() throws -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Are this config logic getting moved elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it wasn't used at all, we are injecting bundlerUrl from swift on init

try Dotenv.configure()

guard let rpcURL = Dotenv["PIMLICO_RPC_URL"]?.stringValue else {
fatalError("Missing PIMLICO_RPC_URL environment variable")
}
guard let bundlerURL = Dotenv["PIMLICO_BUNDLER_URL"]?.stringValue else {
fatalError("Missing PIMLICO_BUNDLER_URL environment variable")
}
let paymasterURL = bundlerURL

return Self(
endpoints: .init(
rpc: .init(baseURL: rpcURL),
bundler: .init(baseURL: bundlerURL),
paymaster: .init(baseURL: paymasterURL)
)
)
}


public var ffi: FFIConfig {
FFIConfig(endpoints: endpoints.ffi)
}
Expand Down