Skip to content

Latest commit

 

History

History
142 lines (100 loc) · 3.83 KB

iOS_Simulator101.md

File metadata and controls

142 lines (100 loc) · 3.83 KB
title
iOS Simulator 101

Table of Contents

iOS Simulator 101

[TOC]

Live Development/Debugging

Code injection allows you to update the implementation of functions and any method of a class, struct or enum incrementally in the iOS simulator without having to rebuild or restart your application.

Getting Started

Loading InjectionIII bundle

#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
//for tvOS:
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/tvOSInjection.bundle")?.load()
//Or for macOS:
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle")?.load()
#endif

Configuration for Injection

  1. using default method.

    @objc func injected() {
    		// injection method
    }
  2. using notification: INJECTION_BUNDLE_NOTIFICATION (this is notification name)

Adding Linker Flags

-Xlinker -interposable

Other More Useful Cases

Just look into this document

Screen Recording

Use QuickTime Player

Just record mac Screen!

Right click QuickTime app in Dock and Record.

Stop in top menu bar right corner.

Use Command Line Tool

Start

xcrun simctl io booted recordVideo videoName.mov

End

Just ctrl + c

Simulate Remote Notification

Use Command Line Tool

Acquire Device ID

 xcrun simctl list | grep Booted 

Push

# 40F9EEBF-98BE-4203-99BB-C64D95E4D7A4 is your deivce ID
xcrun simctl push 40F9EEBF-98BE-4203-99BB-C64D95E4D7A4 com.bundle.identifier PushNotificationPayload.apns

⚠️ PushNotificationPayload.apns is a Notification Simulation File(JSON payload). You can create it in watchOS Resource

com.bundle.identifier is needed to replace with your app bundle identifier. Or

  • remove it from command line.

  • Add "Simulator Target Bundle": "com.bundle.identifier", into Notification Simulation File(JSON payload) on the top level.

    {
        "Simulator Target Bundle": "com.bundle.identifier",
        "aps": {
            "alert": {
                "body": "Test message",
                "title": "Optional title",
                "subtitle": "Optional subtitle"
            },
            "category": "myCategory",
            "thread-id": "5280"
        },
        
        "customKey": ""
    }

Drag Notification Simulation File to Simulator

Notification Simulation File(JSON payload) should be had this key-value "Simulator Target Bundle": "com.bundle.identifier", on the top level.