Skip to content

Commit 838c790

Browse files
committed
Update Datastore example to avoid build/run problems on Linux.
NSString.init(contentsOfFile:usedEncoding:) is not available (yet) on Linux, and is used by String.init(contentsOfFile:). We replace these calls with calls to String.init(contentsOfFile:,encoding:)
1 parent 1a0145a commit 838c790

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Examples/Datastore/PackageManager/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package (
1818
name: "Datastore",
1919
dependencies: [
2020
.Package(url: "https://github.com/grpc/grpc-swift.git", Version(0,1,13)),
21-
.Package(url: "https://github.com/apple/swift-protobuf.git", Version(0,9,901)),
22-
.Package(url: "https://github.com/google/auth-library-swift.git", Version(0,2,0)),
21+
.Package(url: "https://github.com/apple/swift-protobuf.git", Version(0,9,903)),
22+
.Package(url: "https://github.com/google/auth-library-swift.git", Version(0,2,2)),
2323
]
2424
)

Examples/Datastore/PackageManager/Sources/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ guard let authToken = tokenProvider.token?.accessToken else {
4545
let projectID = "<YOUR PROJECT ID>"
4646

4747
let certificateURL = URL(fileURLWithPath:"roots.pem")
48-
let certificates = try! String(contentsOf: certificateURL)
48+
let certificates = try! String(contentsOf: certificateURL, encoding: .utf8)
4949
let service = Google_Datastore_V1_DatastoreService(address:"datastore.googleapis.com",
5050
certificates:certificates,
5151
host:nil)
5252

5353
service.metadata = Metadata(["authorization":"Bearer " + authToken])
5454

5555
var request = Google_Datastore_V1_RunQueryRequest()
56-
request.projectId = projectID
56+
request.projectID = projectID
5757

5858
var query = Google_Datastore_V1_GqlQuery()
5959
query.queryString = "select *"

0 commit comments

Comments
 (0)