├── .gitignore ├── LICENSE ├── README.md ├── READMEResources ├── ProjectTree.png ├── SwiftVIPER-Demo.gif ├── SwiftVIPER-Demo.mov └── diagram.jpg ├── SwiftVIPER.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── hayashi.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── SwiftVIPER ├── Apis │ ├── Api.swift │ ├── Entities │ │ └── GitHubRepository.swift │ └── GitHubApi.swift ├── AppDelegate.swift ├── Extensions │ └── CollectionExtension.swift ├── Protocols │ ├── Interactorable.swift │ ├── Presenterable.swift │ ├── Routerable.swift │ ├── TableViewItemDataSource.swift │ └── Viewable.swift ├── Resources │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ └── Info.plist ├── Screens │ ├── Detail │ │ ├── DetailEntities.swift │ │ ├── DetailInteractor.swift │ │ ├── DetailPresenter.swift │ │ ├── DetailRouter.swift │ │ ├── DetailViewController.swift │ │ └── DetailViewController.xib │ └── List │ │ ├── ListEntities.swift │ │ ├── ListInteractor.swift │ │ ├── ListPresenter.swift │ │ ├── ListRouter.swift │ │ ├── ListTableViewDataSource.swift │ │ ├── ListViewController.swift │ │ └── ListViewController.xib └── ViewController.swift └── SwiftVIPERTests ├── Info.plist └── SwiftVIPERTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | !Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | 67 | # Breakpoint 68 | *.xcbkptlist 69 | 70 | # Firebase 71 | # Firebase 72 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 yokurin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftVIPER (View, Interactor, Presenter, Entity, Router) 2 | 3 | SwiftVIPER is an sample iOS App written in Swift using the [VIPER](https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/) architecture. 4 | Also SwiftVIPER is not a strict [VIPER](https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/) architecture. 5 | Part of the project is a unique way. 6 | 7 | [![Language](https://img.shields.io/badge/language-Swift%204.2-orange.svg)](https://swift.org) 8 | 9 | ## Sample App 10 | 11 | 12 | 13 | ### Architecture 14 | 15 | 16 | ### Run Sample 17 | 1. Clone this repository. 18 | ``` 19 | git clone git@github.com:yokurin/Swift-VIPER-iOS.git 20 | ``` 21 | 22 | 2. Open `SwiftVIPER.xcodeproj` in Xcode. 23 | 24 | 3. Run 25 | 26 | ## Description 27 | 28 | SwiftVIPER is not a strict [VIPER](https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/) architecture. 29 | Part of the project is a unique way. This is just a suggestion. 30 | 31 | 32 | ### View (including UIViewController) 33 | View must implement Viewable. Viewable has Default Extension. 34 | ※ View is not just View like UIView etc in this case. 35 | 36 | ```swift 37 | 38 | protocol Viewable: AnyObject { 39 | func push(_ vc: UIViewController, animated: Bool) 40 | func present(_ vc: UIViewController, animated: Bool) 41 | func pop(animated: Bool) 42 | func dismiss(animated: Bool) 43 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) 44 | } 45 | 46 | extension Viewable where Self: UIViewController { 47 | 48 | func push(_ vc: UIViewController, animated: Bool) { 49 | self.navigationController?.pushViewController(vc, animated: animated) 50 | } 51 | 52 | func present(_ vc: UIViewController, animated: Bool) { 53 | self.present(vc, animated: animated, completion: nil) 54 | } 55 | 56 | func pop(animated: Bool) { 57 | self.navigationController?.popViewController(animated: animated) 58 | } 59 | 60 | func dismiss(animated: Bool) { 61 | self.dismiss(animated: animated, completion: nil) 62 | } 63 | 64 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) { 65 | self.dismiss(animated: animated, completion: completion) 66 | } 67 | } 68 | 69 | 70 | ``` 71 | 72 | Example 73 | 74 | ```swift 75 | 76 | protocol ViewInputs: AnyObject { 77 | 78 | } 79 | 80 | protocol ViewOutputs: AnyObject { 81 | func viewDidLoad() 82 | } 83 | 84 | final class ListViewController: UIViewController { 85 | 86 | internal var presenter: ViewOutputs? 87 | 88 | override func viewDidLoad() { 89 | super.viewDidLoad() 90 | presenter?.viewDidLoad() 91 | } 92 | 93 | ... 94 | 95 | } 96 | 97 | extension ListViewController: ListViewInputs {} 98 | 99 | extension ListViewController: Viewable {} 100 | 101 | ``` 102 | 103 | 104 | ### Interactor 105 | Interactor must implement Interactorable. But Interactorable has no properties. 106 | 107 | ```swift 108 | protocol Interactorable { 109 | // nop 110 | } 111 | 112 | ``` 113 | 114 | Example 115 | 116 | ```swift 117 | 118 | protocol InteractorOutputs: AnyObject { 119 | 120 | } 121 | 122 | final class Interactor: Interactorable { 123 | 124 | weak var presenter: InteractorOutputs? 125 | 126 | } 127 | 128 | 129 | ``` 130 | 131 | ### Presenter 132 | Presenter must implement Presenterable. 133 | 134 | ```swift 135 | protocol Presenterable { 136 | associatedtype I: Interactorable 137 | associatedtype R: Routerable 138 | var dependencies: (interactor: I, router: R) { get } 139 | } 140 | 141 | ``` 142 | 143 | Example 144 | 145 | ```swift 146 | 147 | /// Must not import UIKit 148 | 149 | typealias PresenterDependencies = ( 150 | interactor: Interactor, 151 | router: RouterOutput 152 | ) 153 | 154 | final class Presenter: Presenterable { 155 | 156 | ... 157 | 158 | internal var entities: Entities 159 | private weak var view: ViewInputs! 160 | let dependencies: PresenterDependencies 161 | 162 | init(entities: Entities, 163 | view: ViewInputs, 164 | dependencies: PresenterDependencies) 165 | { 166 | self.view = view 167 | self.entities = entities 168 | self.dependencies = dependencies 169 | } 170 | 171 | ... 172 | } 173 | 174 | ``` 175 | 176 | ### Entity 177 | Entity has no protocol. 178 | 179 | Example 180 | 181 | ```swift 182 | 183 | struct EntryEntity {} 184 | 185 | final class Entities { 186 | let entryEntity: EntryEntity 187 | 188 | var entities: [SomeEntity] = [] 189 | 190 | init(entryEntity: EntryEntity) { 191 | self.entryEntity = entryEntity 192 | } 193 | } 194 | 195 | ``` 196 | 197 | 198 | ### Router 199 | Router must implement Routerable. 200 | 201 | 202 | ```swift 203 | protocol Routerable { 204 | var view: Viewable! { get } 205 | 206 | func dismiss(animated: Bool) 207 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) 208 | func pop(animated: Bool) 209 | } 210 | 211 | extension Routerable { 212 | func dismiss(animated: Bool) { 213 | view.dismiss(animated: animated) 214 | } 215 | 216 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) { 217 | view.dismiss(animated: animated, _completion: completion) 218 | } 219 | 220 | func pop(animated: Bool) { 221 | view.pop(animated: animated) 222 | } 223 | } 224 | 225 | ``` 226 | 227 | Example 228 | 229 | ```swift 230 | 231 | struct RouterInput { 232 | 233 | private func view(entryEntity: EntryEntity) -> ViewController { 234 | let view = ViewController() 235 | let interactor = Interactor() 236 | let dependencies = PresenterDependencies(interactor: interactor, router: RouterOutput(view)) 237 | let presenter = Presenter(entities: Entities(entryEntity: entryEntity), view: view, dependencies: dependencies) 238 | view.presenter = presenter 239 | interactor.presenter = presenter 240 | return view 241 | } 242 | 243 | func push(from: Viewable, entryEntity: EntryEntity) { 244 | let view = self.view(entryEntity: entryEntity) 245 | from.push(view, animated: true) 246 | } 247 | 248 | func present(from: Viewable, entryEntity: EntryEntity) { 249 | let nav = UINavigationController(rootViewController: view(entryEntity: entryEntity)) 250 | from.present(nav, animated: true) 251 | } 252 | } 253 | 254 | final class RouterOutput: Routerable { 255 | 256 | private(set) weak var view: Viewable! 257 | 258 | init(_ view: Viewable) { 259 | self.view = view 260 | } 261 | 262 | func transitionToOther() { 263 | OtherRouterInput().push(from: view, entryEntity: OtherEntryEntity()) 264 | } 265 | } 266 | 267 | ``` 268 | 269 | ### Unit Test 270 | 271 | WIP ... 272 | 273 | ### Xcode Template ( xctemplate ) 274 | 275 | WIP ... 276 | 277 | ## Requirements 278 | 279 | - Xcode 10.0+ 280 | - Swift 4.2+ 281 | 282 | ## Installation 283 | 284 | ``` 285 | git clone git@github.com:yokurin/Swift-VIPER-iOS.git 286 | ``` 287 | 288 | ## Author 289 | 290 | Tsubasa Hayashi, yoku.rin.99@gmail.com 291 | 292 | ## License 293 | 294 | SwiftVIPER is available under the MIT license. See the LICENSE file for more info. 295 | -------------------------------------------------------------------------------- /READMEResources/ProjectTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yokurin/Swift-VIPER-iOS/860393445310eb7e6d4fe724f34da99c3bdf851d/READMEResources/ProjectTree.png -------------------------------------------------------------------------------- /READMEResources/SwiftVIPER-Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yokurin/Swift-VIPER-iOS/860393445310eb7e6d4fe724f34da99c3bdf851d/READMEResources/SwiftVIPER-Demo.gif -------------------------------------------------------------------------------- /READMEResources/SwiftVIPER-Demo.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yokurin/Swift-VIPER-iOS/860393445310eb7e6d4fe724f34da99c3bdf851d/READMEResources/SwiftVIPER-Demo.mov -------------------------------------------------------------------------------- /READMEResources/diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yokurin/Swift-VIPER-iOS/860393445310eb7e6d4fe724f34da99c3bdf851d/READMEResources/diagram.jpg -------------------------------------------------------------------------------- /SwiftVIPER.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4A5B56BB2195E0E4005082B8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5B56BA2195E0E4005082B8 /* AppDelegate.swift */; }; 11 | 4A5B56BD2195E0E4005082B8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5B56BC2195E0E4005082B8 /* ViewController.swift */; }; 12 | 4A5B56C02195E0E4005082B8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A5B56BE2195E0E4005082B8 /* Main.storyboard */; }; 13 | 4A5B56C22195E0E5005082B8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A5B56C12195E0E5005082B8 /* Assets.xcassets */; }; 14 | 4A5B56C52195E0E5005082B8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A5B56C32195E0E5005082B8 /* LaunchScreen.storyboard */; }; 15 | 4A5B56D02195E0E5005082B8 /* SwiftVIPERTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5B56CF2195E0E5005082B8 /* SwiftVIPERTests.swift */; }; 16 | AE895348219981A700BA9616 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE895346219981A700BA9616 /* DetailViewController.swift */; }; 17 | AE895349219981A700BA9616 /* DetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AE895347219981A700BA9616 /* DetailViewController.xib */; }; 18 | AE89534B219981BC00BA9616 /* DetailRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE89534A219981BC00BA9616 /* DetailRouter.swift */; }; 19 | AE89534D219981DA00BA9616 /* DetailInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE89534C219981DA00BA9616 /* DetailInteractor.swift */; }; 20 | AE89534F219981EA00BA9616 /* DetailPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE89534E219981EA00BA9616 /* DetailPresenter.swift */; }; 21 | AE895351219981F800BA9616 /* DetailEntities.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE895350219981F800BA9616 /* DetailEntities.swift */; }; 22 | AED17A1021992ABB0000127C /* Routerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A0F21992ABB0000127C /* Routerable.swift */; }; 23 | AED17A1221992AD90000127C /* Presenterable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A1121992AD90000127C /* Presenterable.swift */; }; 24 | AED17A1421992AEF0000127C /* Viewable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A1321992AEF0000127C /* Viewable.swift */; }; 25 | AED17A1621992B090000127C /* Interactorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A1521992B090000127C /* Interactorable.swift */; }; 26 | AED17A2121993C000000127C /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A1F21993C000000127C /* ListViewController.swift */; }; 27 | AED17A2221993C000000127C /* ListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = AED17A2021993C000000127C /* ListViewController.xib */; }; 28 | AED17A2421993C180000127C /* ListPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2321993C180000127C /* ListPresenter.swift */; }; 29 | AED17A2621993C2A0000127C /* ListRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2521993C2A0000127C /* ListRouter.swift */; }; 30 | AED17A2821993C450000127C /* ListInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2721993C450000127C /* ListInteractor.swift */; }; 31 | AED17A2B219941450000127C /* Api.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2A219941450000127C /* Api.swift */; }; 32 | AED17A2D2199418D0000127C /* GitHubApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2C2199418D0000127C /* GitHubApi.swift */; }; 33 | AED17A30219941BA0000127C /* GitHubRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A2F219941BA0000127C /* GitHubRepository.swift */; }; 34 | AED17A352199540C0000127C /* CollectionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A342199540C0000127C /* CollectionExtension.swift */; }; 35 | AED17A3721995D900000127C /* ListEntities.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A3621995D900000127C /* ListEntities.swift */; }; 36 | AED17A3921995E8E0000127C /* ListTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A3821995E8E0000127C /* ListTableViewDataSource.swift */; }; 37 | AED17A3B219969950000127C /* TableViewItemDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED17A3A219969950000127C /* TableViewItemDataSource.swift */; }; 38 | /* End PBXBuildFile section */ 39 | 40 | /* Begin PBXContainerItemProxy section */ 41 | 4A5B56CC2195E0E5005082B8 /* PBXContainerItemProxy */ = { 42 | isa = PBXContainerItemProxy; 43 | containerPortal = 4A5B56AF2195E0E4005082B8 /* Project object */; 44 | proxyType = 1; 45 | remoteGlobalIDString = 4A5B56B62195E0E4005082B8; 46 | remoteInfo = SwiftVIPER; 47 | }; 48 | /* End PBXContainerItemProxy section */ 49 | 50 | /* Begin PBXFileReference section */ 51 | 4A5B56B72195E0E4005082B8 /* SwiftVIPER.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftVIPER.app; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 4A5B56BA2195E0E4005082B8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 53 | 4A5B56BC2195E0E4005082B8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 54 | 4A5B56BF2195E0E4005082B8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 55 | 4A5B56C12195E0E5005082B8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 56 | 4A5B56C42195E0E5005082B8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 57 | 4A5B56C62195E0E5005082B8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 4A5B56CB2195E0E5005082B8 /* SwiftVIPERTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftVIPERTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 4A5B56CF2195E0E5005082B8 /* SwiftVIPERTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftVIPERTests.swift; sourceTree = ""; }; 60 | 4A5B56D12195E0E5005082B8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | AE895346219981A700BA9616 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 62 | AE895347219981A700BA9616 /* DetailViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DetailViewController.xib; sourceTree = ""; }; 63 | AE89534A219981BC00BA9616 /* DetailRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailRouter.swift; sourceTree = ""; }; 64 | AE89534C219981DA00BA9616 /* DetailInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailInteractor.swift; sourceTree = ""; }; 65 | AE89534E219981EA00BA9616 /* DetailPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailPresenter.swift; sourceTree = ""; }; 66 | AE895350219981F800BA9616 /* DetailEntities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailEntities.swift; sourceTree = ""; }; 67 | AED17A0F21992ABB0000127C /* Routerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Routerable.swift; sourceTree = ""; }; 68 | AED17A1121992AD90000127C /* Presenterable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Presenterable.swift; sourceTree = ""; }; 69 | AED17A1321992AEF0000127C /* Viewable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Viewable.swift; sourceTree = ""; }; 70 | AED17A1521992B090000127C /* Interactorable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interactorable.swift; sourceTree = ""; }; 71 | AED17A1F21993C000000127C /* ListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = ""; }; 72 | AED17A2021993C000000127C /* ListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ListViewController.xib; sourceTree = ""; }; 73 | AED17A2321993C180000127C /* ListPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPresenter.swift; sourceTree = ""; }; 74 | AED17A2521993C2A0000127C /* ListRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRouter.swift; sourceTree = ""; }; 75 | AED17A2721993C450000127C /* ListInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListInteractor.swift; sourceTree = ""; }; 76 | AED17A2A219941450000127C /* Api.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Api.swift; sourceTree = ""; }; 77 | AED17A2C2199418D0000127C /* GitHubApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitHubApi.swift; sourceTree = ""; }; 78 | AED17A2F219941BA0000127C /* GitHubRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitHubRepository.swift; sourceTree = ""; }; 79 | AED17A342199540C0000127C /* CollectionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionExtension.swift; sourceTree = ""; }; 80 | AED17A3621995D900000127C /* ListEntities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListEntities.swift; sourceTree = ""; }; 81 | AED17A3821995E8E0000127C /* ListTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTableViewDataSource.swift; sourceTree = ""; }; 82 | AED17A3A219969950000127C /* TableViewItemDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewItemDataSource.swift; sourceTree = ""; }; 83 | /* End PBXFileReference section */ 84 | 85 | /* Begin PBXFrameworksBuildPhase section */ 86 | 4A5B56B42195E0E4005082B8 /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | 4A5B56C82195E0E5005082B8 /* Frameworks */ = { 94 | isa = PBXFrameworksBuildPhase; 95 | buildActionMask = 2147483647; 96 | files = ( 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | /* End PBXFrameworksBuildPhase section */ 101 | 102 | /* Begin PBXGroup section */ 103 | 4A5B56AE2195E0E4005082B8 = { 104 | isa = PBXGroup; 105 | children = ( 106 | 4A5B56B92195E0E4005082B8 /* SwiftVIPER */, 107 | 4A5B56CE2195E0E5005082B8 /* SwiftVIPERTests */, 108 | 4A5B56B82195E0E4005082B8 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 4A5B56B82195E0E4005082B8 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 4A5B56B72195E0E4005082B8 /* SwiftVIPER.app */, 116 | 4A5B56CB2195E0E5005082B8 /* SwiftVIPERTests.xctest */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | 4A5B56B92195E0E4005082B8 /* SwiftVIPER */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 4A5B56BA2195E0E4005082B8 /* AppDelegate.swift */, 125 | 4A5B56BC2195E0E4005082B8 /* ViewController.swift */, 126 | AED17A33219954000000127C /* Extensions */, 127 | AED17A29219940F70000127C /* Apis */, 128 | AED17A0E21992AA10000127C /* Protocols */, 129 | AED17A1D21993BD90000127C /* Screens */, 130 | 4A5B56DA2195E912005082B8 /* Resources */, 131 | ); 132 | path = SwiftVIPER; 133 | sourceTree = ""; 134 | }; 135 | 4A5B56CE2195E0E5005082B8 /* SwiftVIPERTests */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 4A5B56CF2195E0E5005082B8 /* SwiftVIPERTests.swift */, 139 | 4A5B56D12195E0E5005082B8 /* Info.plist */, 140 | ); 141 | path = SwiftVIPERTests; 142 | sourceTree = ""; 143 | }; 144 | 4A5B56DA2195E912005082B8 /* Resources */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 4A5B56BE2195E0E4005082B8 /* Main.storyboard */, 148 | 4A5B56C32195E0E5005082B8 /* LaunchScreen.storyboard */, 149 | 4A5B56C12195E0E5005082B8 /* Assets.xcassets */, 150 | 4A5B56C62195E0E5005082B8 /* Info.plist */, 151 | ); 152 | path = Resources; 153 | sourceTree = ""; 154 | }; 155 | AE8953452199818900BA9616 /* Detail */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | AE895346219981A700BA9616 /* DetailViewController.swift */, 159 | AE89534E219981EA00BA9616 /* DetailPresenter.swift */, 160 | AE89534C219981DA00BA9616 /* DetailInteractor.swift */, 161 | AE895350219981F800BA9616 /* DetailEntities.swift */, 162 | AE89534A219981BC00BA9616 /* DetailRouter.swift */, 163 | AE895347219981A700BA9616 /* DetailViewController.xib */, 164 | ); 165 | path = Detail; 166 | sourceTree = ""; 167 | }; 168 | AED17A0E21992AA10000127C /* Protocols */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | AED17A0F21992ABB0000127C /* Routerable.swift */, 172 | AED17A1121992AD90000127C /* Presenterable.swift */, 173 | AED17A1321992AEF0000127C /* Viewable.swift */, 174 | AED17A1521992B090000127C /* Interactorable.swift */, 175 | AED17A3A219969950000127C /* TableViewItemDataSource.swift */, 176 | ); 177 | path = Protocols; 178 | sourceTree = ""; 179 | }; 180 | AED17A1D21993BD90000127C /* Screens */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | AED17A1E21993BE50000127C /* List */, 184 | AE8953452199818900BA9616 /* Detail */, 185 | ); 186 | path = Screens; 187 | sourceTree = ""; 188 | }; 189 | AED17A1E21993BE50000127C /* List */ = { 190 | isa = PBXGroup; 191 | children = ( 192 | AED17A1F21993C000000127C /* ListViewController.swift */, 193 | AED17A3821995E8E0000127C /* ListTableViewDataSource.swift */, 194 | AED17A2321993C180000127C /* ListPresenter.swift */, 195 | AED17A2721993C450000127C /* ListInteractor.swift */, 196 | AED17A3621995D900000127C /* ListEntities.swift */, 197 | AED17A2521993C2A0000127C /* ListRouter.swift */, 198 | AED17A2021993C000000127C /* ListViewController.xib */, 199 | ); 200 | path = List; 201 | sourceTree = ""; 202 | }; 203 | AED17A29219940F70000127C /* Apis */ = { 204 | isa = PBXGroup; 205 | children = ( 206 | AED17A2A219941450000127C /* Api.swift */, 207 | AED17A2C2199418D0000127C /* GitHubApi.swift */, 208 | AED17A2E219941B10000127C /* Entities */, 209 | ); 210 | path = Apis; 211 | sourceTree = ""; 212 | }; 213 | AED17A2E219941B10000127C /* Entities */ = { 214 | isa = PBXGroup; 215 | children = ( 216 | AED17A2F219941BA0000127C /* GitHubRepository.swift */, 217 | ); 218 | path = Entities; 219 | sourceTree = ""; 220 | }; 221 | AED17A33219954000000127C /* Extensions */ = { 222 | isa = PBXGroup; 223 | children = ( 224 | AED17A342199540C0000127C /* CollectionExtension.swift */, 225 | ); 226 | path = Extensions; 227 | sourceTree = ""; 228 | }; 229 | /* End PBXGroup section */ 230 | 231 | /* Begin PBXNativeTarget section */ 232 | 4A5B56B62195E0E4005082B8 /* SwiftVIPER */ = { 233 | isa = PBXNativeTarget; 234 | buildConfigurationList = 4A5B56D42195E0E5005082B8 /* Build configuration list for PBXNativeTarget "SwiftVIPER" */; 235 | buildPhases = ( 236 | 4A5B56B32195E0E4005082B8 /* Sources */, 237 | 4A5B56B42195E0E4005082B8 /* Frameworks */, 238 | 4A5B56B52195E0E4005082B8 /* Resources */, 239 | ); 240 | buildRules = ( 241 | ); 242 | dependencies = ( 243 | ); 244 | name = SwiftVIPER; 245 | productName = SwiftVIPER; 246 | productReference = 4A5B56B72195E0E4005082B8 /* SwiftVIPER.app */; 247 | productType = "com.apple.product-type.application"; 248 | }; 249 | 4A5B56CA2195E0E5005082B8 /* SwiftVIPERTests */ = { 250 | isa = PBXNativeTarget; 251 | buildConfigurationList = 4A5B56D72195E0E5005082B8 /* Build configuration list for PBXNativeTarget "SwiftVIPERTests" */; 252 | buildPhases = ( 253 | 4A5B56C72195E0E5005082B8 /* Sources */, 254 | 4A5B56C82195E0E5005082B8 /* Frameworks */, 255 | 4A5B56C92195E0E5005082B8 /* Resources */, 256 | ); 257 | buildRules = ( 258 | ); 259 | dependencies = ( 260 | 4A5B56CD2195E0E5005082B8 /* PBXTargetDependency */, 261 | ); 262 | name = SwiftVIPERTests; 263 | productName = SwiftVIPERTests; 264 | productReference = 4A5B56CB2195E0E5005082B8 /* SwiftVIPERTests.xctest */; 265 | productType = "com.apple.product-type.bundle.unit-test"; 266 | }; 267 | /* End PBXNativeTarget section */ 268 | 269 | /* Begin PBXProject section */ 270 | 4A5B56AF2195E0E4005082B8 /* Project object */ = { 271 | isa = PBXProject; 272 | attributes = { 273 | LastSwiftUpdateCheck = 1000; 274 | LastUpgradeCheck = 1000; 275 | ORGANIZATIONNAME = "Tsubasa Hayashi"; 276 | TargetAttributes = { 277 | 4A5B56B62195E0E4005082B8 = { 278 | CreatedOnToolsVersion = 10.0; 279 | }; 280 | 4A5B56CA2195E0E5005082B8 = { 281 | CreatedOnToolsVersion = 10.0; 282 | TestTargetID = 4A5B56B62195E0E4005082B8; 283 | }; 284 | }; 285 | }; 286 | buildConfigurationList = 4A5B56B22195E0E4005082B8 /* Build configuration list for PBXProject "SwiftVIPER" */; 287 | compatibilityVersion = "Xcode 9.3"; 288 | developmentRegion = en; 289 | hasScannedForEncodings = 0; 290 | knownRegions = ( 291 | en, 292 | Base, 293 | ); 294 | mainGroup = 4A5B56AE2195E0E4005082B8; 295 | productRefGroup = 4A5B56B82195E0E4005082B8 /* Products */; 296 | projectDirPath = ""; 297 | projectRoot = ""; 298 | targets = ( 299 | 4A5B56B62195E0E4005082B8 /* SwiftVIPER */, 300 | 4A5B56CA2195E0E5005082B8 /* SwiftVIPERTests */, 301 | ); 302 | }; 303 | /* End PBXProject section */ 304 | 305 | /* Begin PBXResourcesBuildPhase section */ 306 | 4A5B56B52195E0E4005082B8 /* Resources */ = { 307 | isa = PBXResourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | 4A5B56C52195E0E5005082B8 /* LaunchScreen.storyboard in Resources */, 311 | 4A5B56C22195E0E5005082B8 /* Assets.xcassets in Resources */, 312 | AE895349219981A700BA9616 /* DetailViewController.xib in Resources */, 313 | AED17A2221993C000000127C /* ListViewController.xib in Resources */, 314 | 4A5B56C02195E0E4005082B8 /* Main.storyboard in Resources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | 4A5B56C92195E0E5005082B8 /* Resources */ = { 319 | isa = PBXResourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | }; 325 | /* End PBXResourcesBuildPhase section */ 326 | 327 | /* Begin PBXSourcesBuildPhase section */ 328 | 4A5B56B32195E0E4005082B8 /* Sources */ = { 329 | isa = PBXSourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | AED17A3B219969950000127C /* TableViewItemDataSource.swift in Sources */, 333 | AED17A2821993C450000127C /* ListInteractor.swift in Sources */, 334 | AED17A352199540C0000127C /* CollectionExtension.swift in Sources */, 335 | AE89534B219981BC00BA9616 /* DetailRouter.swift in Sources */, 336 | AED17A2621993C2A0000127C /* ListRouter.swift in Sources */, 337 | AE89534F219981EA00BA9616 /* DetailPresenter.swift in Sources */, 338 | 4A5B56BD2195E0E4005082B8 /* ViewController.swift in Sources */, 339 | AED17A2D2199418D0000127C /* GitHubApi.swift in Sources */, 340 | AED17A1021992ABB0000127C /* Routerable.swift in Sources */, 341 | AE895351219981F800BA9616 /* DetailEntities.swift in Sources */, 342 | AED17A3921995E8E0000127C /* ListTableViewDataSource.swift in Sources */, 343 | AED17A2421993C180000127C /* ListPresenter.swift in Sources */, 344 | AE895348219981A700BA9616 /* DetailViewController.swift in Sources */, 345 | AE89534D219981DA00BA9616 /* DetailInteractor.swift in Sources */, 346 | AED17A3721995D900000127C /* ListEntities.swift in Sources */, 347 | AED17A30219941BA0000127C /* GitHubRepository.swift in Sources */, 348 | AED17A2B219941450000127C /* Api.swift in Sources */, 349 | AED17A1421992AEF0000127C /* Viewable.swift in Sources */, 350 | AED17A1221992AD90000127C /* Presenterable.swift in Sources */, 351 | AED17A1621992B090000127C /* Interactorable.swift in Sources */, 352 | 4A5B56BB2195E0E4005082B8 /* AppDelegate.swift in Sources */, 353 | AED17A2121993C000000127C /* ListViewController.swift in Sources */, 354 | ); 355 | runOnlyForDeploymentPostprocessing = 0; 356 | }; 357 | 4A5B56C72195E0E5005082B8 /* Sources */ = { 358 | isa = PBXSourcesBuildPhase; 359 | buildActionMask = 2147483647; 360 | files = ( 361 | 4A5B56D02195E0E5005082B8 /* SwiftVIPERTests.swift in Sources */, 362 | ); 363 | runOnlyForDeploymentPostprocessing = 0; 364 | }; 365 | /* End PBXSourcesBuildPhase section */ 366 | 367 | /* Begin PBXTargetDependency section */ 368 | 4A5B56CD2195E0E5005082B8 /* PBXTargetDependency */ = { 369 | isa = PBXTargetDependency; 370 | target = 4A5B56B62195E0E4005082B8 /* SwiftVIPER */; 371 | targetProxy = 4A5B56CC2195E0E5005082B8 /* PBXContainerItemProxy */; 372 | }; 373 | /* End PBXTargetDependency section */ 374 | 375 | /* Begin PBXVariantGroup section */ 376 | 4A5B56BE2195E0E4005082B8 /* Main.storyboard */ = { 377 | isa = PBXVariantGroup; 378 | children = ( 379 | 4A5B56BF2195E0E4005082B8 /* Base */, 380 | ); 381 | name = Main.storyboard; 382 | sourceTree = ""; 383 | }; 384 | 4A5B56C32195E0E5005082B8 /* LaunchScreen.storyboard */ = { 385 | isa = PBXVariantGroup; 386 | children = ( 387 | 4A5B56C42195E0E5005082B8 /* Base */, 388 | ); 389 | name = LaunchScreen.storyboard; 390 | sourceTree = ""; 391 | }; 392 | /* End PBXVariantGroup section */ 393 | 394 | /* Begin XCBuildConfiguration section */ 395 | 4A5B56D22195E0E5005082B8 /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ALWAYS_SEARCH_USER_PATHS = NO; 399 | CLANG_ANALYZER_NONNULL = YES; 400 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 401 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 402 | CLANG_CXX_LIBRARY = "libc++"; 403 | CLANG_ENABLE_MODULES = YES; 404 | CLANG_ENABLE_OBJC_ARC = YES; 405 | CLANG_ENABLE_OBJC_WEAK = YES; 406 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 407 | CLANG_WARN_BOOL_CONVERSION = YES; 408 | CLANG_WARN_COMMA = YES; 409 | CLANG_WARN_CONSTANT_CONVERSION = YES; 410 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 411 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 412 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 413 | CLANG_WARN_EMPTY_BODY = YES; 414 | CLANG_WARN_ENUM_CONVERSION = YES; 415 | CLANG_WARN_INFINITE_RECURSION = YES; 416 | CLANG_WARN_INT_CONVERSION = YES; 417 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 418 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 419 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 422 | CLANG_WARN_STRICT_PROTOTYPES = YES; 423 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 424 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 425 | CLANG_WARN_UNREACHABLE_CODE = YES; 426 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 427 | CODE_SIGN_IDENTITY = "iPhone Developer"; 428 | COPY_PHASE_STRIP = NO; 429 | DEBUG_INFORMATION_FORMAT = dwarf; 430 | ENABLE_STRICT_OBJC_MSGSEND = YES; 431 | ENABLE_TESTABILITY = YES; 432 | GCC_C_LANGUAGE_STANDARD = gnu11; 433 | GCC_DYNAMIC_NO_PIC = NO; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_OPTIMIZATION_LEVEL = 0; 436 | GCC_PREPROCESSOR_DEFINITIONS = ( 437 | "DEBUG=1", 438 | "$(inherited)", 439 | ); 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_VARIABLE = YES; 446 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 447 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 448 | MTL_FAST_MATH = YES; 449 | ONLY_ACTIVE_ARCH = YES; 450 | SDKROOT = iphoneos; 451 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 452 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 453 | }; 454 | name = Debug; 455 | }; 456 | 4A5B56D32195E0E5005082B8 /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ALWAYS_SEARCH_USER_PATHS = NO; 460 | CLANG_ANALYZER_NONNULL = YES; 461 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 462 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 463 | CLANG_CXX_LIBRARY = "libc++"; 464 | CLANG_ENABLE_MODULES = YES; 465 | CLANG_ENABLE_OBJC_ARC = YES; 466 | CLANG_ENABLE_OBJC_WEAK = YES; 467 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 468 | CLANG_WARN_BOOL_CONVERSION = YES; 469 | CLANG_WARN_COMMA = YES; 470 | CLANG_WARN_CONSTANT_CONVERSION = YES; 471 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 472 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 473 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 474 | CLANG_WARN_EMPTY_BODY = YES; 475 | CLANG_WARN_ENUM_CONVERSION = YES; 476 | CLANG_WARN_INFINITE_RECURSION = YES; 477 | CLANG_WARN_INT_CONVERSION = YES; 478 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 479 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 480 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 481 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 482 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 483 | CLANG_WARN_STRICT_PROTOTYPES = YES; 484 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 485 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 486 | CLANG_WARN_UNREACHABLE_CODE = YES; 487 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 488 | CODE_SIGN_IDENTITY = "iPhone Developer"; 489 | COPY_PHASE_STRIP = NO; 490 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 491 | ENABLE_NS_ASSERTIONS = NO; 492 | ENABLE_STRICT_OBJC_MSGSEND = YES; 493 | GCC_C_LANGUAGE_STANDARD = gnu11; 494 | GCC_NO_COMMON_BLOCKS = YES; 495 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 496 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 497 | GCC_WARN_UNDECLARED_SELECTOR = YES; 498 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 499 | GCC_WARN_UNUSED_FUNCTION = YES; 500 | GCC_WARN_UNUSED_VARIABLE = YES; 501 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 502 | MTL_ENABLE_DEBUG_INFO = NO; 503 | MTL_FAST_MATH = YES; 504 | SDKROOT = iphoneos; 505 | SWIFT_COMPILATION_MODE = wholemodule; 506 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 507 | VALIDATE_PRODUCT = YES; 508 | }; 509 | name = Release; 510 | }; 511 | 4A5B56D52195E0E5005082B8 /* Debug */ = { 512 | isa = XCBuildConfiguration; 513 | buildSettings = { 514 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 515 | CODE_SIGN_STYLE = Automatic; 516 | INFOPLIST_FILE = "$(SRCROOT)/SwiftVIPER/Resources/Info.plist"; 517 | LD_RUNPATH_SEARCH_PATHS = ( 518 | "$(inherited)", 519 | "@executable_path/Frameworks", 520 | ); 521 | PRODUCT_BUNDLE_IDENTIFIER = app.yokurin.SwiftVIPER; 522 | PRODUCT_NAME = "$(TARGET_NAME)"; 523 | SWIFT_VERSION = 4.2; 524 | TARGETED_DEVICE_FAMILY = "1,2"; 525 | }; 526 | name = Debug; 527 | }; 528 | 4A5B56D62195E0E5005082B8 /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 532 | CODE_SIGN_STYLE = Automatic; 533 | INFOPLIST_FILE = "$(SRCROOT)/SwiftVIPER/Resources/Info.plist"; 534 | LD_RUNPATH_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | "@executable_path/Frameworks", 537 | ); 538 | PRODUCT_BUNDLE_IDENTIFIER = app.yokurin.SwiftVIPER; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | SWIFT_VERSION = 4.2; 541 | TARGETED_DEVICE_FAMILY = "1,2"; 542 | }; 543 | name = Release; 544 | }; 545 | 4A5B56D82195E0E5005082B8 /* Debug */ = { 546 | isa = XCBuildConfiguration; 547 | buildSettings = { 548 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 549 | BUNDLE_LOADER = "$(TEST_HOST)"; 550 | CODE_SIGN_STYLE = Automatic; 551 | INFOPLIST_FILE = SwiftVIPERTests/Info.plist; 552 | LD_RUNPATH_SEARCH_PATHS = ( 553 | "$(inherited)", 554 | "@executable_path/Frameworks", 555 | "@loader_path/Frameworks", 556 | ); 557 | PRODUCT_BUNDLE_IDENTIFIER = app.yokurin.SwiftVIPERTests; 558 | PRODUCT_NAME = "$(TARGET_NAME)"; 559 | SWIFT_VERSION = 4.2; 560 | TARGETED_DEVICE_FAMILY = "1,2"; 561 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftVIPER.app/SwiftVIPER"; 562 | }; 563 | name = Debug; 564 | }; 565 | 4A5B56D92195E0E5005082B8 /* Release */ = { 566 | isa = XCBuildConfiguration; 567 | buildSettings = { 568 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 569 | BUNDLE_LOADER = "$(TEST_HOST)"; 570 | CODE_SIGN_STYLE = Automatic; 571 | INFOPLIST_FILE = SwiftVIPERTests/Info.plist; 572 | LD_RUNPATH_SEARCH_PATHS = ( 573 | "$(inherited)", 574 | "@executable_path/Frameworks", 575 | "@loader_path/Frameworks", 576 | ); 577 | PRODUCT_BUNDLE_IDENTIFIER = app.yokurin.SwiftVIPERTests; 578 | PRODUCT_NAME = "$(TARGET_NAME)"; 579 | SWIFT_VERSION = 4.2; 580 | TARGETED_DEVICE_FAMILY = "1,2"; 581 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftVIPER.app/SwiftVIPER"; 582 | }; 583 | name = Release; 584 | }; 585 | /* End XCBuildConfiguration section */ 586 | 587 | /* Begin XCConfigurationList section */ 588 | 4A5B56B22195E0E4005082B8 /* Build configuration list for PBXProject "SwiftVIPER" */ = { 589 | isa = XCConfigurationList; 590 | buildConfigurations = ( 591 | 4A5B56D22195E0E5005082B8 /* Debug */, 592 | 4A5B56D32195E0E5005082B8 /* Release */, 593 | ); 594 | defaultConfigurationIsVisible = 0; 595 | defaultConfigurationName = Release; 596 | }; 597 | 4A5B56D42195E0E5005082B8 /* Build configuration list for PBXNativeTarget "SwiftVIPER" */ = { 598 | isa = XCConfigurationList; 599 | buildConfigurations = ( 600 | 4A5B56D52195E0E5005082B8 /* Debug */, 601 | 4A5B56D62195E0E5005082B8 /* Release */, 602 | ); 603 | defaultConfigurationIsVisible = 0; 604 | defaultConfigurationName = Release; 605 | }; 606 | 4A5B56D72195E0E5005082B8 /* Build configuration list for PBXNativeTarget "SwiftVIPERTests" */ = { 607 | isa = XCConfigurationList; 608 | buildConfigurations = ( 609 | 4A5B56D82195E0E5005082B8 /* Debug */, 610 | 4A5B56D92195E0E5005082B8 /* Release */, 611 | ); 612 | defaultConfigurationIsVisible = 0; 613 | defaultConfigurationName = Release; 614 | }; 615 | /* End XCConfigurationList section */ 616 | }; 617 | rootObject = 4A5B56AF2195E0E4005082B8 /* Project object */; 618 | } 619 | -------------------------------------------------------------------------------- /SwiftVIPER.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftVIPER.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftVIPER.xcodeproj/xcuserdata/hayashi.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftVIPER.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SwiftVIPER/Apis/Api.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Api.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public enum ApiError: Int, Error { 12 | case recieveNilResponse = 0, 13 | recieveErrorHttpStatus, 14 | recieveNilBody, 15 | failedParse 16 | } 17 | 18 | public enum HttpMethod: String { 19 | case get = "GET" 20 | case post = "POST" 21 | } 22 | 23 | public protocol Request { 24 | var url: String { get } 25 | func params() -> [(key: String, value: String)] 26 | } 27 | 28 | protocol ApiProtocol { 29 | func request(_ httpMethod: HttpMethod, request: Request, onSuccess: @escaping (Data, URLResponse?) -> Void, onError: @escaping (Error) -> Void) 30 | } 31 | 32 | open class ApiTask: ApiProtocol { 33 | 34 | public var httpHeader: [String: String]? = ["content-type": "application/json"] 35 | public var timeoutInterval: TimeInterval = 60 36 | public var cachePolicy: URLRequest.CachePolicy = .reloadIgnoringLocalCacheData 37 | static let apiTaskSession: URLSession = URLSession(configuration: URLSessionConfiguration.ephemeral) 38 | 39 | public init() {} 40 | 41 | public func request(_ httpMethod: HttpMethod, request: Request, onSuccess: @escaping (Data, URLResponse?) -> Void, onError: @escaping (Error) -> Void) { 42 | let urlRequest = URLRequestCreator.create(httpMethod: httpMethod, 43 | request: request, 44 | header: httpHeader, 45 | timeoutInterval: timeoutInterval, 46 | cachePolicy: cachePolicy) 47 | let task = ApiTask.apiTaskSession.dataTask(with: urlRequest, completionHandler: {(data, response, error) in 48 | #if DEBUG 49 | // Warning: print is very slow speed so comment out default 50 | //self.debugResponse(with: urlRequest, data: data, response: response) 51 | #endif 52 | 53 | if let error = error { 54 | onError(error) 55 | return 56 | } 57 | if let responseError = ApiTask.check(response: response) { 58 | onError(responseError) 59 | return 60 | } 61 | guard let data = data else { 62 | onError(ApiError.recieveNilBody) 63 | return 64 | } 65 | onSuccess(data, response) 66 | }) 67 | task.resume() 68 | } 69 | 70 | static func createError(_ code: ApiError, _ info: [String: Any]?) -> NSError { 71 | return NSError(domain: "ApiError", code: code.rawValue, userInfo: info) 72 | } 73 | 74 | static internal func check(response: URLResponse?) -> NSError? { 75 | guard let notNilResponse = response else { 76 | return createError(.recieveNilResponse, nil) 77 | } 78 | 79 | let httpResponse = notNilResponse as! HTTPURLResponse 80 | guard (200..<300) ~= httpResponse.statusCode else { 81 | return createError(.recieveErrorHttpStatus, ["statusCode": httpResponse.statusCode]) 82 | } 83 | return nil 84 | } 85 | 86 | private func debugResponse(with urlRequest: URLRequest, data: Data?, response: URLResponse?) { 87 | print(#file, #function) 88 | let res: [String] = [ 89 | "url: \(urlRequest.url?.absoluteString ?? "")", 90 | "status: \((response as? HTTPURLResponse)?.statusCode ?? 0)" 91 | ] 92 | let detail: [String] = [ 93 | "response: \(response ?? URLResponse())", 94 | "data: \(String(describing: String(data: data ?? Data(), encoding: .utf8)))" 95 | ] 96 | print("Response: {\(res.joined(separator: ", "))}") 97 | print("Response Detail: {\(detail.joined(separator: ", "))}") 98 | } 99 | } 100 | 101 | public class URLRequestCreator { 102 | 103 | static func create(httpMethod: HttpMethod, 104 | request: Request, 105 | header: [String: String]?, 106 | timeoutInterval: TimeInterval, 107 | cachePolicy: URLRequest.CachePolicy) -> URLRequest { 108 | 109 | let urlRequest = NSMutableURLRequest() 110 | urlRequest.httpMethod = httpMethod.rawValue 111 | urlRequest.timeoutInterval = timeoutInterval 112 | urlRequest.cachePolicy = cachePolicy 113 | if let httpHeader = header { 114 | httpHeader.forEach { 115 | urlRequest.setValue($0.1, forHTTPHeaderField: $0.0) 116 | } 117 | } 118 | if httpMethod == .get { 119 | urlRequest.url = URL(string: appendGetParameter(url: request.url, parameter: URLEncoder.encode(request.params()))) 120 | } else { 121 | urlRequest.url = URL(string: request.url) 122 | urlRequest.httpBody = URLEncoder.encode(request.params()).data(using: String.Encoding.utf8, allowLossyConversion: false) 123 | } 124 | #if DEBUG 125 | debugRequest(with: urlRequest as URLRequest) 126 | #endif 127 | return urlRequest as URLRequest 128 | } 129 | 130 | static func appendGetParameter(url: String, parameter: String) -> String { 131 | let separator: String 132 | if url.contains("?") { 133 | if ["?", "&"].contains(url.suffix(1)) { 134 | separator = "" 135 | } else { 136 | separator = "&" 137 | } 138 | } else { 139 | separator = "?" 140 | } 141 | return [url, parameter].joined(separator: separator) 142 | } 143 | 144 | static private func debugRequest(with urlRequest: URLRequest) { 145 | let details: [String] = [ 146 | "timeoutInterval: \(urlRequest.timeoutInterval)", 147 | "method: \(urlRequest.httpMethod ?? "")", 148 | "cachePolicy: \(urlRequest.cachePolicy)", 149 | "allHTTPHeaderFields: \(urlRequest.allHTTPHeaderFields ?? [:])", 150 | "body: \(String(data: urlRequest.httpBody ?? Data(), encoding: .utf8) ?? "")" 151 | ] 152 | let detail: String = details.joined(separator: ", ") 153 | print(#file, #function) 154 | print("Request: {url: \(urlRequest.url?.absoluteString ?? "")}") 155 | print("Request Detail: {\(detail)}") 156 | } 157 | } 158 | 159 | public class URLEncoder { 160 | public class func encode(_ parameters: [(key: String, value: String)]) -> String { 161 | let encodedString: String = parameters.compactMap { 162 | guard let value = $0.value.addingPercentEncoding(withAllowedCharacters: .alphanumerics) else { return nil } 163 | return "\($0.key)=\(value)" 164 | }.joined(separator: "&") 165 | return encodedString 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /SwiftVIPER/Apis/Entities/GitHubRepository.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GitHubRepository.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct GitHubRepository: Codable { 12 | let id: Int 13 | let fullName: String 14 | let description: String 15 | let stargazersCount: Int 16 | let url: String 17 | 18 | private enum CodingKeys: String, CodingKey { 19 | case id 20 | case fullName = "full_name" 21 | case description 22 | case stargazersCount = "stargazers_count" 23 | case url = "html_url" 24 | } 25 | } 26 | 27 | struct SearchRepositoriesResponse: Codable { 28 | let items: [GitHubRepository] 29 | } 30 | -------------------------------------------------------------------------------- /SwiftVIPER/Apis/GitHubApi.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GitHubApi.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct GitHubApi { 12 | private static var baseUrl = "https://api.github.com" 13 | 14 | struct SearchLanguageRequest: Request { 15 | var url: String { 16 | return baseUrl + "/search/repositories" 17 | } 18 | let language: String 19 | let page: Int 20 | 21 | func params() -> [(key: String, value: String)] { 22 | return [ 23 | (key: "q", value: language), 24 | (key: "sort", value : "stars"), 25 | (key: "page", value : "\(page)") 26 | ] 27 | } 28 | } 29 | 30 | func search(with request: SearchLanguageRequest, onSuccess: @escaping (SearchRepositoriesResponse) -> Void, onError: @escaping (Error) -> Void) { 31 | ApiTask().request(.get, request: request, onSuccess: { (data, session) in 32 | do { 33 | let response = try self.parse(data) 34 | onSuccess(response) 35 | } catch { 36 | onError(ApiError.failedParse) 37 | } 38 | }, onError: onError) 39 | } 40 | 41 | private func parse(_ data: Data) throws -> SearchRepositoriesResponse { 42 | let response: SearchRepositoriesResponse = try JSONDecoder().decode(SearchRepositoriesResponse.self, from: data) 43 | return response 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SwiftVIPER/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftVIPER 4 | // 5 | // Created by Tsubasa Hayashi on 2018/11/10. 6 | // Copyright © 2018 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /SwiftVIPER/Extensions/CollectionExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionExtension.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Collection { 12 | subscript (safe index: Index) -> Element? { 13 | return indices.contains(index) ? self[index] : nil 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SwiftVIPER/Protocols/Interactorable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Interactorable.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol Interactorable { 12 | // nop 13 | } 14 | -------------------------------------------------------------------------------- /SwiftVIPER/Protocols/Presenterable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Presenterable.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol Presenterable { 12 | // associatedtype V: Viewable 13 | // associatedtype I: Interactorable 14 | // associatedtype R: Routerable 15 | // associatedtype E: PresenterEntities 16 | // var dependencies: (view: V, router: R, interactor: I, entities: E) { get } 17 | 18 | associatedtype I: Interactorable 19 | associatedtype R: Routerable 20 | var dependencies: (interactor: I, router: R) { get } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /SwiftVIPER/Protocols/Routerable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Routerable.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | protocol Routerable { 13 | var view: Viewable! { get } 14 | 15 | func dismiss(animated: Bool) 16 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) 17 | func pop(animated: Bool) 18 | } 19 | 20 | extension Routerable { 21 | func dismiss(animated: Bool) { 22 | view.dismiss(animated: animated) 23 | } 24 | func dismiss(animated: Bool, completion: @escaping (() -> Void)) { 25 | view.dismiss(animated: animated, _completion: completion) 26 | } 27 | 28 | func pop(animated: Bool) { 29 | view.pop(animated: animated) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftVIPER/Protocols/TableViewItemDataSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewItemDataSource.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | protocol TableViewItemDataSource: AnyObject { 13 | var numberOfItems: Int { get } 14 | 15 | func itemCell(tableView: UITableView, indexPath: IndexPath) -> UITableViewCell 16 | func didSelect(tableView: UITableView, indexPath: IndexPath) 17 | } 18 | -------------------------------------------------------------------------------- /SwiftVIPER/Protocols/Viewable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Viewable.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | protocol Viewable: AnyObject { 13 | func push(_ vc: UIViewController, animated: Bool) 14 | func present(_ vc: UIViewController, animated: Bool) 15 | func pop(animated: Bool) 16 | func dismiss(animated: Bool) 17 | func dismiss(animated: Bool, _completion: @escaping (() -> Void)) 18 | } 19 | 20 | extension Viewable where Self: UIViewController { 21 | 22 | func push(_ vc: UIViewController, animated: Bool) { 23 | self.navigationController?.pushViewController(vc, animated: animated) 24 | } 25 | 26 | func present(_ vc: UIViewController, animated: Bool) { 27 | self.present(vc, animated: animated, completion: nil) 28 | } 29 | 30 | func pop(animated: Bool) { 31 | self.navigationController?.popViewController(animated: animated) 32 | } 33 | 34 | func dismiss(animated: Bool) { 35 | self.dismiss(animated: animated, completion: nil) 36 | } 37 | 38 | func dismiss(animated: Bool, _completion: @escaping (() -> Void)) { 39 | self.dismiss(animated: animated, completion: _completion) 40 | } 41 | 42 | var supportedInterfaceOrientations: UIInterfaceOrientationMask { 43 | return .portrait 44 | } 45 | var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { 46 | return .portrait 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /SwiftVIPER/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /SwiftVIPER/Resources/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SwiftVIPER/Resources/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 | -------------------------------------------------------------------------------- /SwiftVIPER/Resources/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /SwiftVIPER/Resources/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailEntities.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailEntities.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct DetailEntryEntity { 12 | let gitHubRepository: GitHubRepository 13 | init(gitHubRepository: GitHubRepository) { 14 | self.gitHubRepository = gitHubRepository 15 | } 16 | } 17 | 18 | struct DetailEntities { 19 | let entryEntity: DetailEntryEntity 20 | 21 | init(entryEntity: DetailEntryEntity) { 22 | self.entryEntity = entryEntity 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailInteractor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailInteractor.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol DetailInteractorOutputs: AnyObject { 12 | 13 | } 14 | 15 | final class DetailInteractor: Interactorable { 16 | weak var presenter: DetailInteractorOutputs? 17 | } 18 | 19 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailPresenter.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import WebKit 11 | 12 | typealias DetailPresenterDependencies = ( 13 | interactor: DetailInteractor, 14 | router: DetailRouterOutput 15 | ) 16 | 17 | final class DetailPresenter: Presenterable { 18 | 19 | internal var entities: DetailEntities 20 | private weak var view: DetailViewInputs! 21 | let dependencies: DetailPresenterDependencies 22 | 23 | init(entities: DetailEntities, 24 | view: DetailViewInputs, 25 | dependencies: DetailPresenterDependencies) 26 | { 27 | self.view = view 28 | self.entities = entities 29 | self.dependencies = dependencies 30 | } 31 | 32 | } 33 | 34 | extension DetailPresenter: DetailViewOutputs { 35 | 36 | func viewDidLoad() { 37 | view.requestWebView(with: URLRequest(url: URL(string: entities.entryEntity.gitHubRepository.url)!)) 38 | view.indicatorView(animate: true) 39 | view.configure(entities: entities) 40 | } 41 | 42 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { 43 | view.indicatorView(animate: false) 44 | } 45 | } 46 | 47 | extension DetailPresenter: DetailInteractorOutputs {} 48 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailRouter.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | struct DetailRouterInput { 13 | 14 | private func view(entryEntity: DetailEntryEntity) -> DetailViewController { 15 | let view = DetailViewController() 16 | let interactor = DetailInteractor() 17 | let dependencies = DetailPresenterDependencies(interactor: interactor, router: DetailRouterOutput(view)) 18 | let presenter = DetailPresenter(entities: DetailEntities(entryEntity: entryEntity), view: view, dependencies: dependencies) 19 | view.presenter = presenter 20 | interactor.presenter = presenter 21 | return view 22 | } 23 | 24 | func push(from: Viewable, entryEntity: DetailEntryEntity) { 25 | let view = self.view(entryEntity: entryEntity) 26 | from.push(view, animated: true) 27 | } 28 | 29 | func present(from: Viewable, entryEntity: DetailEntryEntity) { 30 | let nav = UINavigationController(rootViewController: view(entryEntity: entryEntity)) 31 | from.present(nav, animated: true) 32 | } 33 | } 34 | 35 | final class DetailRouterOutput: Routerable { 36 | 37 | private(set) weak var view: Viewable! 38 | 39 | init(_ view: Viewable) { 40 | self.view = view 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import WebKit 11 | 12 | 13 | protocol DetailViewInputs: AnyObject { 14 | func configure(entities: DetailEntities) 15 | func requestWebView(with request: URLRequest) 16 | func indicatorView(animate: Bool) 17 | } 18 | 19 | protocol DetailViewOutputs: AnyObject { 20 | func viewDidLoad() 21 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) 22 | } 23 | 24 | 25 | final class DetailViewController: UIViewController { 26 | 27 | internal var presenter: DetailViewOutputs? 28 | 29 | @IBOutlet private weak var indicatorView: UIActivityIndicatorView! 30 | @IBOutlet private weak var webView: WKWebView! { 31 | didSet { 32 | webView.navigationDelegate = self 33 | } 34 | } 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | presenter?.viewDidLoad() 39 | } 40 | } 41 | 42 | 43 | extension DetailViewController: WKNavigationDelegate { 44 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { 45 | presenter?.webView(webView, didFinish: navigation) 46 | } 47 | } 48 | 49 | extension DetailViewController: DetailViewInputs { 50 | 51 | func configure(entities: DetailEntities) { 52 | navigationItem.title = entities.entryEntity.gitHubRepository.fullName 53 | } 54 | 55 | func requestWebView(with request: URLRequest) { 56 | webView.load(request) 57 | } 58 | 59 | func indicatorView(animate: Bool) { 60 | DispatchQueue.main.async { [weak self] in 61 | _ = animate ? self?.indicatorView.startAnimating() : self?.indicatorView.stopAnimating() 62 | } 63 | } 64 | 65 | } 66 | 67 | extension DetailViewController: Viewable {} 68 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/Detail/DetailViewController.xib: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListEntities.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListEntities.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct ListEntryEntity { 12 | let language: String 13 | } 14 | 15 | final class ListEntities { 16 | let entryEntity: ListEntryEntity 17 | 18 | var gitHubRepositories: [GitHubRepository] = [] 19 | 20 | class SearchApiState { 21 | var pageCount = 1 22 | var isFetching = false 23 | } 24 | 25 | var searchApiState = SearchApiState() 26 | 27 | init(entryEntity: ListEntryEntity) { 28 | self.entryEntity = entryEntity 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListInteractor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListInteractor.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol ListInteractorOutputs: AnyObject { 12 | func onSuccessSearch(res: SearchRepositoriesResponse) 13 | func onErrorSearch(error: Error) 14 | } 15 | 16 | final class ListInteractor: Interactorable { 17 | 18 | weak var presenter: ListInteractorOutputs? 19 | 20 | func fetchSearch(language: String, page: Int) { 21 | let request = GitHubApi.SearchLanguageRequest(language: language, page: page) 22 | GitHubApi().search(with: request, onSuccess: { [weak self] res in 23 | self?.presenter?.onSuccessSearch(res: res) 24 | //print(res) 25 | }) { [weak self] error in 26 | self?.presenter?.onErrorSearch(error: error) 27 | //print(error) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListPresenter.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | /// Must not import UIKit 11 | 12 | typealias ListPresenterDependencies = ( 13 | interactor: ListInteractor, 14 | router: ListRouterOutput 15 | ) 16 | 17 | final class ListPresenter: Presenterable { 18 | 19 | internal var entities: ListEntities 20 | private weak var view: ListViewInputs! 21 | let dependencies: ListPresenterDependencies 22 | 23 | init(entities: ListEntities, 24 | view: ListViewInputs, 25 | dependencies: ListPresenterDependencies) 26 | { 27 | self.view = view 28 | self.entities = entities 29 | self.dependencies = dependencies 30 | } 31 | 32 | } 33 | 34 | extension ListPresenter: ListViewOutputs { 35 | func viewDidLoad() { 36 | view.configure(entities: entities) 37 | entities.searchApiState.isFetching = true 38 | dependencies.interactor.fetchSearch(language: entities.entryEntity.language, page: entities.searchApiState.pageCount) 39 | } 40 | 41 | func onCloseButtonTapped() { 42 | dependencies.router.dismiss(animated: true) 43 | } 44 | 45 | func onReachBottom() { 46 | guard !entities.searchApiState.isFetching else { return } 47 | entities.searchApiState.isFetching = true 48 | dependencies.interactor.fetchSearch(language: entities.entryEntity.language, page: entities.searchApiState.pageCount) 49 | view.indicatorView(animate: true) 50 | } 51 | } 52 | 53 | extension ListPresenter: ListInteractorOutputs { 54 | func onSuccessSearch(res: SearchRepositoriesResponse) { 55 | entities.searchApiState.isFetching = false 56 | entities.searchApiState.pageCount += 1 57 | entities.gitHubRepositories += res.items 58 | view.reloadTableView(tableViewDataSource: ListTableViewDataSource(entities: entities, presenter: self)) 59 | view.indicatorView(animate: false) 60 | } 61 | 62 | func onErrorSearch(error: Error) { 63 | view.indicatorView(animate: false) 64 | } 65 | } 66 | 67 | extension ListPresenter: ListTableViewDataSourceOutputs { 68 | func didSelect(_ gitHubRepository: GitHubRepository) { 69 | dependencies.router.transitionDetail(gitHubRepository: gitHubRepository) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListRouter.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | struct ListRouterInput { 13 | 14 | private func view(entryEntity: ListEntryEntity) -> ListViewController { 15 | let view = ListViewController() 16 | let interactor = ListInteractor() 17 | let dependencies = ListPresenterDependencies(interactor: interactor, router: ListRouterOutput(view)) 18 | let presenter = ListPresenter(entities: ListEntities(entryEntity: entryEntity), view: view, dependencies: dependencies) 19 | view.presenter = presenter 20 | view.tableViewDataSource = ListTableViewDataSource(entities: presenter.entities, presenter: presenter) 21 | interactor.presenter = presenter 22 | return view 23 | } 24 | 25 | func push(from: Viewable, entryEntity: ListEntryEntity) { 26 | let view = self.view(entryEntity: entryEntity) 27 | from.push(view, animated: true) 28 | } 29 | 30 | func present(from: Viewable, entryEntity: ListEntryEntity) { 31 | let nav = UINavigationController(rootViewController: view(entryEntity: entryEntity)) 32 | from.present(nav, animated: true) 33 | } 34 | } 35 | 36 | final class ListRouterOutput: Routerable { 37 | 38 | private(set) weak var view: Viewable! 39 | 40 | init(_ view: Viewable) { 41 | self.view = view 42 | } 43 | 44 | func transitionDetail(gitHubRepository: GitHubRepository) { 45 | DetailRouterInput().push(from: view, entryEntity: DetailEntryEntity(gitHubRepository: gitHubRepository)) 46 | } 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListTableViewDataSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListTableViewDataSource.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | protocol ListTableViewDataSourceOutputs: AnyObject { 13 | func didSelect(_ gitHubRepository: GitHubRepository) 14 | } 15 | 16 | final class ListTableViewDataSource: TableViewItemDataSource { 17 | 18 | private weak var entities: ListEntities! 19 | private weak var presenter: ListTableViewDataSourceOutputs? 20 | 21 | init(entities: ListEntities, presenter: ListTableViewDataSourceOutputs) { 22 | self.entities = entities 23 | self.presenter = presenter 24 | } 25 | 26 | var numberOfItems: Int { 27 | return entities.gitHubRepositories.count 28 | } 29 | 30 | func itemCell(tableView: UITableView, indexPath: IndexPath) -> UITableViewCell { 31 | guard let repo = entities.gitHubRepositories[safe: indexPath.row] else { return UITableViewCell() } 32 | let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "subtitle") 33 | cell.textLabel?.text = "\(repo.fullName)" 34 | cell.detailTextLabel?.textColor = UIColor.lightGray 35 | cell.detailTextLabel?.text = "\(repo.description)" 36 | return cell 37 | } 38 | 39 | func didSelect(tableView: UITableView, indexPath: IndexPath) { 40 | tableView.deselectRow(at: indexPath, animated: true) 41 | guard let selectedRepo = entities.gitHubRepositories[safe: indexPath.row] else { return } 42 | presenter?.didSelect(selectedRepo) 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListViewController.swift 3 | // SwiftVIPER 4 | // 5 | // Created by 林 翼 on 2018/11/12. 6 | // Copyright © 2018年 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol ListViewInputs: AnyObject { 12 | func configure(entities: ListEntities) 13 | func reloadTableView(tableViewDataSource: ListTableViewDataSource) 14 | func indicatorView(animate: Bool) 15 | } 16 | 17 | protocol ListViewOutputs: AnyObject { 18 | func viewDidLoad() 19 | func onCloseButtonTapped() 20 | func onReachBottom() 21 | } 22 | 23 | final class ListViewController: UIViewController { 24 | 25 | internal var presenter: ListViewOutputs? 26 | internal var tableViewDataSource: TableViewItemDataSource? 27 | 28 | @IBOutlet private weak var tableView: UITableView! { 29 | didSet { 30 | tableView.delegate = self 31 | tableView.dataSource = self 32 | } 33 | } 34 | @IBOutlet private weak var indicatorView: UIActivityIndicatorView! 35 | @IBOutlet private weak var closeButton: UIButton! 36 | 37 | override func viewDidLoad() { 38 | super.viewDidLoad() 39 | closeButton.isHidden = navigationController?.viewControllers.count != 1 40 | presenter?.viewDidLoad() 41 | } 42 | 43 | @IBAction func onCloseButtonTapped(_ sender: UIButton) { 44 | presenter?.onCloseButtonTapped() 45 | } 46 | 47 | } 48 | 49 | extension ListViewController: ListViewInputs { 50 | 51 | func configure(entities: ListEntities) { 52 | navigationItem.title = "\(entities.entryEntity.language) Repositories" 53 | } 54 | 55 | func reloadTableView(tableViewDataSource: ListTableViewDataSource) { 56 | self.tableViewDataSource = tableViewDataSource 57 | DispatchQueue.main.async { [weak self] in 58 | self?.tableView.reloadData() 59 | } 60 | } 61 | 62 | func indicatorView(animate: Bool) { 63 | DispatchQueue.main.async { [weak self] in 64 | self?.tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: animate ? 50 : 0, right: 0) 65 | _ = animate ? self?.indicatorView.startAnimating() : self?.indicatorView.stopAnimating() 66 | } 67 | } 68 | } 69 | 70 | extension ListViewController: UITableViewDelegate, UITableViewDataSource { 71 | 72 | func numberOfSections(in tableView: UITableView) -> Int { 73 | return 1 74 | } 75 | 76 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 77 | return tableViewDataSource?.numberOfItems ?? 0 78 | } 79 | 80 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 81 | return tableViewDataSource?.itemCell(tableView: tableView, indexPath: indexPath) ?? UITableViewCell() 82 | } 83 | 84 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 85 | tableView.deselectRow(at: indexPath, animated: true) 86 | tableViewDataSource?.didSelect(tableView: tableView, indexPath: indexPath) 87 | } 88 | 89 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 90 | let visibleLastIndexPath = tableView.visibleCells.compactMap { [weak self] in 91 | self?.tableView.indexPath(for: $0) 92 | }.last 93 | guard let last = visibleLastIndexPath, last.row > (tableViewDataSource?.numberOfItems ?? 0) - 2 else { return } 94 | presenter?.onReachBottom() 95 | } 96 | } 97 | 98 | extension ListViewController: Viewable {} 99 | -------------------------------------------------------------------------------- /SwiftVIPER/Screens/List/ListViewController.xib: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 49 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /SwiftVIPER/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftVIPER 4 | // 5 | // Created by Tsubasa Hayashi on 2018/11/10. 6 | // Copyright © 2018 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class ViewController: UIViewController { 12 | 13 | @IBAction func pushListScreenAction(_ sender: Any) { 14 | ListRouterInput().push(from: self, entryEntity: ListEntryEntity(language: "Swift")) 15 | } 16 | 17 | @IBAction func presentListScreenAction(_ sender: Any) { 18 | ListRouterInput().present(from: self, entryEntity: ListEntryEntity(language: "Swift")) 19 | } 20 | 21 | } 22 | 23 | extension ViewController: Viewable {} 24 | -------------------------------------------------------------------------------- /SwiftVIPERTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SwiftVIPERTests/SwiftVIPERTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftVIPERTests.swift 3 | // SwiftVIPERTests 4 | // 5 | // Created by Tsubasa Hayashi on 2018/11/10. 6 | // Copyright © 2018 Tsubasa Hayashi. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SwiftVIPER 11 | 12 | class SwiftVIPERTests: XCTestCase { 13 | 14 | override func setUp() { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | --------------------------------------------------------------------------------