From ed6bc3ec6c847752f983add799cb863edeba97b5 Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Wed, 25 May 2016 02:39:44 +0200 Subject: [PATCH] Remove all use of Objective-C. --- Sources/SwiftShell/Command.swift | 13 +++------ Sources/SwiftShell/NSTask+NSTask_Errors.h | 14 ---------- Sources/SwiftShell/NSTask+NSTask_Errors.m | 27 ------------------- .../SwiftShell/SwiftShell-Bridging-Header.h | 13 --------- SwiftShell2.xcodeproj/project.pbxproj | 22 --------------- 5 files changed, 4 insertions(+), 85 deletions(-) delete mode 100644 Sources/SwiftShell/NSTask+NSTask_Errors.h delete mode 100644 Sources/SwiftShell/NSTask+NSTask_Errors.m delete mode 100644 Sources/SwiftShell/SwiftShell-Bridging-Header.h diff --git a/Sources/SwiftShell/Command.swift b/Sources/SwiftShell/Command.swift index a930cba..1d28fe4 100644 --- a/Sources/SwiftShell/Command.swift +++ b/Sources/SwiftShell/Command.swift @@ -145,15 +145,10 @@ extension NSTask { - throws: ShellError.InAccessibleExecutable if command could not be executed. */ public func launchThrowably() throws { - #if SWIFT_PACKAGE - launch() - #else - do { - try launchWithNSError() - } catch { - throw ShellError.InAccessibleExecutable(path: self.launchPath!) - } - #endif + guard Files.isExecutableFile(atPath: self.launchPath!) else { + throw ShellError.InAccessibleExecutable(path: self.launchPath!) + } + launch() } /** diff --git a/Sources/SwiftShell/NSTask+NSTask_Errors.h b/Sources/SwiftShell/NSTask+NSTask_Errors.h deleted file mode 100644 index ab4be20..0000000 --- a/Sources/SwiftShell/NSTask+NSTask_Errors.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Released under the MIT License (MIT), http://opensource.org/licenses/MIT - * - * Copyright (c) 2015 Kåre Morstøl, NotTooBad Software (nottoobadsoftware.com) - * - */ - -#import - -@interface NSTask (NSTask_Errors) - -- (BOOL) launchWithNSError: (NSError**) error; - -@end diff --git a/Sources/SwiftShell/NSTask+NSTask_Errors.m b/Sources/SwiftShell/NSTask+NSTask_Errors.m deleted file mode 100644 index e047051..0000000 --- a/Sources/SwiftShell/NSTask+NSTask_Errors.m +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Released under the MIT License (MIT), http://opensource.org/licenses/MIT - * - * Copyright (c) 2015 Kåre Morstøl, NotTooBad Software (nottoobadsoftware.com) - * - */ - -#import "NSTask+NSTask_Errors.h" - -@implementation NSTask (NSTask_Errors) - -- (BOOL) launchWithNSError:(NSError *__autoreleasing *)error { - @try { - [self launch]; - } - @catch (NSException *exception) { - if ([exception.name isEqualToString:NSInvalidArgumentException]) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:1 userInfo:exception.userInfo]; - return false; - } else { - @throw exception; - } - } - return true; -} - -@end diff --git a/Sources/SwiftShell/SwiftShell-Bridging-Header.h b/Sources/SwiftShell/SwiftShell-Bridging-Header.h deleted file mode 100644 index 108805e..0000000 --- a/Sources/SwiftShell/SwiftShell-Bridging-Header.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Released under the MIT License (MIT), http://opensource.org/licenses/MIT - * - * Copyright (c) 2015 Kåre Morstøl, NotTooBad Software (nottoobadsoftware.com) - * - */ - -#ifndef SwiftShell_Bridging_Header_h -#define SwiftShell_Bridging_Header_h - -#import "NSTask+NSTask_Errors.h" - -#endif /* SwiftShell_Bridging_Header_h */ diff --git a/SwiftShell2.xcodeproj/project.pbxproj b/SwiftShell2.xcodeproj/project.pbxproj index 1d36a76..32e387b 100644 --- a/SwiftShell2.xcodeproj/project.pbxproj +++ b/SwiftShell2.xcodeproj/project.pbxproj @@ -28,9 +28,6 @@ BAE4F5681B9F838E00908543 /* Bash.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE4F5671B9F838E00908543 /* Bash.swift */; }; BAE503881BAF1061005261A6 /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE503871BAF1061005261A6 /* Array.swift */; }; BAE5038B1BAF1231005261A6 /* Array_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE5038A1BAF1231005261A6 /* Array_Tests.swift */; }; - BAEDDA4C1BB3582B00BD28B2 /* NSTask+NSTask_Errors.h in Headers */ = {isa = PBXBuildFile; fileRef = BAEDDA4A1BB3582B00BD28B2 /* NSTask+NSTask_Errors.h */; }; - BAEDDA4D1BB3582B00BD28B2 /* NSTask+NSTask_Errors.m in Sources */ = {isa = PBXBuildFile; fileRef = BAEDDA4B1BB3582B00BD28B2 /* NSTask+NSTask_Errors.m */; }; - BAEDDA4F1BB36EE200BD28B2 /* SwiftShell-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = BAEDDA4E1BB36EE200BD28B2 /* SwiftShell-Bridging-Header.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -69,9 +66,6 @@ BAE4F5671B9F838E00908543 /* Bash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bash.swift; sourceTree = ""; }; BAE503871BAF1061005261A6 /* Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Array.swift; path = General/Array.swift; sourceTree = ""; }; BAE5038A1BAF1231005261A6 /* Array_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Array_Tests.swift; path = General/Array_Tests.swift; sourceTree = ""; }; - BAEDDA4A1BB3582B00BD28B2 /* NSTask+NSTask_Errors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTask+NSTask_Errors.h"; sourceTree = ""; }; - BAEDDA4B1BB3582B00BD28B2 /* NSTask+NSTask_Errors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTask+NSTask_Errors.m"; sourceTree = ""; }; - BAEDDA4E1BB36EE200BD28B2 /* SwiftShell-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SwiftShell-Bridging-Header.h"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -134,7 +128,6 @@ BA2E3B311B5C35CC001ED175 /* Stream.swift */, BAE503861BAF104C005261A6 /* General */, BA2E3B1A1B5C34DD001ED175 /* Info.plist */, - BAEDDA501BB37B9200BD28B2 /* NSTask */, ); name = Sources; path = Sources/SwiftShell; @@ -174,16 +167,6 @@ name = General; sourceTree = ""; }; - BAEDDA501BB37B9200BD28B2 /* NSTask */ = { - isa = PBXGroup; - children = ( - BAEDDA4A1BB3582B00BD28B2 /* NSTask+NSTask_Errors.h */, - BAEDDA4B1BB3582B00BD28B2 /* NSTask+NSTask_Errors.m */, - BAEDDA4E1BB36EE200BD28B2 /* SwiftShell-Bridging-Header.h */, - ); - name = NSTask; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -191,8 +174,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - BAEDDA4F1BB36EE200BD28B2 /* SwiftShell-Bridging-Header.h in Headers */, - BAEDDA4C1BB3582B00BD28B2 /* NSTask+NSTask_Errors.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -301,7 +282,6 @@ BA2E3B501B5C450C001ED175 /* Context.swift in Sources */, BA2E3B351B5C35CC001ED175 /* Files.swift in Sources */, BAE503881BAF1061005261A6 /* Array.swift in Sources */, - BAEDDA4D1BB3582B00BD28B2 /* NSTask+NSTask_Errors.m in Sources */, BA2E3B371B5C35CC001ED175 /* Stream.swift in Sources */, BAE4F5681B9F838E00908543 /* Bash.swift in Sources */, ); @@ -403,7 +383,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = NO; - SWIFT_OBJC_BRIDGING_HEADER = "Sources/SwiftShell/SwiftShell-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -455,7 +434,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = NO; - SWIFT_OBJC_BRIDGING_HEADER = "Sources/SwiftShell/SwiftShell-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = "";