Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 스위프트
- 리펙토링
- tableView
- SWIFT
- Protocol
- uiscrollview
- Refactoring
- 리팩토링
- Observable
- Clean Code
- Human interface guide
- swiftUI
- map
- combine
- Xcode
- RxCocoa
- clean architecture
- swift documentation
- 리펙터링
- 애니메이션
- MVVM
- 클린 코드
- uitableview
- collectionview
- HIG
- ribs
- UICollectionView
- UITextView
- ios
- rxswift
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] 5. RIBs 프로젝트 초기 세팅 (with cocoapod) 본문
Architecture (swift)/RIBs
[iOS - swift] 5. RIBs 프로젝트 초기 세팅 (with cocoapod)
jake-kim 2021. 4. 28. 23:30RIBs 설치
- 프로젝트 생성
- pod 설치
- pod 'RIBs'할 경우 RxSwift버전은 4.x버전으로 설최되므로, tag를 명시하여 RxSwift 5.x버전이 받아지도록 설정
pod 'RIBs', :git => 'https://github.com/uber/RIBs.git', :tag => '0.9.2'
storyboard, SceneDelegate 삭제
- storyboard 삭제
- Main.storyboard 삭제
- target의 main interface 에서 설정된 스토리보드 해제
- SceneDelegate 삭제
- SceneDelegate.swift 삭제
- info.plist에 Application Scene Manifest 삭제
- AppDelegate.swift에 UISsceneSession Lifecycle 관련 메소드 2개 삭제
RIBs 세팅
- Root RIB 생성
- AppComponent 추가, AppStart 그룹 하위로 AppDelegate도 이동
// AppComponent.swift
import RIBs
class AppComponent: Component<EmptyDependency>, RootDependency {
init() {
super.init(dependency: EmptyComponent())
}
}
Root이므로 builder를 생성할 때 listener 파라미터 제거
- RootBuilder.swift
- build 함수의 파라미터 제거
- build 함수의 반환값 변경: RootRouting -> LaunchRouting
// RootBuilder.swift
...
protocol RootBuildable: Buildable {
// func build(withListener listener: RootListener) -> RootRouting
func build() -> LaunchRouting
}
final class RootBuilder: Builder<RootDependency>, RootBuildable {
override init(dependency: RootDependency) {
super.init(dependency: dependency)
}
func build() -> LaunchRouting {
let component = RootComponent(dependency: dependency)
let viewController = RootViewController()
let interactor = RootInteractor(presenter: viewController)
return RootRouter(interactor: interactor, viewController: viewController)
}
}
- RootRouter.swift가 상속받고 있는 ViewableRouter를 LaunchRouter로 수정
// RootRouter.swift
...
final class RootRouter: LaunchRouter<RootInteractable, RootViewControllable>, RootRouting {
override init(interactor: RootInteractable, viewController: RootViewControllable) {
super.init(interactor: interactor, viewController: viewController)
interactor.router = self
}
}
AppDelegate에서 RootBuilder를 통해 LaunchRouter 객체 획득
import UIKit
import RIBs
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
self.window = window
let launchRouter = RootBuilder(dependency: AppComponent()).build()
self.launchRouter = launchRouter
launchRouter.launch(from: window)
return true
}
// MARK: - Private
private var launchRouter: LaunchRouting?
}
* 빌드 성공 확인
'Architecture (swift) > RIBs' 카테고리의 다른 글
[iOS - swift] 6-2) RIBs 구조 Todo 앱 만들기 (detach child) (0) | 2021.04.29 |
---|---|
[iOS - swift] 6-1) RIBs 구조 Todo 앱 만들기 (attach child, Listener Interface) (0) | 2021.04.28 |
[iOS - swift] 4-6) RIBs 튜토리얼 (Deeplinking, Workflows, Actionable item) (0) | 2021.04.26 |
[iOS - swift] 4-5) RIBs 튜토리얼 (Dependency Injection, Rx Stream) (0) | 2021.04.22 |
[iOS - swift] 4-4) RIBs 튜토리얼 (LoggedIn에 OffGame 붙이기) (0) | 2021.04.21 |
Comments