While competing in the exacting modern software market, many companies find integrating automated testing into their overall testing process beneficial. This guide will help you better understand the different types of automated test solutions and how developers...
Instrumentation with source code on iOS
In this chapter, we’ll show you how to instrument your app using source code on iOS. Simply follow the instructions below. Alternatively, there are also many video tutorials on YouTube that detail this process.
We recommend you only instrument with source code if you are an experienced iOS developer.
Whenever you update Ranorex Studio (i.e. use newer automation libraries/Ranorex Service App), reinstrument your apps. Otherwise, automation may not work as intended.
Download the automation lib from the Mobile Download Archive on your Mac.
The file size of Ranorex Automation Library is about 30 megabytes. This does not automatically make your app 30 megabytes bigger since it is a universal library and only the parts essential for your app will dynamically be added when compiling it.
Open the XCode project of your application under test.
To avoid shipping an instrumented app to your customers it is recommended to create a separate target for your app under test. You should select the project file and duplicate the existing target.
Rename the newly created target.
As XCode does not automatically update all necessary files, you have to rename them manually. You will have to alter the target itself, the targets .plist file (in the workspace as well as in Build Settings -> Packaging), the targets’ project name (Build Settings -> Packaging) and the schemes name (Product -> Manage Schemes).
Add the previously downloaded automation lib to your newly created target.
Choose the lib file and specify the target, i.e. where the lib will be added
After doing this, the automation lib will be listed in the ‘Linked Binary With Libraries’ list in the ‘Build Phases’ pane of the test target.
Add the CFNetwork framework to the list.
Added automation lib and network framework
Additionally, with iOS 8.3 add the IOKit.framework.
In the Build Settings pane of the test, add the switches ‘-ObjC -all_load’ to the option Other Linker Flags.
Set the switches ‘-ObjC’ and ‘-all_load’
Under the Info tab, add a Bundle display name key (CFBundleDisplayName).
Insert the URL schema in the application settings to open the instrumented IPA from RxServices or Ranorex Studio, for more information review the iOS Service App page. Below, an example of a schema:
If a designer implements the existing Apple API, which restricts any schema from running the application, the instrumented IPA does not run within RxServices and Ranorex Studio.
Run the RxServices IPA, put it into the background, and next, run the instrumented IPA and put it in the background as well. This makes the application recognizable by the RxServices IPA.
The new IPAs should display in the list of available IPAs in the RxServices application and in Ranorex Studio.
After performing these steps, your project can be built using the newly created target and scheme for your iOS devices as well as simulators.
If you see the debug output ‘RxAutomationEngine init‘ in the console pane, your app has been instrumented successfully.
Successfully instrumented app
- Because the Ranorex automation lib uses non-public APIs, make sure that you do not submit a Ranorex instrumented app to the app store as your app might be rejected and you might be banned from submitting apps to the app store for a period of time.
- To add your device via Wi-Fi, it’s necessary that the application under test is started on your iOS device or simulator.
- The development provisioning profile should be used for testing your app and not the distribution provisioning profile.
- To improve the object recognition of your app under test set the accessibility label attribute of your controls.
- Due to restriction in Apple API it may occur that the instrumented IPA is not able to run from with Ranorex Studio, while RxServices application is in the background mode. It is recommended to perform any test while the instrumented IPA is in the foreground.