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
- UICollectionView
- ribs
- Clean Code
- SWIFT
- 리펙터링
- rxswift
- HIG
- 스위프트
- UITextView
- tableView
- 리팩토링
- clean architecture
- MVVM
- swift documentation
- uiscrollview
- Human interface guide
- Refactoring
- Observable
- combine
- Xcode
- ios
- uitableview
- RxCocoa
- 애니메이션
- swiftUI
- 클린 코드
- map
- 리펙토링
- collectionview
- Protocol
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] device 분기 방법, 시뮬레이터 분기문 (targetEnvironment, os, arch, swift) 본문
iOS 응용 (swift)
[iOS - swift] device 분기 방법, 시뮬레이터 분기문 (targetEnvironment, os, arch, swift)
jake-kim 2024. 1. 27. 14:50시뮬레이터 분기 방법
- #if targetEnvironment(simulator) 사용
#if targetEnvironment(simulator)
print("simulator")
#else
print("no simulator")
#endif
아키텍쳐, os 분기 방법
- 아키텍쳐는 arch() 사용, os는 os() 사용
- os() 안에 넣을 수 있는 것
- macOS, iOS, watchOS, tvOS, Linux, Windows, FreeBSD, Android, PS4
- arch() 안에 넣을 수 있는 것
- x86_64, arm, arm64, i386, powerpc64, powerpc64le, s390x
ex) 사용 예시
// macOS 시뮬레이터 분기
#if (arch(i386) || arch(x86_64)) && (!os(macOS))
print("Simulator")
#else
print("Device")
#endif
// iOS 시뮬레이터 분기
#if (arch(i386) || arch(x86_64)) && os(iOS)
// iOS simulator code
#endif
Swift 버전 분기 방법
- swift()사용
swift(>=2.2)
* 참고
'iOS 응용 (swift)' 카테고리의 다른 글
[iOS - swift] 1. 추상화 - 개념과 목적 (1) | 2024.01.29 |
---|---|
[iOS - swift] 추상화하기 목차 (0) | 2024.01.28 |
[iOS - swift] nested protocol 개념 (#Swift 5.10) (0) | 2024.01.24 |
[iOS - swift] CustomStringConvertible 개념 (#description, #print 커스텀, #String(describing)) (0) | 2024.01.23 |
[iOS - swift] ipa 파일 reverse engineering 시작하기 (#ghidra, NSA, National Security Agency) (3) | 2024.01.17 |
Comments