From c03141c04cededf6bf31d51627cd8b29c7668495 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Tue, 28 Mar 2017 16:04:02 +0200 Subject: Swift: Default to Swift 3.0 with Xcode 8.3 and later Xcode 8.3 has dropped support for Swift 2.3 so that compiler and feature detection failed. Closes #16742 --- Tests/SwiftMix/ObjCMain.m | 8 +++++++- Tests/SwiftMix/SwiftMain.swift | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'Tests') diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m index 7fa90aefbe..5a8700cfcc 100644 --- a/Tests/SwiftMix/ObjCMain.m +++ b/Tests/SwiftMix/ObjCMain.m @@ -1,4 +1,10 @@ #import "SwiftMix-Swift.h" int ObjCMain(int argc, char const* const argv[]) { - return [SwiftMainClass SwiftMain:argc argv:argv]; + if ([SwiftMainClass respondsToSelector:@selector(SwiftMain:argv:)]) { + return [SwiftMainClass SwiftMain:argc argv:argv]; + } + if ([SwiftMainClass respondsToSelector:@selector(SwiftMainWithArgc:argv:)]) { + return [SwiftMainClass SwiftMainWithArgc:argc argv:argv]; + } + return -1; } diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift index 3629ac82a6..921439a613 100644 --- a/Tests/SwiftMix/SwiftMain.swift +++ b/Tests/SwiftMix/SwiftMain.swift @@ -3,10 +3,17 @@ import Foundation @objc class SwiftMainClass : NSObject { class func SwiftMain(argc:Int, argv:UnsafePointer>) -> Int32 { dump("argc: \(argc)") +#if swift(>=3.0) + for i in 0 ..< argc { + let argi = String(cString:argv[i]); + dump("arg[\(i)]: \(argi)"); + } +#else for (var i = 0; i < argc; ++i) { let argi = String.fromCString(argv[i]) dump("arg[\(i)]: \(argi)"); } +#endif return 0; } } -- cgit v1.2.1