0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FlutterアプリでiPadの向きをLandscapeのみに固定する際の注意点(Xcode設定)

Posted at

FlutterでiPadアプリを開発していて、特定の画面向き(例:Landscape)に限定したい場合、いくつかの方法がありますが、以下のような問題にぶつかりました:

  • SystemChrome.setPreferredOrientations などコード上で制御しても、実機で効かないことがある
  • シミュレーターではうまく行くが、ビルドしてTestFlightにアップロードする段階でエラーが出る

✅ 成功した方法

Xcodeの Runner > General > Deployment Info セクションでチェックボックスを使って設定すること。

以下のように、Landscape LeftLandscape Right のみにチェック:

Screenshot 2025-06-15 at 14.21.05.png

⚠️ 注意点

このチェックを外すと、Xcodeは自動的に Info.plist の以下のチェックを外した行の項目を削除します。

<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>

Landscape以外を無効にしたままアーカイブしようとすると、アーカイブまではできるが、App Store Connectへのアップロード時に「全方向サポートしていない」とエラーが出て絶望することがあります。実際何度もここにきて絶望しました。いけそうに見えて最後で落とすのです。

✅ 解決策(順番が重要)

  1. 開発中・動作確認時Info.plist に上記の4方向すべてを記述しておく
  2. Xcode > Runner > General のチェックボックスも全方向にしておく
  3. アーカイブ直前にチェックボックスで Landscape のみに変更
  4. その後 Info.plist に自分で <array> 内を4方向すべてに戻す
  5. 保存し、その状態でアーカイブ

この順番でやるのが非常に重要です。
これにより、実機でのLandscape固定、かつApp Storeアップロードも成功します。


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?