├── .gitignore ├── CLI Support ├── CLIReceiver.swift ├── CLITransmitter.swift └── Models │ ├── CLIResponse.swift │ └── CommandModels.swift ├── LICENSE ├── Listr.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ ├── Listr.xcscheme │ └── listrctl.xcscheme ├── Listr ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── ContentView.swift ├── Info.plist ├── Model │ └── ListItem.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── SceneDelegate.swift └── Storage │ └── ListStore.swift ├── README.md └── listrctl └── main.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | __MACOSX 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | DerivedData 17 | .idea/ 18 | Crashlytics.sh 19 | generatechangelog.sh 20 | Pods/ 21 | Carthage 22 | Provisioning 23 | Crashlytics.sh -------------------------------------------------------------------------------- /CLI Support/CLIReceiver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CLIReceiver.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | #if DEBUG 10 | 11 | import UIKit 12 | import MultipeerKit 13 | 14 | final class CLIReceiver { 15 | 16 | private var app: AppDelegate { 17 | UIApplication.shared.delegate as! AppDelegate 18 | } 19 | 20 | static let serviceType = "listrctl" 21 | 22 | private lazy var transceiver: MultipeerTransceiver = { 23 | var config = MultipeerConfiguration.default 24 | 25 | config.serviceType = Self.serviceType 26 | 27 | return MultipeerTransceiver(configuration: config) 28 | }() 29 | 30 | func start() { 31 | transceiver.receive(AddItemCommand.self, using: response(handleAddItem)) 32 | transceiver.receive(ListItemsCommand.self, using: response(handleListItems)) 33 | transceiver.receive(DumpDatabaseCommand.self, using: response(handleDumpDatabase)) 34 | transceiver.receive(ReplaceDatabaseCommand.self, using: response(handleReplaceDatabase)) 35 | 36 | transceiver.resume() 37 | } 38 | 39 | private func response(_ handler: @escaping (T) -> CLIResponse) -> (T) -> Void { 40 | return { [weak self] (command: T) in 41 | let result = handler(command) 42 | 43 | self?.transceiver.broadcast(result) 44 | } 45 | } 46 | 47 | private func handleAddItem(_ command: AddItemCommand) -> CLIResponse { 48 | app.store.addItem(with: command.title) 49 | 50 | return .empty 51 | } 52 | 53 | private func handleListItems(_ command: ListItemsCommand) -> CLIResponse { 54 | let list = app.store.items.map { item in 55 | "\(item.done ? "[✓]" : "[ ]" ) \(item.title)" 56 | }.joined(separator: "\n") 57 | 58 | return .message(list) 59 | } 60 | 61 | private func handleDumpDatabase(_ command: DumpDatabaseCommand) -> CLIResponse { 62 | do { 63 | return .data(try app.store.dump()) 64 | } catch { 65 | return .message("Failed to dump store: \(error)") 66 | } 67 | } 68 | 69 | 70 | private func handleReplaceDatabase(_ command: ReplaceDatabaseCommand) -> CLIResponse { 71 | do { 72 | try app.store.replace(with: command.data) 73 | 74 | return .empty 75 | } catch { 76 | return .message("Failed to replace store: \(error)") 77 | } 78 | } 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /CLI Support/CLITransmitter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CLITransmitter.swift 3 | // listrctl 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import ArgumentParser 11 | import MultipeerKit 12 | 13 | final class CLITransmitter { 14 | 15 | static let current = CLITransmitter() 16 | 17 | static let serviceType = "listrctl" 18 | 19 | private lazy var transceiver: MultipeerTransceiver = { 20 | var config = MultipeerConfiguration.default 21 | 22 | config.serviceType = Self.serviceType 23 | 24 | return MultipeerTransceiver(configuration: config) 25 | }() 26 | 27 | var outputPath: String! 28 | 29 | func start() { 30 | transceiver.receive(CLIResponse.self) { [weak self] command in 31 | guard let self = self else { return } 32 | 33 | switch command { 34 | case .message(let message): 35 | print(message) 36 | case .data(let data): 37 | self.handleDataReceived(data) 38 | } 39 | 40 | exit(0) 41 | } 42 | 43 | transceiver.resume() 44 | } 45 | 46 | private func handleDataReceived(_ data: Data) { 47 | try! data.write(to: URL(fileURLWithPath: outputPath)) 48 | outputPath = nil 49 | } 50 | 51 | private let queue = DispatchQueue(label: "CLITransmitter") 52 | 53 | private func requirementsMet(with peers: [Peer]) -> Bool { 54 | !peers.filter({ $0.isConnected }).isEmpty 55 | } 56 | 57 | func send(_ command: T) { 58 | queue.async { 59 | let sema = DispatchSemaphore(value: 0) 60 | 61 | self.transceiver.availablePeersDidChange = { peers in 62 | guard self.requirementsMet(with: peers) else { return } 63 | 64 | sema.signal() 65 | } 66 | 67 | _ = sema.wait(timeout: .now() + 20) 68 | 69 | DispatchQueue.main.async { 70 | self.transceiver.broadcast(command) 71 | } 72 | } 73 | 74 | CFRunLoopRun() 75 | } 76 | 77 | } 78 | 79 | extension ParsableCommand { 80 | func send(_ command: T) { 81 | CLITransmitter.current.send(command) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /CLI Support/Models/CLIResponse.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CLIResponse.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | #if DEBUG 10 | 11 | import Foundation 12 | 13 | enum CLIResponse: Hashable { 14 | case message(String) 15 | case data(Data) 16 | } 17 | 18 | extension CLIResponse { 19 | static let empty = CLIResponse.message("") 20 | } 21 | 22 | extension CLIResponse: Codable { 23 | 24 | private enum CodingKeys: String, CodingKey { 25 | case stringValue = "sv" 26 | case dataValue = "dv" 27 | } 28 | 29 | init(from decoder: Decoder) throws { 30 | let container = try decoder.container(keyedBy: CodingKeys.self) 31 | 32 | if let data = try? container.decode(Data.self, forKey: .dataValue) { 33 | self = .data(data) 34 | } else if let str = try? container.decode(String.self, forKey: .stringValue) { 35 | self = .message(str) 36 | } else { 37 | let ctx = DecodingError.Context(codingPath: [], debugDescription: "Missing stringValue or dataValue.") 38 | throw DecodingError.dataCorrupted(ctx) 39 | } 40 | } 41 | 42 | func encode(to encoder: Encoder) throws { 43 | var container = encoder.container(keyedBy: CodingKeys.self) 44 | 45 | switch self { 46 | case .data(let data): 47 | try container.encode(data, forKey: .dataValue) 48 | case .message(let str): 49 | try container.encode(str, forKey: .stringValue) 50 | } 51 | } 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /CLI Support/Models/CommandModels.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommandModels.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | #if DEBUG 10 | 11 | import Foundation 12 | 13 | struct ListItemsCommand: Hashable, Codable { } 14 | 15 | struct AddItemCommand: Hashable, Codable { 16 | let title: String 17 | } 18 | 19 | struct DumpDatabaseCommand: Hashable, Codable { 20 | 21 | } 22 | 23 | struct ReplaceDatabaseCommand: Hashable, Codable { 24 | let data: Data 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Guilherme Rambo 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | - Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Listr.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DDE21F42240C367B00B1A0C5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F41240C367B00B1A0C5 /* AppDelegate.swift */; }; 11 | DDE21F44240C367B00B1A0C5 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F43240C367B00B1A0C5 /* SceneDelegate.swift */; }; 12 | DDE21F46240C367B00B1A0C5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F45240C367B00B1A0C5 /* ContentView.swift */; }; 13 | DDE21F48240C367C00B1A0C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDE21F47240C367C00B1A0C5 /* Assets.xcassets */; }; 14 | DDE21F4B240C367C00B1A0C5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDE21F4A240C367C00B1A0C5 /* Preview Assets.xcassets */; }; 15 | DDE21F4E240C367C00B1A0C5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DDE21F4C240C367C00B1A0C5 /* LaunchScreen.storyboard */; }; 16 | DDE21F57240C369B00B1A0C5 /* ListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F56240C369B00B1A0C5 /* ListItem.swift */; }; 17 | DDE21F5A240C36C000B1A0C5 /* ListStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F59240C36C000B1A0C5 /* ListStore.swift */; }; 18 | DDE21F62240C3E1A00B1A0C5 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F61240C3E1A00B1A0C5 /* main.swift */; }; 19 | DDE21F68240C3E5100B1A0C5 /* CommandModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F67240C3E5100B1A0C5 /* CommandModels.swift */; }; 20 | DDE21F70240C3E9E00B1A0C5 /* CLIResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F6F240C3E9E00B1A0C5 /* CLIResponse.swift */; }; 21 | DDE21F74240C3EE300B1A0C5 /* MultipeerKit in Frameworks */ = {isa = PBXBuildFile; productRef = DDE21F73240C3EE300B1A0C5 /* MultipeerKit */; }; 22 | DDE21F77240C3EE900B1A0C5 /* MultipeerKit in Frameworks */ = {isa = PBXBuildFile; productRef = DDE21F76240C3EE900B1A0C5 /* MultipeerKit */; }; 23 | DDE21F79240C3EFE00B1A0C5 /* CLIReceiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F78240C3EFE00B1A0C5 /* CLIReceiver.swift */; }; 24 | DDE21F7A240C412600B1A0C5 /* CommandModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F67240C3E5100B1A0C5 /* CommandModels.swift */; }; 25 | DDE21F7B240C412800B1A0C5 /* CLIResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F6F240C3E9E00B1A0C5 /* CLIResponse.swift */; }; 26 | DDE21F7D240C413600B1A0C5 /* CLITransmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE21F7C240C413600B1A0C5 /* CLITransmitter.swift */; }; 27 | DDE21F80240C41CF00B1A0C5 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = DDE21F7F240C41CF00B1A0C5 /* ArgumentParser */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXCopyFilesBuildPhase section */ 31 | DDE21F5D240C3E1A00B1A0C5 /* CopyFiles */ = { 32 | isa = PBXCopyFilesBuildPhase; 33 | buildActionMask = 2147483647; 34 | dstPath = /usr/share/man/man1/; 35 | dstSubfolderSpec = 0; 36 | files = ( 37 | ); 38 | runOnlyForDeploymentPostprocessing = 1; 39 | }; 40 | /* End PBXCopyFilesBuildPhase section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | DDE21F3E240C367B00B1A0C5 /* Listr.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Listr.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | DDE21F41240C367B00B1A0C5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 45 | DDE21F43240C367B00B1A0C5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 46 | DDE21F45240C367B00B1A0C5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 47 | DDE21F47240C367C00B1A0C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | DDE21F4A240C367C00B1A0C5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 49 | DDE21F4D240C367C00B1A0C5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | DDE21F4F240C367C00B1A0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | DDE21F56240C369B00B1A0C5 /* ListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItem.swift; sourceTree = ""; }; 52 | DDE21F59240C36C000B1A0C5 /* ListStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStore.swift; sourceTree = ""; }; 53 | DDE21F5F240C3E1A00B1A0C5 /* listrctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = listrctl; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | DDE21F61240C3E1A00B1A0C5 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 55 | DDE21F67240C3E5100B1A0C5 /* CommandModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandModels.swift; sourceTree = ""; }; 56 | DDE21F6F240C3E9E00B1A0C5 /* CLIResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLIResponse.swift; sourceTree = ""; }; 57 | DDE21F78240C3EFE00B1A0C5 /* CLIReceiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLIReceiver.swift; sourceTree = ""; }; 58 | DDE21F7C240C413600B1A0C5 /* CLITransmitter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLITransmitter.swift; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | DDE21F3B240C367B00B1A0C5 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | DDE21F74240C3EE300B1A0C5 /* MultipeerKit in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | DDE21F5C240C3E1A00B1A0C5 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | DDE21F80240C41CF00B1A0C5 /* ArgumentParser in Frameworks */, 75 | DDE21F77240C3EE900B1A0C5 /* MultipeerKit in Frameworks */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | DDE21F35240C367B00B1A0C5 = { 83 | isa = PBXGroup; 84 | children = ( 85 | DDE21F66240C3E4300B1A0C5 /* CLI Support */, 86 | DDE21F40240C367B00B1A0C5 /* Listr */, 87 | DDE21F60240C3E1A00B1A0C5 /* listrctl */, 88 | DDE21F3F240C367B00B1A0C5 /* Products */, 89 | DDE21F75240C3EE900B1A0C5 /* Frameworks */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | DDE21F3F240C367B00B1A0C5 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | DDE21F3E240C367B00B1A0C5 /* Listr.app */, 97 | DDE21F5F240C3E1A00B1A0C5 /* listrctl */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | DDE21F40240C367B00B1A0C5 /* Listr */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | DDE21F58240C36B700B1A0C5 /* Storage */, 106 | DDE21F55240C369000B1A0C5 /* Model */, 107 | DDE21F41240C367B00B1A0C5 /* AppDelegate.swift */, 108 | DDE21F43240C367B00B1A0C5 /* SceneDelegate.swift */, 109 | DDE21F45240C367B00B1A0C5 /* ContentView.swift */, 110 | DDE21F47240C367C00B1A0C5 /* Assets.xcassets */, 111 | DDE21F4C240C367C00B1A0C5 /* LaunchScreen.storyboard */, 112 | DDE21F4F240C367C00B1A0C5 /* Info.plist */, 113 | DDE21F49240C367C00B1A0C5 /* Preview Content */, 114 | ); 115 | path = Listr; 116 | sourceTree = ""; 117 | }; 118 | DDE21F49240C367C00B1A0C5 /* Preview Content */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | DDE21F4A240C367C00B1A0C5 /* Preview Assets.xcassets */, 122 | ); 123 | path = "Preview Content"; 124 | sourceTree = ""; 125 | }; 126 | DDE21F55240C369000B1A0C5 /* Model */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | DDE21F56240C369B00B1A0C5 /* ListItem.swift */, 130 | ); 131 | path = Model; 132 | sourceTree = ""; 133 | }; 134 | DDE21F58240C36B700B1A0C5 /* Storage */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | DDE21F59240C36C000B1A0C5 /* ListStore.swift */, 138 | ); 139 | path = Storage; 140 | sourceTree = ""; 141 | }; 142 | DDE21F60240C3E1A00B1A0C5 /* listrctl */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | DDE21F61240C3E1A00B1A0C5 /* main.swift */, 146 | ); 147 | path = listrctl; 148 | sourceTree = ""; 149 | }; 150 | DDE21F66240C3E4300B1A0C5 /* CLI Support */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | DDE21F71240C3EBE00B1A0C5 /* Models */, 154 | DDE21F78240C3EFE00B1A0C5 /* CLIReceiver.swift */, 155 | DDE21F7C240C413600B1A0C5 /* CLITransmitter.swift */, 156 | ); 157 | path = "CLI Support"; 158 | sourceTree = ""; 159 | }; 160 | DDE21F71240C3EBE00B1A0C5 /* Models */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | DDE21F67240C3E5100B1A0C5 /* CommandModels.swift */, 164 | DDE21F6F240C3E9E00B1A0C5 /* CLIResponse.swift */, 165 | ); 166 | path = Models; 167 | sourceTree = ""; 168 | }; 169 | DDE21F75240C3EE900B1A0C5 /* Frameworks */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | ); 173 | name = Frameworks; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | DDE21F3D240C367B00B1A0C5 /* Listr */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = DDE21F52240C367C00B1A0C5 /* Build configuration list for PBXNativeTarget "Listr" */; 182 | buildPhases = ( 183 | DDE21F3A240C367B00B1A0C5 /* Sources */, 184 | DDE21F3B240C367B00B1A0C5 /* Frameworks */, 185 | DDE21F3C240C367B00B1A0C5 /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = Listr; 192 | packageProductDependencies = ( 193 | DDE21F73240C3EE300B1A0C5 /* MultipeerKit */, 194 | ); 195 | productName = Listr; 196 | productReference = DDE21F3E240C367B00B1A0C5 /* Listr.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | DDE21F5E240C3E1A00B1A0C5 /* listrctl */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = DDE21F63240C3E1A00B1A0C5 /* Build configuration list for PBXNativeTarget "listrctl" */; 202 | buildPhases = ( 203 | DDE21F5B240C3E1A00B1A0C5 /* Sources */, 204 | DDE21F5C240C3E1A00B1A0C5 /* Frameworks */, 205 | DDE21F5D240C3E1A00B1A0C5 /* CopyFiles */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | ); 211 | name = listrctl; 212 | packageProductDependencies = ( 213 | DDE21F76240C3EE900B1A0C5 /* MultipeerKit */, 214 | DDE21F7F240C41CF00B1A0C5 /* ArgumentParser */, 215 | ); 216 | productName = listrctl; 217 | productReference = DDE21F5F240C3E1A00B1A0C5 /* listrctl */; 218 | productType = "com.apple.product-type.tool"; 219 | }; 220 | /* End PBXNativeTarget section */ 221 | 222 | /* Begin PBXProject section */ 223 | DDE21F36240C367B00B1A0C5 /* Project object */ = { 224 | isa = PBXProject; 225 | attributes = { 226 | LastSwiftUpdateCheck = 1140; 227 | LastUpgradeCheck = 1140; 228 | ORGANIZATIONNAME = "Guilherme Rambo"; 229 | TargetAttributes = { 230 | DDE21F3D240C367B00B1A0C5 = { 231 | CreatedOnToolsVersion = 11.4; 232 | }; 233 | DDE21F5E240C3E1A00B1A0C5 = { 234 | CreatedOnToolsVersion = 11.4; 235 | }; 236 | }; 237 | }; 238 | buildConfigurationList = DDE21F39240C367B00B1A0C5 /* Build configuration list for PBXProject "Listr" */; 239 | compatibilityVersion = "Xcode 9.3"; 240 | developmentRegion = en; 241 | hasScannedForEncodings = 0; 242 | knownRegions = ( 243 | en, 244 | Base, 245 | ); 246 | mainGroup = DDE21F35240C367B00B1A0C5; 247 | packageReferences = ( 248 | DDE21F72240C3EE300B1A0C5 /* XCRemoteSwiftPackageReference "MultipeerKit" */, 249 | DDE21F7E240C41CF00B1A0C5 /* XCRemoteSwiftPackageReference "swift-argument-parser" */, 250 | ); 251 | productRefGroup = DDE21F3F240C367B00B1A0C5 /* Products */; 252 | projectDirPath = ""; 253 | projectRoot = ""; 254 | targets = ( 255 | DDE21F3D240C367B00B1A0C5 /* Listr */, 256 | DDE21F5E240C3E1A00B1A0C5 /* listrctl */, 257 | ); 258 | }; 259 | /* End PBXProject section */ 260 | 261 | /* Begin PBXResourcesBuildPhase section */ 262 | DDE21F3C240C367B00B1A0C5 /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | DDE21F4E240C367C00B1A0C5 /* LaunchScreen.storyboard in Resources */, 267 | DDE21F4B240C367C00B1A0C5 /* Preview Assets.xcassets in Resources */, 268 | DDE21F48240C367C00B1A0C5 /* Assets.xcassets in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | /* End PBXResourcesBuildPhase section */ 273 | 274 | /* Begin PBXSourcesBuildPhase section */ 275 | DDE21F3A240C367B00B1A0C5 /* Sources */ = { 276 | isa = PBXSourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | DDE21F70240C3E9E00B1A0C5 /* CLIResponse.swift in Sources */, 280 | DDE21F79240C3EFE00B1A0C5 /* CLIReceiver.swift in Sources */, 281 | DDE21F57240C369B00B1A0C5 /* ListItem.swift in Sources */, 282 | DDE21F68240C3E5100B1A0C5 /* CommandModels.swift in Sources */, 283 | DDE21F42240C367B00B1A0C5 /* AppDelegate.swift in Sources */, 284 | DDE21F5A240C36C000B1A0C5 /* ListStore.swift in Sources */, 285 | DDE21F44240C367B00B1A0C5 /* SceneDelegate.swift in Sources */, 286 | DDE21F46240C367B00B1A0C5 /* ContentView.swift in Sources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | DDE21F5B240C3E1A00B1A0C5 /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | DDE21F7D240C413600B1A0C5 /* CLITransmitter.swift in Sources */, 295 | DDE21F7B240C412800B1A0C5 /* CLIResponse.swift in Sources */, 296 | DDE21F62240C3E1A00B1A0C5 /* main.swift in Sources */, 297 | DDE21F7A240C412600B1A0C5 /* CommandModels.swift in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | DDE21F4C240C367C00B1A0C5 /* LaunchScreen.storyboard */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | DDE21F4D240C367C00B1A0C5 /* Base */, 308 | ); 309 | name = LaunchScreen.storyboard; 310 | sourceTree = ""; 311 | }; 312 | /* End PBXVariantGroup section */ 313 | 314 | /* Begin XCBuildConfiguration section */ 315 | DDE21F50240C367C00B1A0C5 /* Debug */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ALWAYS_SEARCH_USER_PATHS = NO; 319 | CLANG_ANALYZER_NONNULL = YES; 320 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 321 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 322 | CLANG_CXX_LIBRARY = "libc++"; 323 | CLANG_ENABLE_MODULES = YES; 324 | CLANG_ENABLE_OBJC_ARC = YES; 325 | CLANG_ENABLE_OBJC_WEAK = YES; 326 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_COMMA = YES; 329 | CLANG_WARN_CONSTANT_CONVERSION = YES; 330 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 331 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 332 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 333 | CLANG_WARN_EMPTY_BODY = YES; 334 | CLANG_WARN_ENUM_CONVERSION = YES; 335 | CLANG_WARN_INFINITE_RECURSION = YES; 336 | CLANG_WARN_INT_CONVERSION = YES; 337 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 338 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 339 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 341 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 342 | CLANG_WARN_STRICT_PROTOTYPES = YES; 343 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 344 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | COPY_PHASE_STRIP = NO; 348 | DEBUG_INFORMATION_FORMAT = dwarf; 349 | ENABLE_STRICT_OBJC_MSGSEND = YES; 350 | ENABLE_TESTABILITY = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu11; 352 | GCC_DYNAMIC_NO_PIC = NO; 353 | GCC_NO_COMMON_BLOCKS = YES; 354 | GCC_OPTIMIZATION_LEVEL = 0; 355 | GCC_PREPROCESSOR_DEFINITIONS = ( 356 | "DEBUG=1", 357 | "$(inherited)", 358 | ); 359 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 360 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 361 | GCC_WARN_UNDECLARED_SELECTOR = YES; 362 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 363 | GCC_WARN_UNUSED_FUNCTION = YES; 364 | GCC_WARN_UNUSED_VARIABLE = YES; 365 | IPHONEOS_DEPLOYMENT_TARGET = 13.4; 366 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 367 | MTL_FAST_MATH = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | DDE21F51240C367C00B1A0C5 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_ANALYZER_NONNULL = YES; 380 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_ENABLE_OBJC_WEAK = YES; 386 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 387 | CLANG_WARN_BOOL_CONVERSION = YES; 388 | CLANG_WARN_COMMA = YES; 389 | CLANG_WARN_CONSTANT_CONVERSION = YES; 390 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 398 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 399 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 400 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 401 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 402 | CLANG_WARN_STRICT_PROTOTYPES = YES; 403 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 404 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 405 | CLANG_WARN_UNREACHABLE_CODE = YES; 406 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 407 | COPY_PHASE_STRIP = NO; 408 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 409 | ENABLE_NS_ASSERTIONS = NO; 410 | ENABLE_STRICT_OBJC_MSGSEND = YES; 411 | GCC_C_LANGUAGE_STANDARD = gnu11; 412 | GCC_NO_COMMON_BLOCKS = YES; 413 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 414 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 415 | GCC_WARN_UNDECLARED_SELECTOR = YES; 416 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 417 | GCC_WARN_UNUSED_FUNCTION = YES; 418 | GCC_WARN_UNUSED_VARIABLE = YES; 419 | IPHONEOS_DEPLOYMENT_TARGET = 13.4; 420 | MTL_ENABLE_DEBUG_INFO = NO; 421 | MTL_FAST_MATH = YES; 422 | SDKROOT = iphoneos; 423 | SWIFT_COMPILATION_MODE = wholemodule; 424 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 425 | VALIDATE_PRODUCT = YES; 426 | }; 427 | name = Release; 428 | }; 429 | DDE21F53240C367C00B1A0C5 /* Debug */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 433 | CODE_SIGN_STYLE = Automatic; 434 | DEVELOPMENT_ASSET_PATHS = "\"Listr/Preview Content\""; 435 | DEVELOPMENT_TEAM = 8C7439RJLG; 436 | ENABLE_PREVIEWS = YES; 437 | INFOPLIST_FILE = Listr/Info.plist; 438 | IPHONEOS_DEPLOYMENT_TARGET = 13.3; 439 | LD_RUNPATH_SEARCH_PATHS = ( 440 | "$(inherited)", 441 | "@executable_path/Frameworks", 442 | ); 443 | PRODUCT_BUNDLE_IDENTIFIER = codes.rambo.Listr; 444 | PRODUCT_NAME = "$(TARGET_NAME)"; 445 | SWIFT_VERSION = 5.0; 446 | TARGETED_DEVICE_FAMILY = "1,2"; 447 | }; 448 | name = Debug; 449 | }; 450 | DDE21F54240C367C00B1A0C5 /* Release */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 454 | CODE_SIGN_STYLE = Automatic; 455 | DEVELOPMENT_ASSET_PATHS = "\"Listr/Preview Content\""; 456 | DEVELOPMENT_TEAM = 8C7439RJLG; 457 | ENABLE_PREVIEWS = YES; 458 | INFOPLIST_FILE = Listr/Info.plist; 459 | IPHONEOS_DEPLOYMENT_TARGET = 13.3; 460 | LD_RUNPATH_SEARCH_PATHS = ( 461 | "$(inherited)", 462 | "@executable_path/Frameworks", 463 | ); 464 | PRODUCT_BUNDLE_IDENTIFIER = codes.rambo.Listr; 465 | PRODUCT_NAME = "$(TARGET_NAME)"; 466 | SWIFT_VERSION = 5.0; 467 | TARGETED_DEVICE_FAMILY = "1,2"; 468 | }; 469 | name = Release; 470 | }; 471 | DDE21F64240C3E1A00B1A0C5 /* Debug */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | CODE_SIGN_STYLE = Automatic; 475 | DEVELOPMENT_TEAM = 8C7439RJLG; 476 | ENABLE_HARDENED_RUNTIME = YES; 477 | MACOSX_DEPLOYMENT_TARGET = 10.15; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | SDKROOT = macosx; 480 | SWIFT_VERSION = 5.0; 481 | }; 482 | name = Debug; 483 | }; 484 | DDE21F65240C3E1A00B1A0C5 /* Release */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | CODE_SIGN_STYLE = Automatic; 488 | DEVELOPMENT_TEAM = 8C7439RJLG; 489 | ENABLE_HARDENED_RUNTIME = YES; 490 | MACOSX_DEPLOYMENT_TARGET = 10.15; 491 | PRODUCT_NAME = "$(TARGET_NAME)"; 492 | SDKROOT = macosx; 493 | SWIFT_VERSION = 5.0; 494 | }; 495 | name = Release; 496 | }; 497 | /* End XCBuildConfiguration section */ 498 | 499 | /* Begin XCConfigurationList section */ 500 | DDE21F39240C367B00B1A0C5 /* Build configuration list for PBXProject "Listr" */ = { 501 | isa = XCConfigurationList; 502 | buildConfigurations = ( 503 | DDE21F50240C367C00B1A0C5 /* Debug */, 504 | DDE21F51240C367C00B1A0C5 /* Release */, 505 | ); 506 | defaultConfigurationIsVisible = 0; 507 | defaultConfigurationName = Release; 508 | }; 509 | DDE21F52240C367C00B1A0C5 /* Build configuration list for PBXNativeTarget "Listr" */ = { 510 | isa = XCConfigurationList; 511 | buildConfigurations = ( 512 | DDE21F53240C367C00B1A0C5 /* Debug */, 513 | DDE21F54240C367C00B1A0C5 /* Release */, 514 | ); 515 | defaultConfigurationIsVisible = 0; 516 | defaultConfigurationName = Release; 517 | }; 518 | DDE21F63240C3E1A00B1A0C5 /* Build configuration list for PBXNativeTarget "listrctl" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | DDE21F64240C3E1A00B1A0C5 /* Debug */, 522 | DDE21F65240C3E1A00B1A0C5 /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | defaultConfigurationName = Release; 526 | }; 527 | /* End XCConfigurationList section */ 528 | 529 | /* Begin XCRemoteSwiftPackageReference section */ 530 | DDE21F72240C3EE300B1A0C5 /* XCRemoteSwiftPackageReference "MultipeerKit" */ = { 531 | isa = XCRemoteSwiftPackageReference; 532 | repositoryURL = "git@github.com:insidegui/MultipeerKit.git"; 533 | requirement = { 534 | kind = upToNextMajorVersion; 535 | minimumVersion = 0.1.2; 536 | }; 537 | }; 538 | DDE21F7E240C41CF00B1A0C5 /* XCRemoteSwiftPackageReference "swift-argument-parser" */ = { 539 | isa = XCRemoteSwiftPackageReference; 540 | repositoryURL = "git@github.com:apple/swift-argument-parser.git"; 541 | requirement = { 542 | kind = upToNextMajorVersion; 543 | minimumVersion = 0.0.1; 544 | }; 545 | }; 546 | /* End XCRemoteSwiftPackageReference section */ 547 | 548 | /* Begin XCSwiftPackageProductDependency section */ 549 | DDE21F73240C3EE300B1A0C5 /* MultipeerKit */ = { 550 | isa = XCSwiftPackageProductDependency; 551 | package = DDE21F72240C3EE300B1A0C5 /* XCRemoteSwiftPackageReference "MultipeerKit" */; 552 | productName = MultipeerKit; 553 | }; 554 | DDE21F76240C3EE900B1A0C5 /* MultipeerKit */ = { 555 | isa = XCSwiftPackageProductDependency; 556 | package = DDE21F72240C3EE300B1A0C5 /* XCRemoteSwiftPackageReference "MultipeerKit" */; 557 | productName = MultipeerKit; 558 | }; 559 | DDE21F7F240C41CF00B1A0C5 /* ArgumentParser */ = { 560 | isa = XCSwiftPackageProductDependency; 561 | package = DDE21F7E240C41CF00B1A0C5 /* XCRemoteSwiftPackageReference "swift-argument-parser" */; 562 | productName = ArgumentParser; 563 | }; 564 | /* End XCSwiftPackageProductDependency section */ 565 | }; 566 | rootObject = DDE21F36240C367B00B1A0C5 /* Project object */; 567 | } 568 | -------------------------------------------------------------------------------- /Listr.xcodeproj/xcshareddata/xcschemes/Listr.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Listr.xcodeproj/xcshareddata/xcschemes/listrctl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 66 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Listr/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | private(set) lazy var store = ListStore() 15 | 16 | #if DEBUG 17 | private lazy var cli = CLIReceiver() 18 | #endif 19 | 20 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 21 | #if DEBUG 22 | cli.start() 23 | #endif 24 | 25 | return true 26 | } 27 | 28 | // MARK: UISceneSession Lifecycle 29 | 30 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 31 | // Called when a new scene session is being created. 32 | // Use this method to select a configuration to create the new scene with. 33 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 34 | } 35 | 36 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 37 | // Called when the user discards a scene session. 38 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 39 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 40 | } 41 | 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Listr/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Listr/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Listr/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Listr/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct AddView: View { 12 | 13 | @EnvironmentObject var store: ListStore 14 | 15 | @State private var title = "" 16 | 17 | var onDone: () -> Void 18 | 19 | var body: some View { 20 | NavigationView { 21 | Form { 22 | TextField("Item title", text: $title) 23 | } 24 | .navigationBarTitle("Add Item") 25 | .navigationBarItems( 26 | leading: Button(action: cancel, label: { Text("Cancel") }), 27 | trailing: Button(action: save, label: { Text("Done") }) 28 | ) 29 | } 30 | } 31 | 32 | private func save() { 33 | store.addItem(with: title) 34 | 35 | onDone() 36 | } 37 | 38 | private func cancel() { 39 | onDone() 40 | } 41 | 42 | } 43 | 44 | struct ContentView: View { 45 | @EnvironmentObject var store: ListStore 46 | 47 | @State private var showingAddView = false 48 | 49 | private let feedback = UIImpactFeedbackGenerator(style: .light) 50 | 51 | var body: some View { 52 | NavigationView { 53 | List { 54 | ForEach(store.items) { item in 55 | HStack { 56 | Text(item.title) 57 | Spacer() 58 | if item.done { Image(systemName: "checkmark") } 59 | }.contentShape(Rectangle()).onTapGesture { 60 | self.store.toggleDone(for: item) 61 | self.feedback.impactOccurred() 62 | } 63 | } 64 | } 65 | .navigationBarTitle("Todo") 66 | .navigationBarItems(trailing: 67 | Button(action: add, label: { Text("Add") }).contentShape(Rectangle()) 68 | ) 69 | }.sheet(isPresented: $showingAddView, content: { 70 | AddView(onDone: self.hideAddView).environmentObject(self.store) 71 | }) 72 | } 73 | 74 | private func add() { 75 | showingAddView.toggle() 76 | } 77 | 78 | private func hideAddView() { 79 | showingAddView = false 80 | } 81 | } 82 | 83 | struct ContentView_Previews: PreviewProvider { 84 | static var previews: some View { 85 | ContentView().environmentObject(ListStore.mockStore) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Listr/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Listr/Model/ListItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListItem.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct ListItem: Hashable, Codable, Identifiable { 12 | let id: UUID 13 | var title: String 14 | var done: Bool 15 | } 16 | -------------------------------------------------------------------------------- /Listr/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Listr/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | private var store: ListStore { 17 | (UIApplication.shared.delegate as! AppDelegate).store 18 | } 19 | 20 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 21 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 22 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 23 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 24 | 25 | // Create the SwiftUI view that provides the window contents. 26 | let contentView = ContentView().environmentObject(store) 27 | 28 | // Use a UIHostingController as window root view controller. 29 | if let windowScene = scene as? UIWindowScene { 30 | let window = UIWindow(windowScene: windowScene) 31 | window.rootViewController = UIHostingController(rootView: contentView) 32 | self.window = window 33 | window.makeKeyAndVisible() 34 | } 35 | } 36 | 37 | func sceneDidDisconnect(_ scene: UIScene) { 38 | // Called as the scene is being released by the system. 39 | // This occurs shortly after the scene enters the background, or when its session is discarded. 40 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 41 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 42 | } 43 | 44 | func sceneDidBecomeActive(_ scene: UIScene) { 45 | // Called when the scene has moved from an inactive state to an active state. 46 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 47 | } 48 | 49 | func sceneWillResignActive(_ scene: UIScene) { 50 | // Called when the scene will move from an active state to an inactive state. 51 | // This may occur due to temporary interruptions (ex. an incoming phone call). 52 | } 53 | 54 | func sceneWillEnterForeground(_ scene: UIScene) { 55 | // Called as the scene transitions from the background to the foreground. 56 | // Use this method to undo the changes made on entering the background. 57 | } 58 | 59 | func sceneDidEnterBackground(_ scene: UIScene) { 60 | // Called as the scene transitions from the foreground to the background. 61 | // Use this method to save data, release shared resources, and store enough scene-specific state information 62 | // to restore the scene back to its current state. 63 | } 64 | 65 | 66 | } 67 | 68 | -------------------------------------------------------------------------------- /Listr/Storage/ListStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListStore.swift 3 | // Listr 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | /** 10 | NOTE: This employs UserDefaults to save potentially large amounts of data, 11 | in a real app, you wouldn't want to do this, but store your data directly on 12 | the filesystem or use some sort of database like CoreData. 13 | */ 14 | 15 | import Foundation 16 | import os.log 17 | 18 | final class ListStore: ObservableObject { 19 | 20 | private let log = OSLog(subsystem: "Listr", category: String(describing: ListStore.self)) 21 | 22 | @Published fileprivate(set) var items: [ListItem] = [] 23 | 24 | private let defaults: UserDefaults 25 | 26 | init(defaults: UserDefaults = .standard) { 27 | self.defaults = defaults 28 | 29 | load() 30 | } 31 | 32 | private let defaultsKey = "listItems" 33 | 34 | private func load() { 35 | guard let data = defaults.data(forKey: defaultsKey) else { return } 36 | 37 | do { 38 | items = try PropertyListDecoder().decode([ListItem].self, from: data) 39 | } catch { 40 | os_log("Failed to decode list items from user defaults: %{public}@", log: self.log, type: .error, String(describing: error)) 41 | } 42 | } 43 | 44 | private func save() { 45 | do { 46 | let data = try PropertyListEncoder().encode(items) 47 | 48 | defaults.set(data, forKey: defaultsKey) 49 | } catch { 50 | os_log("Failed to encode list items for saving: %{public}@", log: self.log, type: .error, String(describing: error)) 51 | } 52 | } 53 | 54 | func toggleDone(for item: ListItem) { 55 | guard let idx = items.firstIndex(of: item) else { return } 56 | 57 | var mutableItem = item 58 | mutableItem.done.toggle() 59 | items[idx] = mutableItem 60 | 61 | save() 62 | } 63 | 64 | func addItem(with title: String) { 65 | let item = ListItem(id: UUID(), title: title, done: false) 66 | items.append(item) 67 | 68 | save() 69 | } 70 | 71 | #if DEBUG 72 | func dump() throws -> Data { 73 | try PropertyListEncoder().encode(items) 74 | } 75 | 76 | func replace(with data: Data) throws { 77 | items = try PropertyListDecoder().decode([ListItem].self, from: data) 78 | } 79 | #endif 80 | 81 | } 82 | 83 | extension ListStore { 84 | 85 | static let mockStore: ListStore = { 86 | let s = ListStore() 87 | s.items = [ 88 | ListItem(id: UUID(), title: "Item 1", done: false), 89 | ListItem(id: UUID(), title: "Item 2", done: true), 90 | ListItem(id: UUID(), title: "Item 3", done: false) 91 | ] 92 | return s 93 | }() 94 | 95 | } 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Listr 2 | 3 | Sample app showing how it's possible to create a command line interface for an iOS app using the [MultipeerKit](https://github.com/insidegui/MultipeerKit) library. 4 | 5 | [Read the article for more details](https://rambo.codes/posts/2020-03-01-writing-command-line-interfaces-for-ios-apps). -------------------------------------------------------------------------------- /listrctl/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // listrctl 4 | // 5 | // Created by Guilherme Rambo on 01/03/20. 6 | // Copyright © 2020 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import ArgumentParser 11 | 12 | CLITransmitter.current.start() 13 | 14 | struct ListrCTL: ParsableCommand { 15 | 16 | static let configuration = CommandConfiguration( 17 | commandName: "listrctl", 18 | abstract: "Interfaces with Listr running on a device or simulator.", 19 | subcommands: [ 20 | Item.self, 21 | Store.self 22 | ]) 23 | 24 | struct Item: ParsableCommand { 25 | 26 | static let configuration = CommandConfiguration( 27 | commandName: "item", 28 | abstract: "Commands for manipulating items.", 29 | subcommands: [ 30 | List.self, 31 | Add.self 32 | ]) 33 | 34 | struct List: ParsableCommand { 35 | 36 | static let configuration = CommandConfiguration( 37 | commandName: "list", 38 | abstract: "Lists all items." 39 | ) 40 | 41 | func run() throws { 42 | send(ListItemsCommand()) 43 | } 44 | 45 | } 46 | 47 | struct Add: ParsableCommand { 48 | 49 | static let configuration = CommandConfiguration( 50 | commandName: "add", 51 | abstract: "Adds an item with the specified title." 52 | ) 53 | 54 | @Argument(help: "The title for the new item.") 55 | var title: String 56 | 57 | func run() throws { 58 | send(AddItemCommand(title: title)) 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | struct Store: ParsableCommand { 66 | 67 | static let configuration = CommandConfiguration( 68 | commandName: "store", 69 | abstract: "Manipulate the data store.", 70 | subcommands: [ 71 | Dump.self, 72 | Replace.self 73 | ] 74 | ) 75 | 76 | struct Dump: ParsableCommand { 77 | 78 | static let configuration = CommandConfiguration( 79 | commandName: "dump", 80 | abstract: "Dumps the contents of the store as a property list." 81 | ) 82 | 83 | @Argument(help: "The output path.") 84 | var path: String 85 | 86 | func run() throws { 87 | CLITransmitter.current.outputPath = path 88 | 89 | send(DumpDatabaseCommand()) 90 | } 91 | 92 | } 93 | 94 | struct Replace: ParsableCommand { 95 | 96 | static let configuration = CommandConfiguration( 97 | commandName: "replace", 98 | abstract: "Replaces the contents of the store with the contents from the specified property list." 99 | ) 100 | 101 | @Argument(help: "The path to the store property list.") 102 | var path: String 103 | 104 | func run() throws { 105 | let data = try Data(contentsOf: URL(fileURLWithPath: path)) 106 | 107 | send(ReplaceDatabaseCommand(data: data)) 108 | } 109 | 110 | } 111 | 112 | } 113 | 114 | } 115 | 116 | ListrCTL.main() 117 | --------------------------------------------------------------------------------