bartekpacia / garden

https://garden.pacia.tech
2 stars 1 forks source link

xcodebuild goodies #12

Open bartekpacia opened 8 months ago

bartekpacia commented 8 months ago

man xcodebuild.xctestrun

man xcresulttool (learned about it from https://keith.github.io/xcode-man-pages)

xcodebuild -enumerateTests

xcodebuild -showdestinations

bartekpacia commented 1 month ago

xcrun goodies

List installed apps:

xcrun simctl listapps booted | grep CFBundleIdentifier \
  | sed 's/[ \t]*$//; s/"//g; s/;//g' \
  | cut -d '=' -f 2 | \
  xargs -I {} echo {}

Install an app:

xcrun simctl install booted build/ios/iphonesimulator/Runner.app

List simulators:

xcrun simctl list devices booted

List simulators (only names):

xcrun simctl list --json devices available | jq -r '.devices | ."com.apple.CoreSimulator.SimRuntime.iOS-17-5" | .[] .name'

List simulators (only names and udids):

xcrun simctl list --json devices available | jq -r '.devices | ."com.apple.CoreSimulator.SimRuntime.iOS-17-5" | .[] | { "udid": .udid, "name": .name }'
bartekpacia commented 1 month ago

Landmarks app uses SwiftUI.

Build iOS app

xcodebuild build \
  -project Landmarks.xcodeproj \
  -scheme Landmarks \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath 'derivedData' \
  -resultBundlePath "resultBundle/$(date +%s)" \
  | xcbeautify

Build iOS app for testing

xcodebuild build-for-testing \
  -project Landmarks.xcodeproj \
  -scheme Landmarks \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  -derivedDataPath 'derivedData' \
  -resultBundlePath "resultBundle/$(date +%s)" \
  | xcbeautify

Run the test

xcodebuild test-without-building \
  -xctestrun derivedData/Build/Products/Landmarks_TestPlan_iphonesimulator17.*-arm64-x86_64.xctestrun \
  -only-testing 'LandmarksUITests/LandmarksUITests' \
  -destination 'platform=iOS Simulator,name=iPhone 15' \
  -resultBundlePath "resultBundle/ios_results_$(date +%s).xcresult"