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 |
Tags
- 리펙터링
- 리펙토링
- 애니메이션
- RxCocoa
- combine
- 리팩토링
- collectionview
- UITextView
- Protocol
- uitableview
- UICollectionView
- tableView
- HIG
- Clean Code
- swiftUI
- MVVM
- Xcode
- 클린 코드
- SWIFT
- 스위프트
- rxswift
- Human interface guide
- map
- clean architecture
- uiscrollview
- Refactoring
- ios
- swift documentation
- ribs
- Observable
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - SwiftUI] 튜토리얼 - 17. iOS앱 프로젝트에 macOS 맥북 앱 구현 방법 (1) (맥 앱, 타겟 추가 방법) 본문
iOS 튜토리얼 (SwiftUI)
[iOS - SwiftUI] 튜토리얼 - 17. iOS앱 프로젝트에 macOS 맥북 앱 구현 방법 (1) (맥 앱, 타겟 추가 방법)
jake-kim 2022. 7. 20. 01:52* 프로젝트 파일은 애플 튜토리얼 사이트 참고
프로젝트에 macOS 타겟 추가하는 방법
- 앱을 미리 보고 실행 할 수 있으려면 macOS가 Monterey 이상에서만 가능
- File > New > Target 선택
- macOS > App 선택
- 생성
- 생겨난 파일들 확인
- 미리보기를 사용하기 위해서, scheme 설정
- MacLandmarks > My Mac으로 설정
- ContentView를 선택하여 preview 동작 확인
- MacLandmarks 하위에 있는 MacLandmarksApp을 삭제
- 이전 포스팅 글에서 알아본 watchOS 앱과 마찬가지로 이미 있는 LandmarksApp를 사용할것이기 때문
- iOS에서 만든 파일들을 macOS에서도 사용할 수 있도록 타겟 멤버십 추가
- 주의) 사진에는 LandmarkDetail 파일도 macOS 타겟 추가했지만, LandmarkDetail은 macOS전용으로 다음 포스팅에서 만들 것이므로 선택 해제
- Assets에 앱 아이콘 추가
- XCode 네비게이터의 MacLandmarks/Assets > AppIcon 오른쪽 마우스 클릭 > Finder로 열기
- 프로젝트 루트/Recources/AppIcon.appiconset안의 내용을 위에서 열은 폴더 안, AppIcon.appiconset에 복붙
- 아이콘 복붙 완료
- 맥앱의 ContentView 클릭
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
- frame(minWidth:minHeight:)를 이용하여 맥앱 크기 적당하게 보여주기
struct ContentView: View {
var body: some View {
LandmarkList()
.frame(minWidth: 700, minHeight: 300) // <-
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.environmentObject(ModelData())
}
}
* macOS UI 구현은 다음 포스팅 글 참고
* 참고
https://developer.apple.com/tutorials/swiftui/creating-a-macos-app
'iOS 튜토리얼 (SwiftUI)' 카테고리의 다른 글
Comments