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 | 29 | 30 |
Tags
- 알고리즘
- 리액트
- uikit
- dispatchqueue
- 스위프트
- 영남대
- 스유
- 웹
- swift concurrency
- c++
- 네트워크
- 문법
- TCA
- spritekit
- 후기
- widget
- 운영체제
- 위젯킷
- widgetkit
- 멋쟁이사자처럼
- Swift
- composable architecture
- 백준
- 컴퓨터그래픽스
- SwiftUI
- 멋사
- Protocol
- 1일1알골
- 대외활동
- cs
Archives
- Today
- Total
맛동산이
앱사이즈 최적화 하는 5가지 방법 본문
공식 홈페이지 가이드
최적화를 하기 앞서서, 앱 사이즈 체크
앱사이즈 최적화 보고서
- 통합워크플로우를 생성해서 app thinning size report를 자동생성하도록 할수있다.
- 이를 통해 매번 빌드 배포시, app thinning size를 체크할수 있게 된다.
앱사이즈 최적화 보고서 만드는법
1. 직접 생성하는 법
- Archive your app in Xcode.
- Export your archived app as an Ad Hoc, Development, or Enterprise build.
- In the sheet for setting the development distribution options, choose “All compatible device variants” for app thinning.
- Sign your app and export it to your Mac.
2. 자동으로 생성하도록 xcodebuilder를 사용하는 법
- Add the key “thinning” in your export options plist file with the value “
” (Keep the angular braces in your export option plist file.) - add the following command in your build script to export the archive with report
xcodebuild -exportArchive -archivePath
보고서를 보는법
- A universal IPA file for older devices. This single IPA file contains assets and binaries for all variants of your app.
- Thinned IPA files for each variant of your app. These files contain assets and binaries for only one variant.
- In the output folder, it generates the app size report file with the name “App Thinning Size Report.txt”
앱 사이즈 줄이는 대표적인 방법
- 에셋 카탈로그 사용하기
- App thinning 사용하기(app thinning, slicing, bitcode, on demand resource)
- 사용되지 않는 코드와 리소스 제거
- 코드를 통한 최적화
- LLVM optimization levels
app thinning
app thinning과, on demand resource, slicing이 가능하도록 설정
사용되지 않는 코드 제거와 최적화
아래의 3가지를 효과적으로 사용해서 최적화를 진행한다.
- Structs instead of Classes: Structs take up less memory than classes, making them a great choice for small data structures.
- Enumerations: Enumerations can be used to represent a set of values, which can help reduce the size of your code.
- Optionals: Optionals can help you avoid unnecessary code and reduce the size of your app.
LLVM 최적화
None [-O0]
- No attempt to optimize the code.
- The goal is to reduce the cost of compilation
- Makes debugging produce the expected results and statements are independent
- Used during development when you are focused on debugging and need a fast compile time. Not for shipping your executable.
Fast [-O, O1]
- Does simple optimizations to Increase code performance while minimizing the impact to compile time.
Faster [-O2]
- Increases both compilation time and the performance of generated code.
Fastest [-O3]
- This option can increase the size of generated code as the compiler performs aggressive inlining of functions. (This option is generally not recommended.)
Fastest, Smallest [-Os]
- Performs all optimizations that do not typically increase code size.
- Suitable for shipping code because it gives your executable a smaller memory footprint.
Fastest, Aggressive optimization [-Ofast]
- This setting enables Fastest but also enables aggressive optimizations that may break strict standards compliance but should work well on well-behaved code.
반응형
'앱 > Swift' 카테고리의 다른 글
Swift) CollectionView CompositionalLayout-2 (0) | 2024.03.02 |
---|---|
Swift) 컬렉션뷰 (CollectionView) 레이아웃 -1 (0) | 2024.03.02 |
Swift) RxDataSource 사용하는법 정리 (0) | 2024.02.25 |
Swift) URLSession, async await을 사용하여(parameter, header, body 세팅까지) (0) | 2024.02.25 |
Combine과 Rx가 잘 이해가 안가는 사람을 위한 설명(feat. SwiftUI에 비유해서) (2) | 2024.01.01 |