アプリ制作を始める
Published by @SoNiceInfo at 6/24/2020
Xcodeをダウンロード
SwiftUIでiOSアプリを作るには最新のXcodeが必要です。
用意してないひとはApp Storeからダウンロードします。
「Xcode」をMac App Storeで
新しいプロジェクトを作成
1. Xcodeを開きCreate a new Xcode projectを選択します

2. 作成したいアプリに近いイメージのテンプレートを選択します

Choose a template for your new projectと聞かれるので必要なテンプレートを選択します。
ここではSingle View Appを選択します。
3. プロジェクトに関する情報を入力します

- Team/Organizationに関する部分は作成後も変更できます。
- User InterfaceはSwiftUIを選択します。
- Nextボタンを押して保存場所を選択します。
4. Hello World

これでSwiftUIプロジェクトを始めることができます。
最初に開いている
ContentView.swift
がメインページ(HTML
でいうindex.html
)になります。Buildする
アプリを実行する前にBuildする必要があります。⌘ + B
でBuildします。もしくはXcodeの画面の左上の再生ボタンでもBuildできます。
Build時間はコードの量やBuildするMacの性能によって変わります。
実行する
作ったアプリはシミュレータ, iPhoneで実行することができます。1. シミュレータ, iPhoneどちらで実行するか選択します
Xcode左上のプロジェクト名の右にあるiPhoneの機種名を変更することで選択できます。
2. ⌘ + R
で実行します
3. 実行結果を確認します

おまけ

macOS 10.15以上を使っていると
Canvas
を使って簡単に表示を検証できます。(必要要件を満たしていないとこのように使用できません。使いたいひとはmacOSをアップデートしましょう)