[Bankey - Login] 스토리보드 없이 iOS 프로젝트 만들기

Seoyoung Lee·2022년 2월 24일
0

Professional iOS

목록 보기
1/12

Udemy의 The Swift Arcade Professional iOS 강의를 듣고 정리한 글입니다.


storyboard는 아직 보편화되지 않았고, 협업할 때 불편함이 있다. 따라서 전문적인 iOS 개발을 위해서는 스토리보드 없이 코드로만 개발하는 능력이 필요하다.

1. 불필요한 파일들 제거

SceneDelegate, Main.storyboard 파일 제거

2. info.plist 엔트리 업데이트

  1. Xcode 프로젝트 내 파일 목록에서 command + shift + f 후 main 검색
  2. INFOPLIST_KEY_UIMainStoryboardFile = Main 값 제거
  3. Info.plist에서 Application Scene Manifest key 통째로 제거

3. AppDelegate 업데이트

  1. command + shift + j : 현재 작업 중인 파일로 이동하는 단축키

  2. AppDelegate 클래스 내 모든 내용을 지워준다.

  3. AppDelegate 클래스 안에 아래 코드를 추가한다.

    		var window: UIWindow?
        
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.makeKeyAndVisible()
            window?.backgroundColor = .white
            window?.rootViewController = ViewController()
            
            return true
        }

🤔 AppDelegate 파일이 뭐하는 놈이지?

AppDelegate.swift 소스파일은 두 가지 역할을 한다.

1. AppDelegate 클래스를 정의한다.

app delegate는 AppDelegate 클래스의 인스턴스로, app delegate는 우리 앱의 객체이다. (app delegate와 AppDelegate는 다른 놈들이다!)

app delegate는 앱의 상태에 따라 응답하는 콘텐츠가 그려지는 창(window)을 만든다.

즉, AppDelegate.swift가 있으므로 AppDelegate 클래스가 만들어지고, 이 AppDelegate 클래스의 인스턴스인 app delegate가 우리 앱의 내용이 그려질 창(window)를 만드는 것이다.

2. AppDelegate.swift는 entry point와 앱의 입력 이벤트를 전달하는 run loop를 생성한다.

이 작업은 UIApplicationMain 속성에 의해 수행되며, 이 속성은파일의 맨 위에 나타난다. (Xcode 12 이후에는 @main 으로 대체되었다.) UIApplicationMain 속성을 사용하는 것은 UIApplicationMain 함수를 호출하고 AppDelegate 클래스의 이름을 delegate 클래스에 전달하는 것과 동일하다. 이에 대한 응답으로 시스템은 응용프로그램 객체(application object)를 생성한다. 응용프로그램 객체는 app의 life cycle을 담당한다.

또한 시스템은 AppDelegate 클래스의 인스턴스를 생성하고 이를 응용프로그램 객체에 할당한다.

마지막으로, 시스템은 앱을 실행한다.

✔️ 참고링크

profile
나의 내일은 파래 🐳

0개의 댓글

관련 채용 정보