expo: "orientation: portrait" in app.json does not prevent orientation change on iPad- iOS 12.4

🐛 Bug Report

Environment

  Expo CLI 3.0.9 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 5.5.1 - /usr/local/bin/zsh
    Binaries:
      Node: 10.15.3 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.10.3 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.3/10G8 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^34.0.1 => 34.0.4 
      react: 16.8.3 => 16.8.3 
      react-native: https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz => 0.59.8 
      react-navigation: ^3.11.0 => 3.11.1 

Steps to Reproduce

  1. Create template expo app
npm i -g expo-cli@3.0.9
expo init (picking the tabs template)

app.json

{
  "expo": {
    "name": "expo-template",
    "slug": "expo-template",
    "privacy": "public",
    "sdkVersion": "34.0.0",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    }
  }
}
  1. Start app in portrait orientation on iPad 5th Generation (WiFi) - iOS 12.4
  2. Turn device to landscape orientation

Expected Behavior

Screen should not change orientation

Actual Behavior

Screen does change orientation

Reproducible Demo

Sorry, please dont close this issue, but I can’t work out a way to change the orientation of a snack. If it is possible, please let me know how and I will make one ASAP. 😃

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 15 (3 by maintainers)

Most upvoted comments

This bug is still present on SDK 40

I’m seeing this in v42. Was it really fixed?

still not fixed in v45 😦

Update

This is only an issue in the expo client. After building the app and installing the .ipa file on the same iPad, the orientation is locked to portrait.

I think this warrants a documentation change on this page: https://docs.expo.io/versions/latest/workflow/configuration/

Looks like there’s a special orientation property for iPad (UISupportedInterfaceOrientations~ipad) that Expo isn’t setting. You can use plugins to set this property in the Info.plist file for iOS, try this if you’re using EAS (managed flow):

Create a withCustomInfoPlist.js file with something like this code (in this case it enables the “portrait” orientation only):

const { withInfoPlist } = require('@expo/config-plugins')

module.exports = config =>
  withInfoPlist(config, config => {
    // Only enable portrait orientation in iPad
    config.modResults['UISupportedInterfaceOrientations~ipad'] = ['UIInterfaceOrientationPortrait']

    return config
  })

Use the path to this custom plugin in your app.json or app.config.js like:

plugins: [
    ...otherPlugins,
    ['./plugins/withCustomInfoPlist'],
  ],

Create a new build and at least for me the issue was fixed.

Does not seem to be working. I’m on SDK 49 and orientation: 'portrait' leads to this result:

Screenshot 2023-10-04 at 22 02 24

I’ve tried using app config but that also doesn’t work:

    infoPlist: {
      'UISupportedInterfaceOrientations~ipad': [
        'UIInterfaceOrientationPortrait',
        'UIInterfaceOrientationPortraitUpsideDown'
      ]
    }

results in

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

UPDATE: The answer is that Expo is “smart” enough to add the iPad orientations because it’s required when the app supports multitasking on iPadOS. Setting ios.requireFullScreen to true, in combination wit orientation: 'portrait' solves the issue.