Skip to content

Commit 95c93ae

Browse files
author
Antoine Eddi
authored
Merge pull request #138 from jefft0/fix/go.mod-update-berty-mobile-version
2 parents 6e682fd + a7b8143 commit 95c93ae

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

ios/Bridge/GomobileIPFS/Sources/Config.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Config {
8282
public func get() throws -> [String: Any] {
8383
do {
8484
let rawJson = try self.goConfig.get()
85-
let json = try JSONSerialization.jsonObject(with: rawJson, options: [])
85+
let json = try JSONSerialization.jsonObject(with: rawJson!, options: [])
8686
return (json as? [String: Any])!
8787
} catch let error as NSError {
8888
throw ConfigError("getting failed", error)

ios/Bridge/GomobileIPFS/Sources/RequestBuilder.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class RequestBuilder {
101101
/// - Throws: `RequestBuilderError`: If sending the request failed
102102
/// - Returns: A Data object containing the response
103103
/// - seealso: [IPFS API Doc](https://docs.ipfs.io/reference/api/http/)
104-
public func send() throws -> Data {
104+
public func send() throws -> Data? {
105105
do {
106106
return try self.requestBuilder.send()
107107
} catch let error as NSError {
@@ -113,8 +113,10 @@ public class RequestBuilder {
113113
/// - Throws: `RequestBuilderError`: If sending the request or converting the response failed
114114
/// - Returns: A dict containing the response
115115
/// - seealso: [IPFS API Doc](https://docs.ipfs.io/reference/api/http/)
116-
public func sendToDict() throws -> [String: Any] {
117-
let res = try self.requestBuilder.send()
116+
public func sendToDict() throws -> [String: Any]? {
117+
guard let res = try self.requestBuilder.send() else {
118+
return nil
119+
}
118120

119121
do {
120122
let json = try JSONSerialization.jsonObject(with: res, options: [])

ios/Bridge/GomobileIPFSTests/BasicIPFSClassTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ class BasicIPFSClassTests: XCTestCase {
101101
}
102102

103103
func makeRequest() throws {
104-
let res = try ipfs.newRequest("id").sendToDict()
104+
guard let res = try ipfs.newRequest("id").sendToDict() else {
105+
XCTFail("error while casting dict for \"id\"")
106+
return
107+
}
105108

106109
// TODO: improve these checks
107110
guard let peerID = res["ID"] as? String else {

ios/Bridge/GomobileIPFSTests/RequestIPFSTests.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ class RequestIPFSTests: XCTestCase {
2525
func testDNSRequest() throws {
2626
let domain = "website.ipfs.io"
2727

28-
let resolveResp = try ipfs.newRequest("resolve")
28+
guard let resolveResp = try ipfs.newRequest("resolve")
2929
.with(argument: "/ipns/\(domain)")
30-
.sendToDict()
31-
let dnsResp = try ipfs.newRequest("dns")
30+
.sendToDict() else {
31+
XCTFail("error while casting dict for \"resolve\"")
32+
return
33+
}
34+
guard let dnsResp = try ipfs.newRequest("dns")
3235
.with(argument: domain)
33-
.sendToDict()
36+
.sendToDict() else {
37+
XCTFail("error while casting dict for \"dns\"")
38+
return
39+
}
3440

3541
guard let resolvePath = resolveResp["Path"] as? String else {
3642
XCTFail("error while casting value associated to \"Path\" key")
@@ -61,9 +67,9 @@ class RequestIPFSTests: XCTestCase {
6167
.send()
6268

6369
do {
64-
try JSONSerialization.jsonObject(with: latestRaw, options: [])
70+
try JSONSerialization.jsonObject(with: latestRaw!, options: [])
6571
} catch _ {
66-
XCTFail("error while parsing fetched JSON: \(String(decoding: latestRaw, as: UTF8.self))")
72+
XCTFail("error while parsing fetched JSON: \(String(decoding: latestRaw! , as: UTF8.self))")
6773
}
6874
}
6975
}

ios/Example/Example/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ViewController: UIViewController {
110110
.send()
111111

112112
title = "IPFS File"
113-
image = UIImage(data: fetchedData)!
113+
image = UIImage(data: fetchedData!)!
114114
} catch let err as IPFSError {
115115
error = err.localizedFullDescription
116116
} catch let err {
@@ -257,7 +257,7 @@ class ViewController: UIViewController {
257257
.send()
258258

259259
title = "\(randomIndex). \(fetchedInfo["title"] as! String)"
260-
image = UIImage(data: fetchedData)!
260+
image = UIImage(data: fetchedData!)!
261261
} catch let err as IPFSError {
262262
error = err.localizedFullDescription
263263
} catch let err {

packages/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,5 @@ require (
243243
replace (
244244
github.com/ipfs-shipyard/gomobile-ipfs/go => ../go
245245
github.com/lucas-clemente/quic-go => github.com/lucas-clemente/quic-go v0.25.0
246-
golang.org/x/mobile => github.com/berty/mobile v0.0.8 // temporary, see https://github.com/golang/mobile/pull/58 and https://github.com/golang/mobile/pull/82
246+
golang.org/x/mobile => github.com/berty/mobile v0.0.9 // temporary, see https://github.com/golang/mobile/pull/58 and https://github.com/golang/mobile/pull/82
247247
)

packages/go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)