Calabash run_loop fifo error – Swift app not launching in Simulator solution

For the past day or so I’ve been having a problem with calabash where I couldn’t get calabash to launch an ios app in the simulator without encountering a run_loop error saying :

RunLoop::Fifo::NoReaderConfiguredError

Turns out that this is was due to the push notification alert popping up before Instruments had taken control of the simulator. This issue is a known calabash issue – see here.

ios calabash fifo error

SOLUTION

The solution was a two step approach:

  1. Add a delay to the code to prevent the alert popping up too soon. The app was written in SWIFT. I added the delay code to AppDelegate.swift as follows:

//Existing code

        if application.respondsToSelector(“registerUserNotificationSettings:”) {

                    //Newly add code to delay the pop up.

            let time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), 4 * Int64(NSEC_PER_SEC))

            dispatch_after(time, dispatch_get_main_queue()) {

                //Code to be executed with delay

            let settings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert,UIUserNotificationType.Badge,

UIUserNotificationType.Sound], categories: nil)

            application.registerUserNotificationSettings(settings)

            application.registerForRemoteNotifications()

                          }

        }

  2. Add code to my calabash script to accept the alert:

if uia_query(:alert).count > 0
# dismiss by touching ‘OK’
uia_tap_mark ‘OK
end

uia_tap_mark ‘OK’

Advertisements

Got a Resource id #5 appearing, don’t worry!

So I was echoing out my $query and my $result variables and I coded my site in order to check my SQL statements and I came across a value of ‘Resource id #5’ in my echo values where I instead expected to see a customerID.

The answer? Well,  you can’t echo the result of a sql query,   i.e you can’t do this:

$query = "SELECT CustomerID  FROM CUSTOMER WHERE emailAddress = '".$emailAddress."'";
$result=mysql_query($query);
echo $result;

instead you need to identify which item in $result you want to echo (and for which row). In my instance the item was CustomerID and  I thought it would be good to iterate through all the rows in the resultset, so I echoed it like this:

$query = "SELECT CustomerID  FROM CUSTOMER WHERE emailAddress = '".$emailAddress."'";
$result=mysql_query($query);

//Get the number of rows in the recordset
$num=mysql_numrows($result);

//Set the initial value of the counter to zero (the first position in the resultset)
$i=0;

//iterate through the resulset and echo the value of the CustomerID for each record
while ($i < $num) {
echo mysql_result($result,$i,"CustomerID");
$i++;
	}

It’s an easy mistake to make, but a bit thoughtless when you think about it..after all, how can we expect to echo a recordset? I don’t think I’ll be making that mistake again!!