ponshu-room-lite/docs/archive/IOS_SETUP_GUIDE.md

7.5 KiB
Raw Permalink Blame History

iOS開発環境セットアップ完全手順

📋 前提条件チェックリスト

ハードウェア

  • 2017 MacBook Air以降
  • メモリ8GB以上
  • ストレージ空き容量30GB以上

ソフトウェア

  • macOS Big Sur 11.x2017 MacBook Air最大
  • Xcode 13.2.1Big Sur最大対応
  • Flutter SDK 3.10.1以降

Step 1: Flutter iOS toolchain確認5分

flutter doctor -v

# 期待される出力
[] Flutter (Channel stable, 3.10.1, on macOS Big Sur 11.x)
[] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.x

[] Android Studio (version 2023.x)
[!] iOS deploy (iOS 12.0 or higher required)

トラブルシュート:

# Xcodeが見つからない
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

# Xcode license未承認
sudo xcodebuild -license accept

# CocoaPods未インストール
sudo gem install cocoapods

Step 2: iOSプロジェクトファイル生成10分

cd ~/posimai-project/ponshu_room_lite

# 既存ファイルを保持しつつiOSファイル生成
flutter create .

# 確認
ls -la ios/
# 期待: Runner.xcodeproj, Runner.xcworkspace, Podfile等が生成される

注意: 既存のAndroidファイルは影響を受けません


Step 3: Podfile確認と設定15分

3-1. Podfile内容確認

cat ios/Podfile

3-2. プラットフォーム設定

# ios/Podfile自動生成後の確認
platform :ios, '12.0'  # iOS 12.0以上対応2017デバイス対応

# CocoaPods 1.11.x用設定
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

3-3. 依存関係インストール

cd ios
pod install  # 初回は5-10分かかる

# 成功メッセージ
# Pod installation complete! There are X dependencies from the Podfile...

cd ..

トラブルシュート:

# エラー: CocoaPods could not find compatible versions
pod repo update  # Podリポジトリ更新10-15分
pod install

# エラー: ffi gem missing
sudo gem install ffi

# 2017 MacBook Airでメモリ不足
# 他のアプリケーションを終了してから再試行

Step 4: Firebase iOS設定30分

4-1. Firebase Console設定

  1. https://console.firebase.google.com/
  2. プロジェクト「ponshu-room」選択
  3. プロジェクトの設定全般
  4. アプリを追加iOS

4-2. Bundle ID設定

Bundle ID: com.posimai.ponshu_room_lite
Apple App Nickname: Ponshu Room Lite
App Store ID: (後で設定)

4-3. GoogleService-Info.plist取得

  1. Firebase ConsoleからGoogleService-Info.plistをダウンロード
  2. ファイル配置:
mv ~/Downloads/GoogleService-Info.plist ios/Runner/
  1. 確認:
cat ios/Runner/GoogleService-Info.plist | grep BUNDLE_ID
# 期待: com.posimai.ponshu_room_lite

4-4. REVERSED_CLIENT_ID取得

cat ios/Runner/GoogleService-Info.plist | grep REVERSED_CLIENT_ID
# 出力例: <string>com.googleusercontent.apps.123456789-xxxx</string>

この値を次のステップで使用


Step 5: Info.plist完全設定20分

open ios/Runner/Info.plist
# Xcode または テキストエディタで開く

5-1. 権限記述(既存確認 + 追加)

<!-- 既存(確認のみ) -->
<key>NSCameraUsageDescription</key>
<string>日本酒のラベルを撮影するためにカメラを使用します</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>撮影した日本酒の写真をギャラリーに保存します</string>

<!-- 追加必須 -->
<key>NSPhotoLibraryUsageDescription</key>
<string>日本酒の写真をギャラリーから選択します</string>

5-2. Google Sign-In設定

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- Step 4-4で取得したREVERSED_CLIENT_IDを貼り付け -->
      <string>com.googleusercontent.apps.123456789-xxxx</string>
    </array>
  </dict>
</array>

5-3. 設定確認

# NSPhotoLibraryUsageDescriptionが存在するか確認
grep -A 1 "NSPhotoLibraryUsageDescription" ios/Runner/Info.plist

# CFBundleURLSchemesが設定されているか確認
grep -A 5 "CFBundleURLTypes" ios/Runner/Info.plist

Step 6: Xcodeでプロジェクトを開く10分

# 重要: .xcodeproj ではなく .xcworkspace を開く
open ios/Runner.xcworkspace

6-1. Signing設定

  1. Xcode左ペイン → Runner 選択

  2. Signing & Capabilities タブ

  3. Team: Apple Developer Accountを選択

    • 未登録の場合: Add Account → Apple IDでサインイン
  4. Bundle Identifier: com.posimai.ponshu_room_lite確認

  5. Automatically manage signing: チェック

6-2. Deployment Target確認

  1. General タブ
  2. Deployment InfoiOS 12.0 確認

Step 7: ビルドテスト15分

7-1. シミュレータ用ビルド

flutter build ios --debug

# 成功メッセージ
# Built build/ios/Release-iphoneos/Runner.app

7-2. Xcodeでシミュレータ起動

  1. Xcode上部 → デバイス選択 → iPhone 12 ProiOS 15.x
  2. ▶ ボタンクリック
  3. アプリが起動するか確認

Step 8: 実機ビルドApple Developer Program必須

8-1. Apple Developer Program登録任意

無料版 (Personal Team):

  • 有効期限: 7日間
  • 実機1台まで
  • App Store配布不可

有料版 (年間99ドル):

  • 有効期限: 1年間
  • 実機100台まで
  • App Store配布可能
  • TestFlight配布可能

8-2. 実機接続

# 実機をUSB接続
flutter devices

# 出力例
# iPhone 13 Pro (mobile) • 00008030-XXXX • ios • iOS 16.1

8-3. 実機ビルド

flutter build ios --release
flutter install -d <device_id>

# または Xcodeから
# デバイス選択 → 実機選択 → ▶ ボタン

Step 9: トラブルシューティング

エラー1: Signing for "Runner" requires a development team

原因: Teamが未設定

解決: Xcode → Signing & Capabilities → Team選択

エラー2: The operation couldn't be completed

原因: デバイスがロックされている

解決: iPhoneロック解除 → 「このコンピュータを信頼」

エラー3: Module 'xxx' not found

原因: CocoaPods依存関係エラー

解決:

cd ios
rm -rf Pods Podfile.lock
pod install
cd ..

エラー4: Xcode build failed - Could not find a bundle identifier

原因: GoogleService-Info.plist未配置

解決: Step 4-3を再確認

エラー5: 2017 MacBook Airでメモリ不足

対策:

  • 他のアプリケーションを終了
  • Xcode再起動
  • ターミナルでsudo purge(メモリ解放)
  • Virtual Memory確保10GB以上

完了チェックリスト

  • flutter doctor でiOS toolchain ✓
  • CocoaPods依存関係インストール完了
  • Firebase iOS設定完了
  • Info.plist完全設定
  • Xcodeでビルド成功シミュレータ
  • 実機ビルド成功(任意)

次のステップ

IOS_DEVICE_TEST_CHECKLIST.mdに従って実機テストを実施