aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2016-10-03 11:20:54 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-10-03 13:24:24 -0400
commit297449aaf4b3fabb29a75ba3912af12e27fdefd9 (patch)
treea657e8036dc9f18f288f3e5bc4fcbbe8e789c477
parent350d49449bcabb491f1fb05e3ac2a91717c9ef04 (diff)
Update the ObjC projects for Xcode 8
- Let Xcode 8 update settings on the projects/schemes. - Migrate Swift tests to Swift 3 syntax. - Update the build/test script: - Require Xcode 8 (because of the Swift 3 requirement for tests) - Update the devices to what Xcode 8 has (8.x simulator seem to fail even though they can be downloaded in Xcode 8) - Update the travis images to ones with Xcode 8.
-rw-r--r--.travis.yml2
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh48
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj16
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme2
-rw-r--r--objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme2
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj28
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme2
-rw-r--r--objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme2
-rw-r--r--objectivec/Tests/GPBSwiftTests.swift278
9 files changed, 205 insertions, 175 deletions
diff --git a/.travis.yml b/.travis.yml
index 14b7050c..af8e5c97 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ language: cpp
os:
- osx
# The Objective C build needs Xcode 7.0 or later.
-osx_image: xcode7.3
+osx_image: xcode8
script:
- ./tests.sh $CONFIG
env:
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 89240ee0..7b335618 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -228,34 +228,23 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
# NOTE: Different Xcode have different simulated hardware/os support.
readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
- IOS_SIMULATOR_NAME="Simulator"
case "${XCODE_VERSION}" in
6.* )
- echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 7.0 or higher." 1>&2
+ echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
exit 10
;;
- 7.1* )
- XCODEBUILD_TEST_BASE_IOS+=(
- -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0" # 64bit
- -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPad Air,OS=9.0" # 64bit
- )
+ 7.* )
+ echo "ERROR: The unittests include Swift code that is now Swift 3.0." 1>&2
+ echo "ERROR: Xcode 8.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
+ exit 11
;;
- 7.2* )
+ 8.0* )
+ # The 8.* device seem to hang and never start under Xcode 8.
XCODEBUILD_TEST_BASE_IOS+=(
- -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit
- -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit
- )
- ;;
- 7.3* )
- XCODEBUILD_TEST_BASE_IOS+=(
- -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPhone 6,OS=9.3" # 64bit
- -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
- -destination "platform=iOS Simulator,name=iPad Air,OS=9.3" # 64bit
+ -destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit
+ -destination "platform=iOS Simulator,name=iPhone 7,OS=10.0" # 64bit
+ -destination "platform=iOS Simulator,name=iPad 2,OS=9.0" # 32bit
+ -destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.0" # 64bit
)
;;
* )
@@ -272,7 +261,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
"${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
fi
# Don't leave the simulator in the developer's face.
- killall "${IOS_SIMULATOR_NAME}"
+ killall Simulator
fi
if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_OSX=(
@@ -282,6 +271,19 @@ if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
# Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported.
-destination "platform=OS X,arch=x86_64" # 64bit
)
+ readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )"
+ readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix.
+ case "${XCODE_VERSION}" in
+ 6.* )
+ echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.0 or higher." 1>&2
+ exit 10
+ ;;
+ 7.* )
+ echo "ERROR: The unittests include Swift code that is now Swift 3.0." 1>&2
+ echo "ERROR: Xcode 8.0 or higher is required to build the test suite, but the library works with Xcode 7.x." 1>&2
+ exit 11
+ ;;
+ esac
if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then
header "Doing Xcode OS X build/tests - Debug"
"${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
index 1585dbed..7ce5d54f 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj
@@ -556,9 +556,10 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0710;
+ LastUpgradeCheck = 0800;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
+ LastSwiftMigration = 0800;
TestTargetID = 8B9A5EA41831993600A9D33B;
};
F45BBC141B0CE3C6002D064D = {
@@ -740,6 +741,7 @@
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -764,6 +766,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
+ SWIFT_VERSION = 3.0;
WARNING_CFLAGS = (
"$(inherited)",
"-Wno-documentation-unknown-command",
@@ -785,16 +788,21 @@
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
@@ -846,16 +854,21 @@
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -881,6 +894,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",
"-Wundef",
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 25814c5f..2f618131 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index 3eb4f92b..b1243b79 100644
--- a/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
index b6bc95ab..5f599719 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
@@ -633,9 +633,10 @@
attributes = {
LastSwiftUpdateCheck = 0710;
LastTestingUpgradeCheck = 0600;
- LastUpgradeCheck = 0710;
+ LastUpgradeCheck = 0800;
TargetAttributes = {
8BBEA4A5147C727100C4ADB7 = {
+ LastSwiftMigration = 0800;
TestTargetID = 8B9A5EA41831993600A9D33B;
};
F45BBC0E1B0CDB50002D064D = {
@@ -843,7 +844,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
INFOPLIST_FILE = "$(SRCROOT)/Tests/iOSTestHarness/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
@@ -858,7 +859,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
INFOPLIST_FILE = "$(SRCROOT)/Tests/iOSTestHarness/Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.google.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
@@ -880,7 +881,7 @@
"$(SRCROOT)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@@ -890,6 +891,7 @@
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
WARNING_CFLAGS = (
@@ -915,7 +917,7 @@
"$(SRCROOT)",
);
INFOPLIST_FILE = "Tests/UnitTests-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@@ -924,6 +926,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = UnitTests;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h";
+ SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness";
WARNING_CFLAGS = (
@@ -947,17 +950,22 @@
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
@@ -982,7 +990,7 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
- IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
@@ -1009,17 +1017,22 @@
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -1042,9 +1055,10 @@
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = NO;
- IPHONEOS_DEPLOYMENT_TARGET = 6.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
WARNING_CFLAGS = (
"-Wdocumentation-unknown-command",
"-Wundef",
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
index 0b96b75f..be31c308 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
index d53a75f9..edbe6898 100644
--- a/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
+++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0710"
+ LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
diff --git a/objectivec/Tests/GPBSwiftTests.swift b/objectivec/Tests/GPBSwiftTests.swift
index b5999c21..9d8a0fae 100644
--- a/objectivec/Tests/GPBSwiftTests.swift
+++ b/objectivec/Tests/GPBSwiftTests.swift
@@ -42,23 +42,23 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalString = "abc"
- msg.optionalEnum = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg3.a = 200
msg.optionalGroup = msg3
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
- msg.repeatedEnumArray.addValue(Message2_Enum.Bar.rawValue)
- msg.repeatedEnumArray.addValue(Message2_Enum.Baz.rawValue)
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
+ msg.repeatedEnumArray.addValue(Message2_Enum.bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message2_Enum.baz.rawValue)
msg.mapInt32Int32.setInt32(400, forKey:500)
msg.mapInt32Int32.setInt32(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setEnum(Message2_Enum.Bar.rawValue, forKey:600)
- msg.mapInt32Enum.setEnum(Message2_Enum.Baz.rawValue, forKey:601)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
+ msg.mapInt32Enum.setEnum(Message2_Enum.baz.rawValue, forKey:601)
// Check has*.
XCTAssertTrue(msg.hasOptionalInt32)
@@ -75,19 +75,19 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.bar)
XCTAssertEqual(msg3.a, Int32(200))
XCTAssertTrue(msg.optionalGroup === msg3)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(1), Int32(301))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(1) as? String, "pqr")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(0), Message2_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message2_Enum.Baz.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message2_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message2_Enum.baz.rawValue)
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
var intValue: Int32 = 0
@@ -96,13 +96,13 @@ class GPBBridgeTests: XCTestCase {
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
- XCTAssertEqual(intValue, Message2_Enum.Baz.rawValue)
+ XCTAssertEqual(intValue, Message2_Enum.baz.rawValue)
// Clearing a string with nil.
msg2.optionalString = nil
@@ -124,8 +124,8 @@ class GPBBridgeTests: XCTestCase {
XCTAssertFalse(msg.hasOptionalFloat)
XCTAssertEqual(msg.optionalInt32, Int32(0))
XCTAssertEqual(msg.optionalString, "")
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message2_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message2_Enum.foo) // Default
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
@@ -140,22 +140,22 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalString = "abc"
- msg.optionalEnum = .Bar
+ msg.optionalEnum = .bar
msg2.optionalString = "other"
- msg.optionalMessage = msg2
+ msg.optional = msg2
msg.repeatedInt32Array.addValue(300)
msg.repeatedInt32Array.addValue(301)
- msg.repeatedStringArray.addObject("mno")
- msg.repeatedStringArray.addObject("pqr")
+ msg.repeatedStringArray.add("mno")
+ msg.repeatedStringArray.add("pqr")
// "proto3" syntax lets enum get unknown values.
- msg.repeatedEnumArray.addValue(Message3_Enum.Bar.rawValue)
+ msg.repeatedEnumArray.addValue(Message3_Enum.bar.rawValue)
msg.repeatedEnumArray.addRawValue(666)
SetMessage3_OptionalEnum_RawValue(msg2, 666)
msg.mapInt32Int32.setInt32(400, forKey:500)
msg.mapInt32Int32.setInt32(401, forKey:501)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
- msg.mapInt32Enum.setEnum(Message2_Enum.Bar.rawValue, forKey:600)
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
+ msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
// "proto3" syntax lets enum get unknown values.
msg.mapInt32Enum.setRawValue(666, forKey:601)
@@ -167,20 +167,20 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg.optionalInt32, Int32(100))
XCTAssertEqual(msg.optionalString, "abc")
XCTAssertEqual(msg2.optionalString, "other")
- XCTAssertTrue(msg.optionalMessage === msg2)
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Bar)
+ XCTAssertTrue(msg.optional === msg2)
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.bar)
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(0), Int32(300))
- XCTAssertEqual(msg.repeatedInt32Array.valueAtIndex(1), Int32(301))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
+ XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(0) as? String, "mno")
- XCTAssertEqual(msg.repeatedStringArray.objectAtIndex(1) as? String, "pqr")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
+ XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(0), Message3_Enum.Bar.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.valueAtIndex(1), Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
- XCTAssertEqual(msg.repeatedEnumArray.rawValueAtIndex(1), 666)
- XCTAssertEqual(msg2.optionalEnum, Message3_Enum.GPBUnrecognizedEnumeratorValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message3_Enum.bar.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertEqual(msg.repeatedEnumArray.rawValue(at: 1), 666)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.gpbUnrecognizedEnumeratorValue)
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Int32(666))
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
var intValue: Int32 = 0
@@ -189,13 +189,13 @@ class GPBBridgeTests: XCTestCase {
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:501))
XCTAssertEqual(intValue, Int32(401))
XCTAssertEqual(msg.mapStringString.count, Int(2))
- XCTAssertEqual(msg.mapStringString.objectForKey("bar") as? String, "foo")
- XCTAssertEqual(msg.mapStringString.objectForKey("xyz") as? String, "abc")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
+ XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
- XCTAssertEqual(intValue, Message2_Enum.Bar.rawValue)
+ XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
- XCTAssertEqual(intValue, Message3_Enum.GPBUnrecognizedEnumeratorValue.rawValue)
+ XCTAssertEqual(intValue, Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
XCTAssertTrue(msg.mapInt32Enum.getRawValue(&intValue, forKey:601))
XCTAssertEqual(intValue, 666)
@@ -204,23 +204,23 @@ class GPBBridgeTests: XCTestCase {
XCTAssertEqual(msg2.optionalString, "")
// Clearing a message with nil.
- msg.optionalMessage = nil
+ msg.optional = nil
XCTAssertFalse(msg.hasOptionalMessage)
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
+ XCTAssertTrue(msg.optional !== msg2) // New instance
// Clear.
msg.clear()
XCTAssertFalse(msg.hasOptionalMessage)
XCTAssertEqual(msg.optionalInt32, Int32(0))
XCTAssertEqual(msg.optionalString, "")
- XCTAssertTrue(msg.optionalMessage !== msg2) // New instance
- XCTAssertEqual(msg.optionalEnum, Message3_Enum.Foo) // Default
+ XCTAssertTrue(msg.optional !== msg2) // New instance
+ XCTAssertEqual(msg.optionalEnum, Message3_Enum.foo) // Default
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
msg2.clear()
- XCTAssertEqual(msg2.optionalEnum, Message3_Enum.Foo) // Default
- XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.Foo.rawValue)
+ XCTAssertEqual(msg2.optionalEnum, Message3_Enum.foo) // Default
+ XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.foo.rawValue)
XCTAssertEqual(msg.mapInt32Int32.count, UInt(0))
XCTAssertEqual(msg.mapStringString.count, Int(0))
XCTAssertEqual(msg.mapInt32Enum.count, UInt(0))
@@ -234,201 +234,201 @@ class GPBBridgeTests: XCTestCase {
// Access shouldn't result in has* but should return objects.
let msg2 = msg.optionalGroup
- let msg3 = msg.optionalMessage.optionalMessage
- let msg4 = msg.optionalMessage
+ let msg3 = msg.optional.optional
+ let msg4 = msg.optional
XCTAssertNotNil(msg2)
XCTAssertNotNil(msg3)
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
// Setting things should trigger has* getting set.
msg.optionalGroup.a = 10
- msg.optionalMessage.optionalMessage.optionalInt32 = 100
+ msg.optional.optional.optionalInt32 = 100
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
// And they should be the same pointer as before.
XCTAssertTrue(msg2 === msg.optionalGroup)
- XCTAssertTrue(msg3 === msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 === msg.optionalMessage)
+ XCTAssertTrue(msg3 === msg.optional.optional)
+ XCTAssertTrue(msg4 === msg.optional)
// Clear gets us new objects next time around.
msg.clear()
XCTAssertFalse(msg.hasOptionalGroup)
- XCTAssertFalse(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertFalse(msg.optional.hasOptionalMessage)
XCTAssertFalse(msg.hasOptionalMessage)
msg.optionalGroup.a = 20
- msg.optionalMessage.optionalMessage.optionalInt32 = 200
+ msg.optional.optional.optionalInt32 = 200
XCTAssertTrue(msg.hasOptionalGroup)
- XCTAssertTrue(msg.optionalMessage.hasOptionalMessage)
+ XCTAssertTrue(msg.optional.hasOptionalMessage)
XCTAssertTrue(msg.hasOptionalMessage)
XCTAssertTrue(msg2 !== msg.optionalGroup)
- XCTAssertTrue(msg3 !== msg.optionalMessage.optionalMessage)
- XCTAssertTrue(msg4 !== msg.optionalMessage)
+ XCTAssertTrue(msg3 !== msg.optional.optional)
+ XCTAssertTrue(msg4 !== msg.optional)
// Explicit set of a message, means autocreated object doesn't bind.
msg.clear()
- let autoCreated = msg.optionalMessage
+ let autoCreated = msg.optional
XCTAssertFalse(msg.hasOptionalMessage)
let msg5 = Message2()
msg5.optionalInt32 = 123
- msg.optionalMessage = msg5
+ msg.optional = msg5
XCTAssertTrue(msg.hasOptionalMessage)
// Modifing the autocreated doesn't replaced the explicit set one.
- autoCreated.optionalInt32 = 456
+ autoCreated?.optionalInt32 = 456
XCTAssertTrue(msg.hasOptionalMessage)
- XCTAssertTrue(msg.optionalMessage === msg5)
- XCTAssertEqual(msg.optionalMessage.optionalInt32, Int32(123))
+ XCTAssertTrue(msg.optional === msg5)
+ XCTAssertEqual(msg.optional.optionalInt32, Int32(123))
}
func testProto2OneOfSupport() {
let msg = Message2()
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message2_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message2_Enum.Baz) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.OneofMessage)
+ msg.oneof.optionalInt32 = 300
+ XCTAssertTrue(msg.oneof !== autoCreated) // New instance
+ XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
}
func testProto3OneOfSupport() {
let msg = Message3()
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated = msg.oneofMessage // Default create one.
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated = msg.oneof // Default create one.
XCTAssertNotNil(autoCreated)
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
msg.oneofFloat = 20.0
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(20.0))
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofFloat)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofFloat)
- msg.oneofEnum = .Bar
+ msg.oneofEnum = .bar
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Bar)
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofEnum)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.bar)
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofEnum)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 200
+ msg.oneof.optionalInt32 = 200
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- XCTAssertTrue(msg.oneofMessage === autoCreated) // Still the same
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(200))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ XCTAssertTrue(msg.oneof === autoCreated) // Still the same
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
// Clear the oneof.
Message3_ClearOOneOfCase(msg)
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
- XCTAssertEqual(msg.oneofEnum, Message3_Enum.Foo) // Default
- let autoCreated2 = msg.oneofMessage // Default create one
+ XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
+ let autoCreated2 = msg.oneof // Default create one
XCTAssertNotNil(autoCreated2)
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
msg.oneofInt32 = 10
XCTAssertEqual(msg.oneofInt32, Int32(10))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofInt32)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
// Confirm Message.clear() handles the oneof correctly.
msg.clear()
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
// Sets via the autocreated instance.
- msg.oneofMessage.optionalInt32 = 300
- XCTAssertTrue(msg.oneofMessage !== autoCreated) // New instance
- XCTAssertTrue(msg.oneofMessage !== autoCreated2) // New instance
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(300))
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.OneofMessage)
+ msg.oneof.optionalInt32 = 300
+ XCTAssertTrue(msg.oneof !== autoCreated) // New instance
+ XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
// Set message to nil clears the oneof.
- msg.oneofMessage = nil
- XCTAssertEqual(msg.oneofMessage.optionalInt32, Int32(0)) // Default
- XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.GPBUnsetOneOfCase)
+ msg.oneof = nil
+ XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
+ XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
}
func testSerialization() {
@@ -437,12 +437,12 @@ class GPBBridgeTests: XCTestCase {
msg.optionalInt32 = 100
msg.optionalInt64 = 101
msg.optionalGroup.a = 102
- msg.repeatedStringArray.addObject("abc")
- msg.repeatedStringArray.addObject("def")
+ msg.repeatedStringArray.add("abc")
+ msg.repeatedStringArray.add("def")
msg.mapInt32Int32.setInt32(200, forKey:300)
msg.mapInt32Int32.setInt32(201, forKey:201)
- msg.mapStringString.setObject("foo", forKey:"bar")
- msg.mapStringString.setObject("abc", forKey:"xyz")
+ msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
+ msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
let data = msg.data()