Testing your native iOS App on a Virtual Machine

Setting up your application file for testing:

XCODE

To run tests on an iOS VM, follow these steps to set up your app as a .app file: 

1. Generate a simulator build using the xcodebuild  command

Make sure xcode Command Line tools are installed. They come bundled with xcode. 

To build simulator builds you need to build your app for x86 64-bit. The command you will run to make the build should look similar to this:

xcodebuild ENABLE_BITCODE=NO -workspace '/path/to/YourWorkspace.xcworkspace' -scheme 'myScheme' -arch x86_64 -sdk iphonesimulator 

  • ENABLE_BITCODE=NO  turns off bitcode for the build.
  • -workspace takes your .xcworkspace  file
  • -scheme is the build scheme. You may instead need to use -project myproject.xcodeproj  or -target myTarget, depending on your setup.
  • -arch x86_64  sets the build to be 64-bit which will let it run on simulators. If you need to build 32-bit use -arch i386. Apple deprecated 32-bit support in iOS 11 so most builds should be 64-bit now. Your app MUST be built with one of these to run on simulators.
  • -sdk iphonesimulator sets the sdk to simulator. If you want a specific sdk you can list your installed sdks with xcodebuild -showsdks  and change the option to be explicit: -sdk iphonesimulator11.1  
  • Depending on your setup you may need to use the option -configuration "Debug" or -configuration "Release" 
  • If you need more help with xcodebuild check out Apple's documentation here and here.

Ionic Framework 

To build a simulator build using Ionic framework follow their CLI reference: https://ionicframework.com/docs/cli/cordova/build/

ionic cordova build ios --emulator

Should produce the .app file you need.

Notes

IMPORTANT: Test that your .app works on a local iOS simulator by dragging and dropping the .app  file onto your local xcode simulator. If it does not work on your local iOS simulator, it won't work on ours.

IMPORTANT: Zip the .app file produced by the command. Rainforest supports .zip , .tar and .gz

Host your app

Host your app somewhere that supports direct downloads. 

  • The hosted file URL MUST be a direct download link. If this is not the case, Rainforest will not be able to install the .app file.
  • Do not use links that redirect, require credentials, or limit access; the link should lead to a direct download.

Add your app's URL to Rainforest

To set up your app for testing, add a link to your iOS .app zip file under Settings > Sites > ‘Apps’, and set the device 'Type' to ‘iOS’

  • Please Note: if you set the 'Type' to 'iOS Device Farm' your runs will error due to the difference between file types (.ipa for iOS device testing and .app for iOS VM testing)!

Creating a new native iOS test

  1. To create a new test for your native iOS application, click New Test, then select ‘App’

2. Click the drop-down, and select the URL for the .app file you wish to test

  • NOTE: As Rainforest will automatically download, install and start your application for testing, you cannot select non-iOS VMs for this test. 

3. To preview the test hit the Glasses Icon or to run the test, select the 'Run Test' button and then 'Run' to choose the iOS VM from the Platforms section. 

Can I reuse my existing web tests?

In most cases, a company’s web app and native app are fundamentally different, so you will not be able to reuse your existing web tests for your native app. However, in some cases, you can (and should!) reuse the work that you have already done.

If your mobile and web apps are very similar, you can simply copy the appropriate tests for your web app to a new test for your mobile application.

Native mobile app and web application tests are separated in the Rainforest interface, since they cannot share a starting URL.

  • The URL for a web browser test serves as a direction for the testers
  • The URL for a native app test is a source, where Rainforest will access and install your native application

Supported Devices for VM testing 

  • iPhone4s (iOS 8)
  • iPhone6 (iOS 8)
  • iPhone6 (iOS 9)
  • iPhone6+ (iOS 9)
  • iPhone6s (iOS 10)
  • iPhone6s+ (iOS 10)
  • iPhone6s+ (iOS 10)
  • iPhone6s+ (iOS 10)
  • iPhone7 (iOS 10.3) 
  • iPhone7+ (iOS 10.3) 

Troubleshooting

App won’t load? Take a look at the following 

Testing your build

If your app is not running properly on Rainforest’s VMs, we strongly recommend that you test it locally to ensure that your application is configured properly for running in a simulator. Try the following code to test that your build loads as expected on a simulator.

# list devices
xcrun simctl list
Ex: iPhone 7 (BCFE928E-1FFB-446B-A41C-288558412F0D) (Shutdown)

# open the simulator
open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator --args -CurrentDeviceUDID BCFE928E-1FFB-446B-A41C-288558412F0D

# install .app
# xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl install BCFE928E-1FFB-446B-A41C-288558412F0D /tmp/Example.app

# get bundle ID
osascript -e 'id of app "/tmp/Example.app"'
# Ex: com.rainforestqa.ExampleApp

# launch app
#xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>
xcrun simctl launch BCFE928E-1FFB-446B-A41C-288558412F0D com.rainforestqa.ExampleApp

# terminate app
xcrun simctl terminate BCFE928E-1FFB-446B-A41C-288558412F0D com.rainforestqa.ExampleApp

# unistall app
xcrun simctl uninstall BCFE928E-1FFB-446B-A41C-288558412F0D com.rainforestqa.ExampleApp

# shutdown the simulator
xcrun simctl shutdown BCFE928E-1FFB-446B-A41C-288558412F0D 

Make sure your app URL is a direct download link

The hosted file URL MUST be a direct download link. If this is not the case, Rainforest will not be able to install the .app file.

Verify Site URL

Rainforest will add a trailing slash "/" when launching running the test. This will sometimes lead to an error that does not allow the test to direct to the correct URL which will fail the test. This can be avoided by adding a "#" to the end of your site url. 

Whitelisting IPs

Our testers come from various IP address, secure environments may block testers from reaching your site. Whitelisting Rainforest IP addresses may be required.

Did this answer your question?