1. 프로젝트 생성하기


2. Main.storyboard 삭제

삭제만 한 상태로 프로젝트를 그냥 시작하게 되면 오류가 발생합니다!
Main.storyboard를 찾을 수 없다는 오류가 뜨게됩니다.
'Could not find a storyboard named 'Main' in bundle NSBundle [파일위치] WeatherClone.app> (loaded)'
terminating with uncaught exception of type NSException

3. Storyboard 오류 해결하기
- info.plist에 가서 storyboard 이름을 삭제시킵니다.

- 프로젝트 targets 설정에서 BuildSettings - info.plist Value - UIKit Main Storyboard File Base Name (Main) 경로도 찾아서 삭제

4. 초기 ViewController (Root) 설정
- SceneDelegate.swift 설정
iOS 13 이전의 AppDelegate의 UI LifeCycle의 역할을 IOS 13부터는 SceneDelegate에게 넘겨주어, Scene(화면)과 관련된 부분을 SceneDelegate가 담당하게 되었다. iOS 13부터 SceneDelegate에서 scene을 지정해주어야합니다.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// guard let _ = (scene as? UIWindowScene) else { return } - 삭제
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
}
ViewController타입의 인스턴스(객체) 를 생성해준 뒤 window의 rootViewController에 해당 인스턴스를 대입
여기서 rootViewController는 Storyboard상에서 'Is Initial View Controller'로 설정해주는 컨트롤러이다!
😮NavigationController를 rootViewController로 지정하고 싶을때는?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene) // SceneDelegate의 프로퍼티에 설정해줌
let mainViewController = ViewController() // 맨 처음 보여줄 ViewController
let navigationController = UINavigationController(rootViewController : mainViewController)
// NavigationController에 처음으로 보여질 화면을 rootView로 지정
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
5. 확인
import UIKit
class ViewController: UIViewController {
private let tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
setBackGroundUI()
}
func setBackGroundUI() {
let backgroundImage = UIImageView(frame: UIScreen.main.bounds)
backgroundImage.image = UIImage(named: "skyBackGround")
backgroundImage.contentMode = .scaleAspectFill
self.view.insertSubview(backgroundImage, at: 0)
}
}

'기타 > iOS🍎' 카테고리의 다른 글
1. 프로젝트 생성하기


2. Main.storyboard 삭제

삭제만 한 상태로 프로젝트를 그냥 시작하게 되면 오류가 발생합니다!
Main.storyboard를 찾을 수 없다는 오류가 뜨게됩니다.
'Could not find a storyboard named 'Main' in bundle NSBundle [파일위치] WeatherClone.app> (loaded)'
terminating with uncaught exception of type NSException

3. Storyboard 오류 해결하기
- info.plist에 가서 storyboard 이름을 삭제시킵니다.

- 프로젝트 targets 설정에서 BuildSettings - info.plist Value - UIKit Main Storyboard File Base Name (Main) 경로도 찾아서 삭제

4. 초기 ViewController (Root) 설정
- SceneDelegate.swift 설정
iOS 13 이전의 AppDelegate의 UI LifeCycle의 역할을 IOS 13부터는 SceneDelegate에게 넘겨주어, Scene(화면)과 관련된 부분을 SceneDelegate가 담당하게 되었다. iOS 13부터 SceneDelegate에서 scene을 지정해주어야합니다.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// guard let _ = (scene as? UIWindowScene) else { return } - 삭제
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: UIScreen.main.bounds)
window?.windowScene = windowScene
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
}
ViewController타입의 인스턴스(객체) 를 생성해준 뒤 window의 rootViewController에 해당 인스턴스를 대입
여기서 rootViewController는 Storyboard상에서 'Is Initial View Controller'로 설정해주는 컨트롤러이다!
😮NavigationController를 rootViewController로 지정하고 싶을때는?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene) // SceneDelegate의 프로퍼티에 설정해줌
let mainViewController = ViewController() // 맨 처음 보여줄 ViewController
let navigationController = UINavigationController(rootViewController : mainViewController)
// NavigationController에 처음으로 보여질 화면을 rootView로 지정
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
5. 확인
import UIKit
class ViewController: UIViewController {
private let tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
setBackGroundUI()
}
func setBackGroundUI() {
let backgroundImage = UIImageView(frame: UIScreen.main.bounds)
backgroundImage.image = UIImage(named: "skyBackGround")
backgroundImage.contentMode = .scaleAspectFill
self.view.insertSubview(backgroundImage, at: 0)
}
}
