Thuta Learning
ရှာဖွေရန်
BasicMobile Developmentintermediate

ပထမဆုံး App — Hello World

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • ပထမဆုံး App — Hello World ကို ကြောက်စရာမလိုအောင် နားလည်မယ်
  • ကိုယ်တိုင် Xcode/SwiftUI code ကို run ကြည့်တတ်မယ်
  • Real project ထဲမှာ ဒီ concept ကို ချက်ချင်း အသုံးချတတ်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

App တစ်ခုကို Simulator (ဒါမှမဟုတ် physical device) ပေါ်မှာ run ဖို့ Run (▶ ဒါမှမဟုတ် Cmd+R) ကို နှိပ်ရုံပါပဲ — Xcode က code ကို compile လုပ်ပြီး, app bundle ကို build ကာ Simulator ပေါ် install/launch လုပ်ပေးပါတယ်။ `ContentView` ကို `WindowGroup { ContentView() }` ထဲမှာ root view အနေနဲ့ ခေါ်ထားရင် app ဖွင့်တာနဲ့ အဲဒီ UI ချက်ချင်း ပေါ်လာပါလိမ့်မယ်.

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

`ContentView.swift` ထဲမှာ `var body: some View { Greeting(name: "iOS") }` လို့ ရေးထားရင်, app ကို Run လိုက်တာနဲ့ Simulator screen ပေါ်မှာ 'Hello, iOS!' ဆိုတဲ့ text ချက်ချင်း ပေါ်လာပါလိမ့်မယ် — ဒါက သင့်ရဲ့ ပထမဆုံး တကယ့် iOS app ပါပဲ.

အတူတူ ကြည့်မယ်

swift
struct ContentView: View {
    var body: some View {
        Greeting(name: "iOS")
    }
}
You should see
Simulator screen ပေါ်မှာ 'Hello, iOS!' ဆိုတဲ့ text ကို တွေ့ရမည်။

၅ မိနစ် စမ်းကြည့်

`ContentView.swift` ကို edit လုပ်ပြီး `Greeting(name: "iOS")` ထည့်ကာ Run (Cmd+R) နှိပ်ကြည့်ပါ — Simulator ပေါ် app ချက်ချင်း launch ဖြစ်တာ confirm လုပ်ကြည့်ပါ။

သတိလေးတစ်ချက်

ပထမဆုံး build/Simulator boot က (Mac performance အလိုက်) မိနစ်အနည်းငယ် ကြာနိုင်ပါတယ် — 'stuck နေတယ်' လို့ မထင်ဘဲ progress indicator ကို စောင့်ကြည့်ပါ။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Simulator ကို boot မလုပ်ထားဘဲ Run နှိပ်ခြင်း — Simulator boot ကြာနိုင်ပါတယ်, ပထမဆုံးအကြိမ်ဆို especially
  • Build error ရှိနေရင် error message ကို ဖတ်ရှုချသွားပြီး 'ဘာမှမသိဘူး' ဆိုပြီး ဆက်မကြိုးစားခြင်း — Issue Navigator ရဲ့ error line number ကို ကိုးကားပြီး debug လုပ်တတ်ဖို့ အရေးကြီးပါတယ်

အခု ကိုယ်တိုင် စမ်းကြည့်

`ContentView.swift` ကို edit လုပ်ပြီး `Greeting(name: "iOS")` ထည့်ကာ Run (Cmd+R) နှိပ်ကြည့်ပါ — Simulator ပေါ် app ချက်ချင်း launch ဖြစ်တာ confirm လုပ်ကြည့်ပါ။

You'll know it worked when: Simulator screen ပေါ်မှာ 'Hello, iOS!' ဆိုတဲ့ text ကို တွေ့ရမည်။

ပထမဆုံး App — Hello World | Thuta Learning