Table of Contents
iOS Simulator 101
[TOC]
Live Development/Debugging
Tools - InjectionIII
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
-
using default method.
@objc func injected() { // injection method }
-
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 andRecord
.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",
intoNotification 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.