All Projects → ctreffs → SwiftSimctl

ctreffs / SwiftSimctl

Licence: MIT license
Swift client-server tool to call xcrun simctl from your simulator. Automate push notification testing!

Programming Languages

swift
15916 projects
Makefile
30231 projects

Projects that are alternatives of or similar to SwiftSimctl

Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (+138%)
Mutual labels:  simulator, tvos, swift-package-manager
SwiftZip
Swift wrapper for libzip — library for reading, creating, and modifying zip archives.
Stars: ✭ 44 (-12%)
Mutual labels:  swift-package-manager, spm
xxHash-Swift
xxHash framework in Swift.
Stars: ✭ 22 (-56%)
Mutual labels:  tvos, swift-package-manager
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-46%)
Mutual labels:  tvos, swift-package-manager
Table
CLI tables in Swift
Stars: ✭ 53 (+6%)
Mutual labels:  swift-package-manager, spm
SwiftDown
📦 A themable markdown editor component for your SwiftUI apps.
Stars: ✭ 203 (+306%)
Mutual labels:  swift-package-manager, spm
SwiftCurrent
A library for managing complex workflows in Swift
Stars: ✭ 286 (+472%)
Mutual labels:  tvos, swift-package-manager
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+42%)
Mutual labels:  swift-package-manager, spm
tracelog
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.
Stars: ✭ 52 (+4%)
Mutual labels:  tvos, swift-package-manager
danger-swift-xcodesummary
A Danger-Swift plugin that adds build errors, warnings and unit tests results generated from xcodebuild to your Danger report
Stars: ✭ 72 (+44%)
Mutual labels:  swift-package-manager, spm
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (-30%)
Mutual labels:  tvos, swift-package-manager
CSV
A simple CSV file parser and serializer
Stars: ✭ 31 (-38%)
Mutual labels:  swift-package-manager, spm
SupportEmail
Pre-populates emails with support information in iOS/iPadOS apps
Stars: ✭ 20 (-60%)
Mutual labels:  swift-package-manager, spm
Match3Kit
Library for simple Match3 games.
Stars: ✭ 38 (-24%)
Mutual labels:  swift-package-manager, spm
swift-watch
Watches over your Swift project's source
Stars: ✭ 43 (-14%)
Mutual labels:  swift-package-manager, spm
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (+38%)
Mutual labels:  swift-package-manager, spm
Controlroom
A macOS app to control the Xcode Simulator.
Stars: ✭ 4,617 (+9134%)
Mutual labels:  simulator, simctl
MMActionSheet
An actionSheet view implement with pure swift
Stars: ✭ 25 (-50%)
Mutual labels:  swift-package-manager, spm
ecs-demo
Minimal demo App for the Fireblade Entity-Component System (ECS)
Stars: ✭ 20 (-60%)
Mutual labels:  swift-package-manager, spm
YMFF
Feature management made easy.
Stars: ✭ 26 (-48%)
Mutual labels:  swift-package-manager, spm

Swift Simctl

macOS license
swift-version-compatibility platform-compatibility

simctl-example-gif

This is a small tool (SimctlCLI) and library (Simctl), written in Swift, to automate xcrun simctl commands for Simulator in unit and UI tests.

It enables, among other things, reliable fully automated testing of Push Notifications with dynamic content, driven by a UI Test you control.

🚧 Architecture

Swift Simctl is made of two parts. SimctlCLI and Simctl.

Simctl is a Swift library that can be added to your project's test bundles. It provides an interface to commands that are otherwise only available via xcrun simctl from within your test code. To enable calling these commands Simctl communicates over a local network connection to SimctlCLI.

SimctlCLI is a small command line tool that starts a local server, listens to requests from Simctl (the client library) and executes xcrun simctl commands.

Available Commands

The following commands will be available in code in your (test) targets:

  • Send push notifications with custom payload
  • Grant or revoke privacy permissions (i.e. camera, photos ...)
  • Set the device UI appearance to light or dark mode
  • Set status bar overrides (i.e. data network, time ...)
  • Uninstall app by bundle id
  • Terminate app by bundle id
  • Rename device
  • Trigger iCloud Sync
  • Open URLs including registered URL schemes
  • Erase the contents and settings of the simulator
  • Get app container

Why would you (not) use this

Pro

  • Closed system (Mac with Xcode + Simulator)
  • No external dependencies on systems like APNS
  • No custom test code bloating your code base (AppDelegate) unnecessarily
  • Push notifications can be simulated properly and the normal app cycle is preserved
  • Runs on CI machines
  • Your app stays a black box and does not need to be modified

Contra

  • Needs a little configuration in your Xcode project
  • Only available for Xcode 11.4+

For specific usage please refer to the example projects Swift Simctl Package Example

🚀 Getting Started

These instructions will get your copy of the project up and running on your machine.

📋 Prerequisites

💻 Usage

📦 Swift Package

To use Swift Simctl in your Xcode project add the package:

  1. Xcode > File > Swift Packages > Add Package Dependency...
  2. Choose Package Repository > Search: SwiftSimctl or find https://github.com/ctreffs/SwiftSimctl.git
  3. Select SwiftSimctl package > Next xcode-swift-package
  4. Do not forget to add the dependency to your (test) target
  5. Use import Simctl to access the library in your (test) target.

Running the server alongside your tests

Make sure that for the duration of your test run SimctlCLI runs on your host machine. To automate that with Xcode itself use the following snippets as pre and post action of your test target.

Your Scheme > Test > Pre-Actions > Run Script
#!/bin/bash
killall SimctlCLI # cleaning up hanging servers
set -e # fail fast
# start the server non-blocking from the checked out package
${BUILD_ROOT}/../../SourcePackages/checkouts/SwiftSimctl/bin/SimctlCLI start-server > /dev/null 2>&1 &
Your Scheme > Test > Post-Actions > Run Script
#!/bin/bash
set -e
killall SimctlCLI
📝 Code Example Swift Package

Please refer to the example project for an in depth code example https://github.com/ctreffs/SwiftSimctlExample

💭 Port and settings

The default port used by the server is 8080.
If you need to use another port you need to provide it via the --port flag when calling SimctlCLI and adjust the client port accordingly when setting up your test in code.
Use SimctlCLI --help to get help regarding this and other server configuration settings.

🙏 Kudos

Swift Simctl would not be possible without these awesome libraries:

💁 How to contribute

If you want to contribute please see the CONTRIBUTION GUIDE first.

Before commiting code please ensure to run:

  • make precommit

This project is currently maintained by @ctreffs.
See also the list of contributors who participated in this project.

🔏 Licenses

This project is licensed under the MIT License - see the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].