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’

Installing Appium with Ruby bindings – moving from Calabash – Part 2

In part 1 we looked at the set up of Appium when moving from Calabash. In the next articles we look at getting the ruby console (ARC) working to query your app, but first we have to generate an appium.txt file. This article will help you resolve the annoying App doesn’t exist error message relating to appium.txt when running the arc command.

Create the appium.txt file

The next step is to create the appium.txt file – simple right? Well when I first tried to this i hit a couple of problems.

The appium.txt tells appium what platform you are automating and what simulator you wish to use  and where your app is (amongst other things). Although it is nicely explained in the Appium tutuorial it fails to point out three things

  1.   You can create a sample empty appium.txt using the command
 arc setup ios

2.   Not everyone likes using nano to create files but if you use TextEdit to create / edit the appium.txt file you will end up with the wrong kind of double quotes and later on when you come to run the ARC (ruby console) you’ll get appium.txt errors. If this happens copy the correct double quoted from the file generated by the arc setup ios command.

3. When adding the path to you app, appium will automatically prefix it with the path to the folder where are running the arc command from i.e. it is a relative path, not an absolute path. if you use the absolute path to your app you will get an error something like this:

 App doesn't exist

My appium.txt looks like this – you can use it as an example:

[caps]
platformName = "ios"
platformVersion = "9.0"
deviceName ="iPhone 5s"
app = "./myAppName.app"
autoAcceptAlerts = "true"
waitForAppScript = "true"

[appium_lib]
sauce_username = ""
sauce_access_key = ""

I’ll explain the autoAcceptAlerts and waitForAppScript values in another article – running the Appium Ruby Console (arc).

In the next article i’ll explain the difference between building an app for calabash and building an app for Appium.

Blogging Tools

I don’t want to go into my WordPress site everytime I learn something new so I’m using a useful app called myWPEdit. It’s like a small notes window on your screen and you just write your bit then click post. No opening a web page etc – it can just sit there all day and […]