[iOS] 코드베이스 프로젝트 세팅 / Codebase Project

2024. 12. 30. 20:45🍏/Xcode

 

1. Main.storyboard(Main) 삭제(move trash)

 

 

2. Info.plist에서 Storyboard Name 삭제

- 를 눌러 삭제하자

- 를 눌러 삭제하자

 

3. UIKit Main Storyboard File Base Name 삭제

delete 키를 눌러 삭제하자

Module > TARGETS > Build Settings > filter(story)

delete 키를 눌러 삭제하자

 

4. SceneDelegate의 willConnectTo 파라미터 함수 수정

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
let window = UIWindow(windowScene: windowScene)
let vc = ViewController()
window.rootViewController = vc
self.window = window
window.makeKeyAndVisible()
}

 

5. 테스트

아래 코드를 넣어 화면이 제대로 나오는지 Build & Run 해봅시다. (command + r)

import UIKit
final class ViewController: UIViewController {
private let testLabel: UILabel = {
let label = UILabel()
label.text = "초기세팅 테스트"
label.font = .systemFont(ofSize: 32)
return label
}()
override func viewDidLoad() {
super.viewDidLoad()
setUI()
setLayout()
}
private func setUI() {
view.addSubview(testLabel)
view.backgroundColor = .green
}
private func setLayout() {
testLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
testLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
testLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 300)
])
}
}