Control your iPhone from inside Xcode for end-to-end testing.

Related tags

Testing xcode-plugin
Overview

Remote - Control your iPhone from Xcode

"Remote" is a plugin for Xcode that allows you to control an iPhone from a window on your Mac during development. Originally created to avoid having to pick up a device during testing you can record "macros" of device touches and replay them. It will also compare the resulting screen output against a snapshot for end-to-end testing. The Macro log is an editable WebView that can be modified at will. Finally, you can now record and save all display output into a quicktime movie.

Update: This former Xcode plugin has been re-organised into a Swift Package for use in other apps. To use Remote, simply add this project as a Swift package and the RemoteCapture target to your app. It will connect automatically using the hostname of your desktop. You also need to be running an application containg the RemoteUI target such as InjectionIII or the HotReloading daemon with "Remote Control" enabled to receive connections and render your device's screen. By default, adding the package to a project will have it try to connect to a process running the remote UI. The package manifest compiles your hostname into the package so it should be able to connect from a device.

Icon

(The gif shows the recording of a macro, saving it and then playing it back - testing the screen is as expected in the snapshot.)

To use, download the zipped source for this plugin, build and restart Xcode. You can then patch your project's main.m to include the Remote client header using "Product/Remote/Patch App" or it can load from a bundle on the fly if using the simulator. When using a device check that the correct IP address has been patched into main.m so the device can connect. To use with Swift, add an empty main.m to your project so it can be patched.

The display shadowing window will not display by default. Use the Menu item "Product/Remote/Load" to have it appear. Thereafter, touches on the shadow display or device applied and recorded. To save a macro or a sequence of touches, enter a name into the textfield towards the bottom of the touch display and click the save button. You can then replay the macro either by loading it using the pulldown menu at the top of the touch display and clicking replay or directly from the "Product/Remote/" Menu.

For end-to-end testing, include a snapshot in a macro by clicking the "Snapshot" button. On replay, the macro will pause until the screen matches the snapshot within the specified tolerance or it will timeout asking if you would like to update the snapshot or the tolerance used (remember to save the updated macro.) The units of tolerance are the number of bytes the screen image differs after the run length encoding of simular pixel values.

Macro entries logged/replayed:

  • Hardware <hw.machine> - device type from sysctlbyname()

  • Device <screen width> <screen height> <snapshot scale> <device scale>

  • Begin <wait time> <x> <y> [<x2> <y2>] - touch(s) start

  • Moved/Ended <ditto> touches moved/ended - two touches maximum

  • Expect timeout:<seconds> tolerance:<bytes different>.. <snapshot>

Implementation Classes

UI:

  • RMPluginController - interface between the Remote display and Xcode

  • RMWindowController - macro re-player and overall nib controller

  • RMMacroManager - controls display, saving and loading of macros

Internal (connected by protocol RMDeviceDelegate):

  • RMImageView - subclass of NSImageView for event capture/device display

  • RMDeviceController - interface between remote display and device

  • RemoteCapture.h - #imported into application's main.m to connect to Xcode

RemoteCapture.h requires a patched main.m to be compiled using ARC.

Limitations

Remote uses [UIWindow.layer renderInContext:] so most activity on the device is captured including the keyboard but excepting video replay and openGL layers. UIAlertView prompts are also not captured as they seem to render outside the window hierarchy. Finally, UIDatePickers are not rendered correctly at all although they will respond to events. To preserve network bandwidth to the device animations are not played.

Remote performs better with swipe events if you make an initial tap on the device.

Please note: for some reason it takes about a minute before Xcode will accept remote connections on it's server socket (firewall complications?). After restarting Xcode you may need to wait a while before being able to use the Remote plugin from a device.

Thanks

AVFoundation code for video capture adapted from: https://github.com/acj/TimeLapseBuilder-Swift

MIT license. Please see the LICENSE file for the particulars.

You might also like...
Fastbot is a model-based testing tool for modeling GUI transitions to discover app stability problems

Fastbot is a model-based testing tool for modeling GUI transitions to discover app stability problems. It combines machine learning and reinforcement learning techniques to assist discovery in a more intelligent way.

Genything is a framework for random testing of a program properties.

