|
| 1 | +--- |
| 2 | +name: run-ios-simulator |
| 3 | +description: Build and run an iPlug2 iOS app in the iOS Simulator |
| 4 | +--- |
| 5 | + |
| 6 | +# Run iOS App in Simulator |
| 7 | + |
| 8 | +Use this skill when the user wants to run an iPlug2 iOS project in the iOS Simulator. |
| 9 | + |
| 10 | +## Workflow |
| 11 | + |
| 12 | +1. **Identify the project:** |
| 13 | + - If not specified, look for `.xcworkspace` files in the repo root |
| 14 | + - Ask user to choose if multiple projects exist |
| 15 | + |
| 16 | +2. **Check available simulators and get UDID:** |
| 17 | + ```bash |
| 18 | + xcrun simctl list devices available | grep -E "iPhone|iPad" |
| 19 | + ``` |
| 20 | + Extract the UDID from the output (the value in parentheses, e.g., `9E866BC3-9E64-4608-B4D0-D20F1DE3E980`) |
| 21 | + |
| 22 | + Or programmatically: |
| 23 | + ```bash |
| 24 | + xcrun simctl list devices available -j | jq -r '.devices[] | .[] | select(.name=="[DeviceName]") | .udid' |
| 25 | + ``` |
| 26 | + |
| 27 | +3. **Build for Simulator:** |
| 28 | + ```bash |
| 29 | + xcodebuild -workspace [Project]/[Project].xcworkspace \ |
| 30 | + -scheme "iOS-APP with AUv3" \ |
| 31 | + -configuration Debug \ |
| 32 | + -destination 'platform=iOS Simulator,name=[DeviceName]' \ |
| 33 | + build |
| 34 | + ``` |
| 35 | + |
| 36 | +4. **Find the built app:** |
| 37 | + ```bash |
| 38 | + find ~/Library/Developer/Xcode/DerivedData -name "[Project].app" -path "*Debug-iphonesimulator*" -type d 2>/dev/null | head -1 |
| 39 | + ``` |
| 40 | + |
| 41 | +5. **Boot simulator and install (use UDID, not "booted"):** |
| 42 | + ```bash |
| 43 | + open -a Simulator |
| 44 | + xcrun simctl boot [UDID] 2>/dev/null || true |
| 45 | + xcrun simctl install [UDID] "[path/to/Project.app]" |
| 46 | + ``` |
| 47 | + Using the UDID ensures the correct simulator is targeted even when multiple are running. |
| 48 | + |
| 49 | +6. **Launch the app (use UDID):** |
| 50 | + ```bash |
| 51 | + # Get bundle ID from Info.plist |
| 52 | + /usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "[path/to/Project.app]/Info.plist" |
| 53 | + xcrun simctl launch [UDID] [bundle.identifier] |
| 54 | + ``` |
| 55 | + |
| 56 | +## Notes |
| 57 | + |
| 58 | +- **No code signing required** for Simulator builds |
| 59 | +- **Always use UDID** to target a specific simulator, not `booted` |
| 60 | +- Default device: iPhone 17 Pro (or latest available) |
| 61 | +- The AUv3 plugin is embedded in the app and will be available to host apps in the Simulator |
| 62 | +- Use `xcrun simctl list devices available` to see all device options |
| 63 | +- If `jq` is not installed, extract UDID manually from `xcrun simctl list devices available` output |
| 64 | + |
| 65 | +## Example |
| 66 | + |
| 67 | +For TemplateProject on iPhone 17 Pro: |
| 68 | +```bash |
| 69 | +# Get the UDID for iPhone 17 Pro |
| 70 | +UDID=$(xcrun simctl list devices available -j | jq -r '.devices[] | .[] | select(.name=="iPhone 17 Pro") | .udid') |
| 71 | + |
| 72 | +# Build |
| 73 | +xcodebuild -workspace TemplateProject/TemplateProject.xcworkspace \ |
| 74 | + -scheme "iOS-APP with AUv3" -configuration Debug \ |
| 75 | + -destination "platform=iOS Simulator,id=$UDID" build |
| 76 | + |
| 77 | +# Install and run using UDID |
| 78 | +open -a Simulator |
| 79 | +xcrun simctl boot $UDID 2>/dev/null || true |
| 80 | +xcrun simctl install $UDID ~/Library/Developer/Xcode/DerivedData/TemplateProject-*/Build/Products/Debug-iphonesimulator/TemplateProject.app |
| 81 | +xcrun simctl launch $UDID com.AcmeInc.TemplateProject |
| 82 | +``` |
0 commit comments