From 297449aaf4b3fabb29a75ba3912af12e27fdefd9 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Mon, 3 Oct 2016 11:20:54 -0400 Subject: 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. --- .travis.yml | 2 +- objectivec/DevTools/full_mac_build.sh | 48 ++-- .../ProtocolBuffers_OSX.xcodeproj/project.pbxproj | 16 +- .../xcschemes/PerformanceTests.xcscheme | 2 +- .../xcschemes/ProtocolBuffers.xcscheme | 2 +- .../ProtocolBuffers_iOS.xcodeproj/project.pbxproj | 28 ++- .../xcschemes/PerformanceTests.xcscheme | 2 +- .../xcschemes/ProtocolBuffers.xcscheme | 2 +- objectivec/Tests/GPBSwiftTests.swift | 278 ++++++++++----------- 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 @@