• Stars
    star
    853
  • Rank 53,438 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

injectionforxcode

Runtime Code Injection for Objective-C & Swift
Objective-C
6,551
star
2

InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
Objective-C
3,995
star
3

Xtrace

Trace Objective-C method calls by class or instance
Objective-C++
1,832
star
4

Refactorator

Xcode Plugin that Refactors Swift & Objective-C
Swift
991
star
5

GitDiff

Highlights deltas against git repo in Xcode
Objective-C
891
star
6

SwiftTrace

Trace Swift and Objective-C method invocations
Swift
695
star
7

HotReloading

Hot reloading as a Swift Package
Swift
536
star
8

XprobePlugin

Live Memory Browser for Apps & Xcode
Objective-C++
395
star
9

RefactoratorApp

App version of Refactorator plugin
Swift
255
star
10

Accelerator

Inline frameworks of Swift CocoaPods projects for faster launch
Ruby
174
star
11

InjectionApp

Issue Tracking Repo for Injection as an App
Swift
111
star
12

Fortify

Making Swift more robust
Swift
95
star
13

HotSwiftUI

Utilities for Hot Reloading SwiftUI apps.
Swift
94
star
14

Diamond

Diamond - Swift scripting made easy
Objective-C
94
star
15

SwiftPython

Experiments in bridging Swift to Python
Swift
88
star
16

Dynamo

High Performance (nearly)100% Swift Web server supporting dynamic content.
Swift
68
star
17

SwiftRegex

Some regular expression operators for Swift
Swift
67
star
18

NSLinux

NSString and libdispatch compatibility code for Swift on Linux
Swift
47
star
19

InstantSyntax

SwiftSyntax binary frameworks
Swift
47
star
20

InjectionNext

Fourth evolution of Code Injection for Xcode
Swift
47
star
21

WatchkitCurrency

Swift Currency Convertor for iWatch with flexible interface
Swift
40
star
22

TwoWayMirror

Adapt Swift’s Mirror functionality to make it bidirectional.
Swift
38
star
23

InjectionLite

Swift package re-write of InjectionIII app
Swift
34
star
24

Smuggler

Smuggle code bundles into an app running in the Simulator
Objective-C++
32
star
25

SwiftRegex5

5th incarnation of Swift Regex library using generic subscripts
Swift
32
star
26

SwiftAspects

Experiments in Aspects with Swift (Xtrace for Swift)
Assembly
30
star
27

unhide

export symbols with “hidden” visibility for Swift frameworks
Objective-C++
25
star
28

Symbolicate

Symbolicate for OS X
Objective-C
23
star
29

DLKit

A rather subscript oriented interface to the dynamic linker.
Swift
22
star
30

SwiftTryCatch

Try/Catch for Swift?
Swift
15
star
31

ApportablePlugin

Simple Plugin for work with Apportable
Objective-C
14
star
32

Compilertron

InjectionIII for the Swift compiler
C++
14
star
33

SearchLight

SpotLight on Steroids
Objective-C++
14
star
34

siteify

Build web site from a project’s Swift sources.
HTML
13
star
35

SwiftPlugin

A way to import classes from plugins
Swift
12
star
36

SwiftKeyPath

valueForKeyPath: for Swift
Swift
12
star
37

DynamoLinux

100% Swift Linux Web Server
Swift
11
star
38

ProfileSwiftUI

InstrumentSwiftUI
Swift
10
star
39

SwiftUIPlaygrounds

Alternative to Xcode previews.
Swift
9
star
40

SwiftRegex4

Basic regex operations for Swift4
Swift
9
star
41

StringIndex

Sensible indexing into Swift Strings
Swift
8
star
42

SwiftView

Curated Xcode Project as a means of navigating Swift Sources
7
star
43

Parallel

Some primitives for concurrent processing
Swift
6
star
44

Popen

Reading and writing processes and files
Swift
6
star
45

WatchkitSundial

Sundial for Apple Watch
Objective-C
6
star
46

SwiftierJSON

Memory efficient version of SwiftyJSON
Swift
6
star
47

objectivecpp

HTML
5
star
48

YieldGenerator

Python's "yield" generators for Swift
Swift
5
star
49

opaqueify

Greater use of Opaque types (SE0335)
Swift
5
star
50

SwiftMock

Mock structs and classes without code modification for testing.
Swift
4
star
51

Unwrap

Self documenting alternatives to force unwrap operator.
Swift
4
star
52

InjectionScratch

InjectionScratch
Objective-C++
3
star
53

EasyPointer

Rounding off some of the rough edges of Swift's pointer model
Swift
2
star
54

TestRunner

Example of calling Swift methods using name pattern (XCTest?)
Swift
2
star
55

binary-Swallow0

Swift
1
star
56

Character

Integer conversions and operators for Swift Characters.
Swift
1
star
57

ASCII

Facilitating operations on ASCII in Swift
Swift
1
star