iOS Developer Cheat Sheet

Xcode

Certificates & Provisioning Profiles

  1. Locate the provisioning profiles directory.
1
~/Library/MobileDevice/Provisioning\ Profiles

Tips: You can use hot keys "Command+Shift+G" to open the directory in Finder.

Simulator

Command Usage
open -A Simulator Open the recent launch simulator device
xcrun simctl list Listing all available simulators
xcrun simctl create My-iphoneX Create a new iPhone X on top of exsiting ios version
xcrun simctl shutdown C8C050F3–062D-4444-A888-BBEC783E31BD Shutdown the simulator has uuid C8C050F3–062D-4444-A888-BBEC783E31BD
xcrun simctl erase
xcrun simctl erase all Erase all simulators
xcrun simctl boot
xcrun simctl delete DEVICE_UUID Delete a simulator by device UUID
xcrun simctl addmedia booted ~/Downloads/hain.png Add a media file to the simulator
xcrun simctl install booted /file_path/HaiN.app Install an application in App format to the opening simulator
xcrun simctl uninstall booted HaiN.CLI Uninstall an application from the opening simulator
xcrun simctl io booted screenshot screen.png Take a screenshot of the opening simulator
xcrun simctl io booted recordVideo news.mov Record a video of the opening simulator
xcrun simctl spawn booted log stream — level=debug Stream the log of the opening simulator

Coding

Debugging

Deployment

Keychain

  1. Convert p12 to pem

https://stackoverflow.com/questions/10412603/convert-p12-file-to-pem-using-terminal-app-in-mac-no-such-file-or-directory

1
openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts

Or

1
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12

Testing

1
gem install xcpretty
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Create a new simulator device
DEVICE_UUID=$(xcrun simctl create "HaiN_iPhone_11" "com.apple.CoreSimulator.SimDeviceType.iPhone-11" "com.apple.CoreSimulator.SimRuntime.iOS-15-5")
echo "Created new simulator device with UUID: $DEVICE_UUID"

DESTINATION="platform=iOS Simulator,id=$DEVICE_UUID"

if ! [ -x "$(command -v xcpretty)" ]; then
  xcodebuild -workspace ./path/Project.xcworkspace -scheme UnitTestScheme -destination "$DESTINATION" test
else
  xcodebuild -workspace ./path/Project.xcworkspace -scheme UnitTestScheme -destination "$DESTINATION" test | xcpretty --report html
fi

#Delete the simulator device
xcrun simctl delete $DEVICE_UUID

Troubleshooting

XCProject (https://github.com/Serchinastico/Kin)

1
2
pip install kin
kin --project ./path/Project.xcodeproj