Widget building blocks

설명 들어도 잘 모르는 구성 블록들 차차 알아가보자

Hello world

widget extension 생성 (file이 아니고 target에 있음)

When creating the widget extension, Xcode has autogenerated two important files: WidgetExtension.swift, WidgetExtension.intentdefinition

Intent configuration은 위젯을 configure하는 것을 유저에게 허락함

Provider() 는 위젯에 데이터를 제공해

뷰는 데이터를 디스플레이함

익스텐션에 @main 태그가 붙어있다는 것은 진입점이라는 뜻

CryptoWidgetExtensionEntryView
SimpleEntry
WidgetPreviewContext
  1. 추가하고 싶은 데이터를 SimpleEntry struct에 추가!

    1. 커스텀 데이터일 경우 위젯에서도 사용가능하도록 타켓에 추가
      1. 'cannot find type 'customData' in scope
    2. 스유끼리는 되는데 UIKit에서도 되려나?
    3. 타켓 변경시 에러 대량 발생 !! Provider에 적절한 데이터가 없기 때문, 일단 더미 데이터 추가 후 차후 진짜 데이터 적용해보자
    SimpleEntry(date: Date(), configuration: ConfigurationIntent(), ***coins: coins***)
    

<aside> 💡 시뮬레이터를 돌릴 때는 기존 앱을 최소 한번 실행한 후에 위젯을 타겟으로 시뮬레이터 돌릴 것

</aside>

Untitled

Multiple-size widgets

Placeholder