Skip to content

Setting interface orientation does not work in version 8.0.0 #1593

@contfedorov

Description

@contfedorov

Bug Report

Problem

I need to set device interface orientation to be the following:

  • iPhones: portrait only
  • iPads: landscape only

I add the following to config.xml in order to update Info.plist:

<platform name="ios">
        <config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations">
            <array>
                <string>UIInterfaceOrientationPortrait</string>
            </array>
        </config-file>

        <config-file target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad">
            <array>
                <string>UIInterfaceOrientationLandscapeLeft</string>
                <string>UIInterfaceOrientationLandscapeRight</string>
            </array>
        </config-file>
</platform>

App-Info.plist is generated correctly, interface-related options are included. Nevertheless, UI rotates according to emulator rotation.

What is expected to happen?

App orientation is fixed according to my requirements: portrait only for phones, landscape only for tablets.

What does actually happen?

App orientation does not depend on config.xml settings.

Information

  • It used to work in cordova-ios 7.1.1

  • It can be reproduced by creating empty Cordova project (cordova create MyApp) and updating config.xml accordingly.

  • Generated XCode project (platforms/ios/App.xcodeproj/project.pbxproj) contains lined related to interface orientation. These lines override Info.plist configuration. It can be changed in UI, but it is not an acceptable solution.

Image

Lines in project template:

INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";

INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";

  • It can be overridden by overriding supportedInterfaceOrientations in ViewController.swift, but using config.xml is preferable

Command or Code

Environment, Platform, Device

macOS 15.7.2
iPhone simulator w/ iOS 17.2, 18.4

Version information

Cordova CLI 13.0.0
cordova-ios 8.0.0
no plugins
XCode 16.3

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions