aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/examples
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2016-10-07 19:44:03 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2016-10-07 19:44:03 -0700
commit20d58ef12464f3a422b1afb99e6e62c8c9cf0d35 (patch)
treef5874a7fd3000435ebaf5a527c49c1eb79b36a06 /src/objective-c/examples
parent062ba7b8baefdc76f74fffb9aa3e2134ba047ea6 (diff)
Upgrade SwiftSample to XCode 8 and Swift 3
Diffstat (limited to 'src/objective-c/examples')
-rw-r--r--src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj18
-rw-r--r--src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/xcshareddata/xcschemes/SwiftSample.xcscheme2
-rw-r--r--src/objective-c/examples/SwiftSample/ViewController.swift25
3 files changed, 26 insertions, 19 deletions
diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
index afc3da7116..55b392e778 100644
--- a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
+++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 46;
+ objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
@@ -123,16 +123,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
- LastUpgradeCheck = 0730;
+ LastUpgradeCheck = 0800;
ORGANIZATIONNAME = gRPC;
TargetAttributes = {
633BFFC11B950B210007E424 = {
CreatedOnToolsVersion = 6.4;
+ LastSwiftMigration = 0800;
};
};
};
buildConfigurationList = 633BFFBD1B950B210007E424 /* Build configuration list for PBXProject "SwiftSample" */;
- compatibilityVersion = "Xcode 3.2";
+ compatibilityVersion = "Xcode 8.0";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
@@ -246,8 +247,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -292,8 +295,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -312,6 +317,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@@ -327,6 +333,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
+ SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
@@ -341,6 +348,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.grpc.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
+ SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "";
};
name = Release;
@@ -355,7 +363,7 @@
633BFFE01B950B210007E424 /* Release */,
);
defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
+ defaultConfigurationName = Debug;
};
633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */ = {
isa = XCConfigurationList;
@@ -364,7 +372,7 @@
633BFFE31B950B210007E424 /* Release */,
);
defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
+ defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
};
diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/xcshareddata/xcschemes/SwiftSample.xcscheme b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/xcshareddata/xcschemes/SwiftSample.xcscheme
index bba6a02b2b..87bca5ec68 100644
--- a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/xcshareddata/xcschemes/SwiftSample.xcscheme
+++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/xcshareddata/xcschemes/SwiftSample.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0730"
+ LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift
index 66d4fa9412..6b25e71f2d 100644
--- a/src/objective-c/examples/SwiftSample/ViewController.swift
+++ b/src/objective-c/examples/SwiftSample/ViewController.swift
@@ -51,7 +51,7 @@ class ViewController: UIViewController {
// Example gRPC call using a generated proto client library:
let service = RMTTestService(host: RemoteHost)
- service.unaryCallWithRequest(request) { response, error in
+ service.unaryCall(with: request) { response, error in
if let response = response {
NSLog("1. Finished successfully with response:\n\(response)")
} else {
@@ -63,40 +63,39 @@ class ViewController: UIViewController {
// Same but manipulating headers:
var RPC : GRPCProtoCall! // Needed to convince Swift to capture by reference (__block)
- RPC = service.RPCToUnaryCallWithRequest(request) { response, error in
+ RPC = service.rpcToUnaryCall(with: request) { response, error in
if let response = response {
NSLog("2. Finished successfully with response:\n\(response)")
} else {
NSLog("2. Finished with error: \(error!)")
}
- NSLog("2. Response headers: \(RPC.responseHeaders)")
- NSLog("2. Response trailers: \(RPC.responseTrailers)")
+ NSLog("2. Response headers: \(RPC.responseHeaders!)")
+ NSLog("2. Response trailers: \(RPC.responseTrailers!)")
}
- // TODO(jcanizales): Revert to using subscript syntax once XCode 8 is released.
- RPC.requestHeaders.setObject("My value", forKey: "My-Header")
+ RPC.requestHeaders["My-Header"] = "My value";
RPC.start()
// Same example call using the generic gRPC client library:
- let method = GRPCProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall")
+ let method = GRPCProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall")!
let requestsWriter = GRXWriter(value: request.data())
- let call = GRPCCall(host: RemoteHost, path: method.HTTPPath, requestsWriter: requestsWriter)
+ let call = GRPCCall(host: RemoteHost, path: method.httpPath, requestsWriter: requestsWriter)!
- call.requestHeaders.setObject("My value", forKey: "My-Header")
+ call.requestHeaders["My-Header"] = "My value";
- call.startWithWriteable(GRXWriteable { response, error in
- if let response = response as? NSData {
+ call.start(with: GRXWriteable { response, error in
+ if let response = response as? Data {
NSLog("3. Received response:\n\(try! RMTSimpleResponse(data: response))")
} else {
NSLog("3. Finished with error: \(error!)")
}
- NSLog("3. Response headers: \(call.responseHeaders)")
- NSLog("3. Response trailers: \(call.responseTrailers)")
+ NSLog("3. Response headers: \(call.responseHeaders!)")
+ NSLog("3. Response trailers: \(call.responseTrailers!)")
})
}
}