앱사이즈 최적화 하는 5가지 방법

2024. 2. 25. 17:30·앱/Swift

공식 홈페이지 가이드

bookmark

bookmark

최적화를 하기 앞서서, 앱 사이즈 체크

앱사이즈 최적화 보고서

  • 통합워크플로우를 생성해서 app thinning size report를 자동생성하도록 할수있다.
  • 이를 통해 매번 빌드 배포시, app thinning size를 체크할수 있게 된다.

앱사이즈 최적화 보고서 만드는법

1. 직접 생성하는 법

  1. Archive your app in Xcode.
  2. Export your archived app as an Ad Hoc, Development, or Enterprise build.
  3. In the sheet for setting the development distribution options, choose “All compatible device variants” for app thinning.
  4. 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 .xcarchive -exportPath -exportOptionsPlist .plist

보고서를 보는법

  • 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이 가능하도록 설정

Untitled.png

사용되지 않는 코드 제거와 최적화

아래의 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 최적화

bookmark

bookmark

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.

Untitled.png

반응형

'앱 > 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
'앱/Swift' 카테고리의 다른 글
  • Swift) CollectionView CompositionalLayout-2
  • Swift) 컬렉션뷰 (CollectionView) 레이아웃 -1
  • Swift) RxDataSource 사용하는법 정리
  • Swift) URLSession, async await을 사용하여(parameter, header, body 세팅까지)
진ddang
진ddang
안녕하세요 진땅의 개발자 블로그 입니다. 피드백은 환영입니다. 깃헙 : https://github.com/it794613
    반응형
  • 진ddang
    맛동산이
    진ddang
  • 전체
    오늘
    어제
    • 분류 전체보기 (199)
      • 일기 그리고 목표 (1)
      • 웹 (20)
        • 리액트 (19)
      • 앱 (115)
        • Swift 문법 (15)
        • Swift (65)
        • SwiftUI (32)
        • 리액트 네이티브 (3)
      • CS (30)
        • 컴퓨터그래픽스 (8)
        • 운영체제 (6)
        • 네트워크 (16)
      • 알고리즘 (13)
        • 백준 (12)
        • 프로그래머스 (1)
      • 대외활동 (7)
        • ict한이음(2022.04) (2)
        • 멋쟁이 사자처럼 (5)
        • Apple Developer Academy (0)
      • 다양한 내용들 (8)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    위젯킷
    웹
    Swift
    멋사
    스유
    c++
    uikit
    ReactorKit
    swift concurrency
    리액트
    Protocol
    컴퓨터그래픽스
    문법
    대외활동
    멋쟁이사자처럼
    composable architecture
    후기
    TCA
    스위프트
    운영체제
    cs
    dispatchqueue
    백준
    영남대
    spritekit
    SwiftUI
    네트워크
    widget
    widgetkit
    알고리즘
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
진ddang
앱사이즈 최적화 하는 5가지 방법
상단으로

티스토리툴바