Twitter Feed Popout byInfofru

Statusbar settings in Cordova (IOS)

When I first try to deploy my Cordova application on IOS, the statusbar was blending with app header

When I first try to deploy my Cordova application on IOS, the statusbar was blending with app header. Below is how it was displayed. 

 

From IOS 7 and on statusbar has become the part of the running app to allow developers do something creative with it. It can be useful if you are using it but in routine hybrid apps, we don't need to do that. Luckily, there are two ways to configure statusbar. 

Config.XML: 

There are three configuration element that can be used. Just specify them in your config.xml and you will be all good to go. 

<preference name="StatusBarOverlaysWebview" value="false" />
<preference name="StatusBarBackgroundColor" value="#669F36"/>
<preference name="StatusBarStyle" value="lightcontent" />

For more configurational options, check http://goo.gl/y0cUQI

Programable approach (Using plugin):

By installing a plugin (which is preinstalled in all ionic templates) we can do it programmatically and it will override all StatusBar settings specified in Config.XML. 

angular.module('ionicApp', ['ionic']).run(function ($ionicPlatform, $cordovaSQLite) {

 if (window.StatusBar) {
              
                    StatusBar.overlaysWebView(false);
                 StatusBar.backgroundColorByHexString('#669F36');
                    StatusBar.styleLightContent();
                    
                }

})

Results:

In either approach, below is how you see the statusbar if you set overlaysWebView to false, give it a decent background and a lightcontent style. 


Most Important Note:

Just in case if you don't see any reflection of these configuration in your application, you should remove ios and add it again (sometimes restart do miracles). 

I spent hours to figure it out. In my application, statusBar settings were not working at all. So, I removed and add ios platform again. 

 cordova platform remove ios
 cordova platform add ios

 

Deploy cordova application on specific ios emulator image

Lets make some simple stuff more complicated and more powerful. Below&amp;nbsp;is&amp;nbsp;a cute command to

Lets make some simple stuff more complicated and more powerful. Below is a cute command to emulate your cordova app on ios simulator or device. 

cordova run ios 
//or
cordova emulate ios

First shell command will search for the connected device and if not found just deploy the app to the default emulator and run it. 

Well in my scenario, I want to deploy my app to to iPhone 6 emulator image which uses IOS 8.4. To do that I first wants to know what are the available emulator images I have installed. Below script will do that

./platforms/ios/cordova/lib/list-emulator-images

Following output is from my machine

iPhone-4s, 8.4
iPhone-4s, 9.2
iPhone-5, 8.4
iPhone-5, 9.2
iPhone-5s, 8.4
iPhone-5s, 9.2
iPhone-6, 8.4
iPhone-6, 9.2

Just in case if you don't find emulator image of your choice. You can go to Simulator -> Hardware -> Device -> Manage Devices . 

And then click on the (+) button below and then select add simulator

Once you have devices listed in terminal using the shell given above. Below is how you can now deploy your app on specific IOS image

cordova emulate ios --target="iPhone-6, 8.4"

 

 

Permission issues on Cordova run

This afternoon, while I try to run Cordova run ios terminal shows up with bunch of identical ambigu

This afternoon, while I try to run

 cordova run ios

terminal shows up with bunch of identical ambiguous errors. Some of them are as follows 

rm: could not remove file (code EACCES)
Error: EACCES, permission denied

 

Fixing permission:

It is obvious that there is some thing wrong with the permissions. So I decided to put sudo before the command 

sudo cordova run ios

Ok fair enough, the error is changed. Now it says  

Command failed with exit code 2
You may not have the required environment or OS to run this project

Before going further to solve the issue, lets just make sure that we give full permission on folder to the current user.  To know about your actual user name (just to be on safe side) on mac write 

echo $(logname)

Since you know your username now, lets give your user full permission on this folder. To do so, write 

sudo chown -Rv {angrycoder} ~/Documents/Development/phonegap/appname/

where {angrycoder} should replace by your username followed by the full path of your directory. Unfortunately, that didn't help either and it keep showing the same error. 

Actual Issue (XCode License Agreement): 

Even after the permission fixed the problem still exists. I decided to look at some other clue in terminal and finds out following

simctl was not found

It seems that simulation control is not installed. This is insane, I was using the same machine to build all these projects. When I open Xcode to make sure if every thing is working fine it throws An Accept License Agreement Screen before welcome dialog appears. Yes, you read it right ... Accept license was the main culprit. 

So if you encounter similar issue. Make sure to open your XCode and check if Apple wants you to click somewhere.