Skip to content

Instantly share code, notes, and snippets.

@rustymagnet3000
Last active August 14, 2022 22:35
Show Gist options
  • Save rustymagnet3000/fab543dde9f1e29a3dc6ba388c62f191 to your computer and use it in GitHub Desktop.
Save rustymagnet3000/fab543dde9f1e29a3dc6ba388c62f191 to your computer and use it in GitHub Desktop.
xCode tips

xCode and iOS Simulator tricks

iOS-Deploy

List Bundle IDs on real iOS device

ios-deploy -B

Command line deploy app over USB

ios-deploy -W -b foobar.app

Install, run and debug iOS app on real device from command line

ios-deploy -d -W -b <DerivedDatapath to app build>/Debug-iphoneos/tinyDormant.app

Build Scripts

Better Scripts

http://www.mokacoding.com/blog/better-build-phase-scripts/

Add warnings and errors

https://briksoftware.com/blog/archives/120/

Xcode Behaviors

This SO post shows how to get XCode's debug console as a new Window instead of a small debug Tab.

Xcodebuild

List

xcodebuild -list

Build

xcodebuild -scheme "tinyScheme" -project tiny.xcodeproj

Xcode environment variables

Read all environment variables available to Xcode: https://gist.github.com/gdavis/6670468

Or print it locally:

xcodebuild -project foobar.xcodeproj -target "foobar" -showBuildSettings

Environment variables

I moved away Build Scripts away from:

PROJECT_NAME
TARGETNAME
CURRENT_ARCH

As Xcode build tended to use the PRODUCT_NAME and ARCHS to get the correct env variable.

Print UUID of Simulator

xcrun simctl list | egrep '(Booted)'
    iPhone 8 (89ECF974-0740-4FBE-8388-BB25AC5503A3) (Booted)
    Phone: iPhone 8 (89ECF974-0740-4FBE-8388-BB25AC5503A3) (Booted)

Launch app on Simulator

xcrun simctl launch booted <bundle_id>

Terminate app on Simulator

xcrun simctl terminate booted <bundle_id>

Inspect KeyChain on Simulator

/Users/.../Library/Developer/CoreSimulator/Devices/89ECF974-0740-4FBE-8388-BB25AC5503A3/data/Library/Keychains

Inspect persisted local files

/Users/.../Library/Developer/CoreSimulator/Devices/<device ID>/data/Containers/Data/Application/<app_uuid>/Documents

Add Certificate Authority files to Simulators

You can drag and drop .crt or .der certificate files to a simulator in xCode.

The iOS Simulator will auto open Springboard (Settings) and ask for confirmation of trust. This is a great way to test UIWebView or WKWebView code with a self-signed certificate chain. Remember, you need to trust the Root CA and Int CA of a certificate chain. I never load my leaf certificate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment