Skip to content

Commit

Permalink
Merge pull request #104 from EricRabil/master
Browse files Browse the repository at this point in the history
Exclude Task-based code from iOS compilation
  • Loading branch information
jakeheis committed Sep 17, 2021
2 parents 29a4afd + e7bee2d commit 2e94905
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/SwiftCLI/Compatibility.swift
Expand Up @@ -45,6 +45,8 @@ public func run(bash: String, directory: String? = nil) throws {}
@available(*, unavailable, renamed: "Task.capture")
public func capture(bash: String, directory: String? = nil) throws -> CaptureResult { fatalError() }

#if !os(iOS)

extension Task {

@available(*, unavailable, message: "Use Task.execvp(_:arguments:directory:env) instead")
Expand All @@ -67,6 +69,8 @@ extension Task {

}

#endif

extension Input {

@available(*, unavailable, message: "Use Validation<String>.custom instead of (String) -> Bool")
Expand Down
9 changes: 8 additions & 1 deletion Sources/SwiftCLI/Task.swift
Expand Up @@ -7,6 +7,8 @@

import Foundation

#if !os(iOS)

// MARK: -

public class Task {
Expand Down Expand Up @@ -336,6 +338,8 @@ extension Task: CustomStringConvertible {
}
}

#endif

// MARK: -

/// The error thrown by run(...) and run(bash:)
Expand Down Expand Up @@ -397,8 +401,9 @@ public struct CaptureResult {

// MARK: - Interrupts

#if !os(iOS)

private class InterruptPasser {

private static var lock = NSLock()
private static var hasBeenSetup = false
private static var tasks: [ObjectIdentifier: Task] = [:]
Expand Down Expand Up @@ -436,3 +441,5 @@ private class InterruptPasser {
}

}

#endif
2 changes: 2 additions & 0 deletions Tests/SwiftCLITests/TaskTests.swift
Expand Up @@ -10,6 +10,7 @@ import SwiftCLI
import XCTest

class TaskTests: XCTestCase {
#if !os(iOS)

func testRun() throws {
let file = "file.txt"
Expand Down Expand Up @@ -183,4 +184,5 @@ class TaskTests: XCTestCase {
task.runSync()
}

#endif
}

0 comments on commit 2e94905

Please sign in to comment.