phonegap / phonegap-cli

PhoneGap and PhoneGap/Build command-line interface
Apache License 2.0
489 stars 157 forks source link

No way to lock iPad orientation to landscape via config.xml #405

Closed martenbiehl closed 7 years ago

martenbiehl commented 9 years ago

Hi!

I can make none of the ways work that are described here http://docs.build.phonegap.com/en_US/2.9.0/configuring_config_file_element.md.html

I am on version 3.5.0-0.21.14 of phonegap installed via npm.

To reproduce:

npm install -g phonegap
phonegap create orientation-test

1. edit config.xml

<preference name="orientation" value="landscape" /> phonegap build ios open platforms/ios/HelloWorld/HelloWorld-Info.plist to check that the setting had no effect

2. edit config.xml to contain

<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
        <array>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
</gap:config-file>
<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations~ipad" overwrite="true">
        <array>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
</gap:config-file>

phonegap build ios open platforms/ios/HelloWorld/HelloWorld-Info.plist to check that the setting had no effect

Is this a bug or is some information missing from the documentation? I can find no information anywhere online to make this work without editing the pList file directly. Yet, I would rather avoid this to not having to manage multiple configuration files and being able to keep up to date with phonegap.

Thanks Marten

jborden commented 9 years ago

I am having this exact same issue and can confirm that neither of martenbiehl's #1 or #2 edits to config.xml worked for me either. I will be manually setting the configurations in platforms/ios/HelloWorld/HelloWorld-Info.plist for now.

My system: $ phonegap --version 3.5.0-0.21.17 $ sw_vers ProductName: Mac OS X ProductVersion: 10.9.5 BuildVersion: 13F34

Thanks guys!

Tyguy7 commented 9 years ago

Same issue for me.

TianleZhang commented 9 years ago

Same issue here

iharosi commented 9 years ago

Same issue!

devacc at macmini in ~
$ cordova -v
4.3.0

devacc at macmini in ~
$ phonegap -v
4.2.0-0.24.2

devacc at macmini in ~
$ node -v
v0.12.0

devacc at macmini in ~
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.2
BuildVersion:   14C1510
pbihler commented 9 years ago

Still the same issue, and I don't have the option to set things manually in the plist, since its generated on build in my setup.

SergeySnegirev commented 9 years ago

Still the same issue, incredibly annoying for Phonegap Build users.

LukaszC commented 9 years ago

+1

timcosta commented 8 years ago

+1.

alain-r commented 8 years ago

+2

SergioRodriguezRuiz commented 8 years ago

+3 Same issue here.

michagerwig commented 8 years ago

+4 same issue. iOS 8.4, phonegap 5.1.1

ygayl commented 8 years ago

+5 same issue. iOs 8.3, cordova 5.0.0

brad-sf commented 8 years ago

+6 Cordova 5.1.1

markusv commented 8 years ago

+7

xairoo commented 8 years ago

+8

abruzzihraig commented 8 years ago

+9

voluntas commented 8 years ago

+10

smemane commented 8 years ago

+11

ygayl commented 8 years ago

Guys, for those of you still having the issue, I just wrote a simple grunt task to update the plist file and removing the portrait.

    grunt.registerTask('updateiOSPlistLandscapeOnly', function () {
        var plist = require('plist'),
            appName = 'Your Super App',
            plistFilepath = path.resolve() + '/' + 'platforms/ios/' + appName + '/' + appName + '-Info.plist',
            plistJson = plist.parseFileSync(plistFilepath);

            plistJson['UISupportedInterfaceOrientations~ipad'].forEach(function(value, index){
                if (value && value.indexOf('Portrait') > -1){
                    plistJson['UISupportedInterfaceOrientations~ipad'].splice(index, 1);
                }
            });
            var plistObj = plist.build(plistJson);
            grunt.verbose.writeln('****Updating plist: removing portrait****');
            grunt.file.write(plistFilepath, plistObj);
    });

And depending on your build management, either add it to your build workflow (grunt, gulp) either you can it to the hooks. For the last one, within your before_build hooks directory (create it if you don't have it yet), you can just add the following code in a new file (010_remove_portrait.js for example).

#!/usr/bin/env node

var exec = require('child_process').exec;
if (process.env.CORDOVA_CMDLINE.indexOf('ios') > -
    function puts(error, stdout, stderr) {
        console.log(stdout)
    }
    exec("grunt updateiOSPlistLandscapeOnly", puts);

An easier and cleaner solution would be to write the code directly within the hooks nodejs script. But as my build was using grunt already with a lot of other tasks, I just went with it.

SergeySnegirev commented 8 years ago

@ygayl Thanks but this won't help those who use PhoneGap Build online. So we really need that bug fixed.

kishorekumaru commented 8 years ago

The issue with IOS 9.0 iPhone devices also, I am using the following lang version

Cordova : 5.3.3 Phonegap : 5.2.0 config.xml :<preference name="orientation" value="portrait" /> I have tried cordova-plugin-screen-orientation, it didnt help iPhone 6 plus : IOS ( 9.0.2) not working

Any help?

pjanu commented 8 years ago

+12

cmartinezv commented 8 years ago

+13

ruudruud commented 8 years ago

+14 This is a very annoying bug.

filmaj commented 7 years ago

I cannot reproduce this with the latest phonegap-cli.

I created a project, added <preference name="Orientation" value="landscape" /> to my config.xml, ran phonegap build ios, and I see this under platforms/ios/HelloWorld/HelloWorld-Info.plist:

➔ ack -i orientation platforms/ios/HelloWorld/HelloWorld-Info.plist
    <key>UISupportedInterfaceOrientations</key>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    <key>UISupportedInterfaceOrientations~ipad</key>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    <key>UIInterfaceOrientation</key>
      <string>UIInterfaceOrientationLandscapeLeft</string>

Closing.

iharosi commented 7 years ago

So it took 3 years to fix this. Unbelievable. 🥇 👍 XD :D

filmaj commented 7 years ago

@iharosi incorrect. The issue existed in Apache Cordova land and took one year to fix.

PhoneGap and Apache Cordova are open source projects, and you are more than welcome to help out and fix things. Snark is, generally speaking, unhelpful, and quite frankly, demotivating to all of the contributors spending their time on this trying to help folks like yourself.