Genything is a framework for random testing of a program properties. It provides way to random data based on simple and complex types.

For Testing APIs of NYTimes

NYTimes-APIs For Testing APIs of NYTimes Mark Dennis Diwa 👓 To run the app: Open terminal first then run pod install. Open workspace. Run the app on

A Mac and iOS Playgrounds Unit Testing library based on Nimble.
A Mac and iOS Playgrounds Unit Testing library based on Nimble.

Spry Spry is a Swift Playgrounds Unit Testing library based on Nimble. The best thing about Spry is that the API matches Nimble perfectly. Which means

Multivariate & A/B Testing for iOS and Mac

This library is no longer being maintained. You can continue to use SkyLab in your projects, but we recommend switching another solution whenever you

Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

AppiumLibrary is an appium testing library for RobotFramework

Appium library for RobotFramework Introduction AppiumLibrary is an appium testing library for Robot Framework. Library can be downloaded from PyPI. It

Keep It Functional - An iOS Functional Testing Framework
Keep It Functional - An iOS Functional Testing Framework

IMPORTANT! Even though KIF is used to test your UI, you need to add it to your Unit Test target, not your UI Test target. The magic of KIF is that it

Comments
  • Can't compile on macOS 10.12 because of QTKit

    Can't compile on macOS 10.12 because of QTKit

    Hey,

    I'm getting an error while trying to build this project.

    Error message: QTKit/QTKit.h file not found (RMMacroManager.m)

    In macOS 10.12, Apple removed most of QTKit's components (that's probably cause of my issue) and I'm not able to build this project anymore. Is there any way to fix that/workaround?

    Cheers, drptbl.

    opened by drptbl 4
  • there is a error in RemoteBundle-Prefix.pch

    there is a error in RemoteBundle-Prefix.pch

    the error is: UIKit/UIKit.h' file not found UIKit is not available when building for macOS. Consider using #if !TARGET_OS_OSX to conditionally import this framework, first importing TargetConditionals.h if necessary.

    My Xcode version is 12.1 How can I do?

    opened by safuter 1
Owner
John Holdsworth
Add a bio
John Holdsworth
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur

Buildasaur Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running

Buildasaurs 774 Dec 11, 2022
SwiftCheck is a testing library that automatically generates random data for testing of program properties

SwiftCheck QuickCheck for Swift. For those already familiar with the Haskell library, check out the source. For everybody else, see the Tutorial Playg

TypeLift 1.4k Dec 21, 2022
Testing the UI without UI Testing, a Swift experiment.

UI tests without UI Testing experiment This repo is a small experiment to see if there's an "in-between" for testing iOS applications. More feature-le

Joe Masilotti 20 Sep 26, 2022
Swifty tool for visual testing iPhone and iPad apps. Every pixel counts.

Cribble Cribble - a tool for visual testing iPhone and iPad apps. Every pixel counts. Getting Started An example app is included demonstrating Cribble

Max Sokolov 273 Nov 4, 2022
Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5 and iOS 15.

StoreHelper Demo Implementing and testing In-App Purchases with StoreKit2 in Xcode 13, Swift 5.5, iOS 15. See also In-App Purchases with Xcode 12 and

Russell Archer 192 Dec 17, 2022
Network testing for Swift

DVR DVR is a simple Swift framework for making fake NSURLSession requests for iOS, watchOS, and OS X based on VCR. Easy dependency injection is the ma

Venmo 650 Nov 3, 2022
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Quick 9.6k Dec 31, 2022
Snapshot testing tool for iOS and tvOS

SnapshotTest is a simple view testing tool written completely in Swift to aid with development for Apple platforms. It's like unit testing for views.

Pär Strindevall 44 Sep 29, 2022
UI Testing Cheat Sheet and Examples.

UI Testing Cheat Sheet This repository is complementary code for my post, UI Testing Cheat Sheet and Examples. The post goes into more detail with exa

Joe Masilotti 2.1k Dec 25, 2022
Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS

Mockingbird Mockingbird was designed to simplify software testing, by easily mocking any system using HTTP/HTTPS, allowing a team to test and develop

FARFETCH 183 Dec 24, 2022