Skip to content

Commit

Permalink
SPM Support (#212)
Browse files Browse the repository at this point in the history
* replace pod with spm
* Add Package.swift
  • Loading branch information
hewigovens authored Jan 26, 2022
1 parent 105ad0b commit 9118b36
Show file tree
Hide file tree
Showing 12 changed files with 444 additions and 486 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ profile
DerivedData
*.hmap
*.ipa
.swiftpm/
IDEWorkspaceChecks.plist

# Bundler
.bundle
Expand Down
24 changes: 24 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.5

import PackageDescription

let package = Package(
name: "trust-web3-provider",
products: [
.library(
name: "TrustWeb3Provider",
targets: ["TrustWeb3Provider"]
)
],
dependencies: [],
targets: [
.target(
name: "TrustWeb3Provider",
dependencies: [],
path: "dist",
resources: [
.process("trust-min.js", localization: .none)
]
)
]
)
11 changes: 11 additions & 0 deletions dist/TrustWeb3Provider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright © 2017-2022 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

import Foundation

public func providerJsUrl() -> URL {
return Bundle.module.url(forResource: "trust-min", withExtension: "js")!
}
24 changes: 24 additions & 0 deletions ios/Packages/WalletCore/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "WalletCore",
platforms: [.iOS(.v13)],
products: [
.library(name: "WalletCore", targets: ["WalletCore"]),
.library(name: "SwiftProtobuf", targets: ["SwiftProtobuf"])
],
dependencies: [],
targets: [
.binaryTarget(
name: "WalletCore",
url: "https://github.com/trustwallet/wallet-core/releases/download/2.7.0/WalletCore.xcframework.zip",
checksum: "42812dfdcb1e003d41755f3df87a04ecd8ad2ef6fe475756b67f13a717724f5b"
),
.binaryTarget(
name: "SwiftProtobuf",
url: "https://github.com/trustwallet/wallet-core/releases/download/2.7.0/SwiftProtobuf.xcframework.zip",
checksum: "3d70a5432e5c3e1f8b6f52eee87727f9c45f51f3b51d8defb7495f567da945a2"
)
]
)
12 changes: 0 additions & 12 deletions ios/Podfile

This file was deleted.

31 changes: 0 additions & 31 deletions ios/Podfile.lock

This file was deleted.

143 changes: 38 additions & 105 deletions ios/TrustWeb3Provider.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
ReferencedContainer = "container:TrustWeb3Provider.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
10 changes: 0 additions & 10 deletions ios/TrustWeb3Provider.xcworkspace/contents.xcworkspacedata

This file was deleted.

13 changes: 2 additions & 11 deletions ios/TrustWeb3Provider/WKUserScriptConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@

import Foundation
import WebKit
import TrustWeb3Provider

struct WKUserScriptConfig {

let address: String
let chainId: Int
let rpcUrl: String

var providerJsBundleUrl: URL {
let bundlePath = Bundle.main.path(forResource: "TrustWeb3Provider", ofType: "bundle")
let bundle = Bundle(path: bundlePath!)!
return bundle.url(forResource: "trust-min", withExtension: "js")!
}

var providerJsUrl: URL {
return Bundle.main.url(forResource: "trust-min", withExtension: "js", subdirectory: "dist")!
}

var providerScript: WKUserScript {
let source = try! String(contentsOf: providerJsUrl)
let source = try! String(contentsOf: TrustWeb3Provider.providerJsUrl())
let script = WKUserScript(source: source, injectionTime: .atDocumentStart, forMainFrameOnly: false)
return script
}
Expand Down
Loading

0 comments on commit 9118b36

Please sign in to comment.