Skip to content

Swift4: Update to use swift 4 syntax #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Tests/Functional/Asynchronous/Predicates/Handler/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PredicateHandlerTestCase: XCTestCase {
func test_predicateIsTrue_handlerReturnsTrue_passes() {
let predicate = NSPredicate(value: true)
let object = NSObject()
self.expectation(for: predicate, evaluatedWith: object, handler: { _ in
self.expectation(for: predicate, evaluatedWith: object, handler: {
return true
})
waitForExpectations(timeout: 0.1)
Expand All @@ -29,7 +29,7 @@ class PredicateHandlerTestCase: XCTestCase {
func test_predicateIsTrue_handlerReturnsFalse_fails() {
let predicate = NSPredicate(value: true)
let object = NSObject()
self.expectation(for: predicate, evaluatedWith: object, handler: { _ in
self.expectation(for: predicate, evaluatedWith: object, handler: {
return false
})
waitForExpectations(timeout: 0.1)
Expand All @@ -46,7 +46,7 @@ class PredicateHandlerTestCase: XCTestCase {
}
return false
})
expectation(for: predicate, evaluatedWith: halfSecLaterDate, handler: { _ in
expectation(for: predicate, evaluatedWith: halfSecLaterDate, handler: {
XCTFail("Should not call the predicate expectation handler")
return true
})
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def _getenv(name):
return value

built_products_dir = _getenv('BUILT_PRODUCTS_DIR')
# Force tests to build with -swift-version 3 for now.
# Force tests to build with -swift-version 4 for now.
swift_exec = [
_getenv('SWIFT_EXEC'),
'-swift-version', '3',
'-swift-version', '4',
'-Xlinker', '-rpath',
'-Xlinker', built_products_dir,
'-L', built_products_dir,
Expand Down
30 changes: 24 additions & 6 deletions XCTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@
attributes = {
LastSwiftMigration = 0730;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Apple;
TargetAttributes = {
5B5D86DA1BBC74AD00234F36 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
DAA333B51C267AD6000CC115 = {
CreatedOnToolsVersion = 7.2;
Expand Down Expand Up @@ -376,14 +376,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -416,7 +422,8 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -430,14 +437,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -462,7 +475,8 @@
PRODUCT_NAME = SwiftXCTest;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -485,10 +499,12 @@
"-framework",
SwiftFoundation,
);
OTHER_SWIFT_FLAGS = "-swift-version 3";
OTHER_SWIFT_FLAGS = "-swift-version 4";
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
USER_HEADER_SEARCH_PATHS = $BUILT_PRODUCTS_DIR/usr/local/include/CoreFoundation;
Expand All @@ -510,10 +526,12 @@
"-framework",
SwiftFoundation,
);
OTHER_SWIFT_FLAGS = "-swift-version 3";
OTHER_SWIFT_FLAGS = "-swift-version 4";
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
USER_HEADER_SEARCH_PATHS = $BUILT_PRODUCTS_DIR/usr/local/include/CoreFoundation;
Expand Down
4 changes: 3 additions & 1 deletion XCTest.xcodeproj/xcshareddata/xcschemes/SwiftXCTest.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -59,6 +60,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
Expand Down Expand Up @@ -54,6 +54,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -73,6 +74,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions build_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ def build(args):
else:
libdispatch_args = ""

# NOTE: Force -swift-version 3 to build XCTest sources.
# NOTE: Force -swift-version 4 to build XCTest sources.
run("{swiftc} -Xcc -fblocks -c {style_options} -emit-object -emit-module "
"-module-name XCTest -module-link-name XCTest -parse-as-library "
"-emit-module-path {build_dir}/XCTest.swiftmodule "
"-force-single-frontend-invocation "
"-swift-version 3 "
"-swift-version 4 "
"-I {foundation_build_dir} -I {core_foundation_build_dir} "
"{libdispatch_args} "
"{source_paths} -o {build_dir}/XCTest.o".format(
Expand Down