This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
import Foundation | |
let projectType = "-workspace" | |
let projectPath = "SignalPath.xcworkspace" | |
let scheme = "SignalPathiOS" | |
let destinationDevice = "platform=iOS Simulator,name=iPhone 11 Pro Max" | |
let resultBundlePath = "PrePush.xcresult" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let coverageCommand = [ | |
"xcrun", | |
"xccov", | |
"view", | |
"--only-targets", | |
"--report", resultBundlePath.wrappedInQuotes | |
].joined(separator: " ") | |
Process.runZshCommand(coverageCommand) | |
removeResultBundle(at: resultBundlePath) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removeResultBundle(at: resultBundlePath) | |
print("Running tests…") | |
let testCommand = [ | |
"xcodebuild", | |
"test-without-building", | |
"-quiet", | |
projectType, projectPath.wrappedInQuotes, | |
"-scheme", scheme.wrappedInQuotes, | |
"-destination", destinationDevice.wrappedInQuotes, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
import Foundation | |
let projectType = "-workspace" | |
let projectPath = "SignalPath.xcworkspace" | |
let scheme = "SignalPathiOS" | |
let destinationDevice = "platform=iOS Simulator,name=iPhone 11 Pro Max" | |
let resultBundlePath = "PrePush.xcresult" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Process { | |
@discardableResult | |
static func runZshCommand(_ command: String) -> Int32 { | |
let process = Process() | |
process.launchPath = "/bin/zsh" | |
process.arguments = ["-c", command] | |
process.standardOutput = { | |
let pipe = Pipe() | |
pipe.fileHandleForReading.readabilityHandler = { handler in | |
guard let string = String(data: handler.availableData, encoding: .utf8), !string.isEmpty else { return } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
print("Example") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Provider: TimelineProvider { | |
// … | |
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | |
let plants = loadPlants() | |
let entry = PlantEntry(date: Date(), plants: plants) | |
let timeline = Timeline(entries: [entry], policy: .atEnd) | |
completion(timeline) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class WidgetPlantProvider { | |
private var cancellables = [AnyCancellable]() | |
private let plantContainer: PlantContainer // NSPersistentContainer subclass | |
init(plantContainer: PlantContainer, notificationCenter: NotificationCenter = .default) { | |
self.plantContainer = plantContainer | |
let notificationCancellable = notificationCenter.publisher(for: .NSManagedObjectContextDidSave, object: plantContainer.viewContext).sink { [weak self] _ in | |
self?.reloadData() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension WidgetPlantProvider { | |
static let sharedDataFileURL: URL = { | |
let appGroupIdentifier = "group.com.company.appname.widget" | |
if let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) { | |
return url.appendingPathComponent("Plants.plist") | |
} | |
else { | |
preconditionFailure("Expected a valid app group container") | |
} | |
}() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import SwiftUI | |
struct BottomBarView: View { | |
@StateObject var viewModel: BottomBarViewModel | |
var body: some View { | |
Text(viewModel.text) | |
} | |
} |