ios-xcb
Machine-wide atomic lock wrapper serializing parallel xcodebuild and simctl runs.
Lightweight POSIX shell wrapper that serializes concurrent xcodebuild, simulator, and device commands across parallel agents using an atomic directory lock with stale-PID cleanup.
git clone https://github.com/BestRoiMedia/bestroi-game-tools.gitWhy we built it
When multiple AI agents build or test different iOS games on the same Mac simultaneously, concurrent xcodebuild and simctl calls contend on DerivedData and simulator state. A single machine-wide lock prevents those collisions.
Architecture & how it works
xcb.sh attempts an atomic mkdir at $XCB_LOCK (defaulting to /tmp/games_xcb.lock), records the owner PID and command, clears stale locks if the owner process no longer exists, and releases the lock on EXIT, INT, or TERM while returning the wrapped command's exact exit code.
Key capabilities
- Atomic mkdir-based locking across all projects and parallel agents on one Mac
- Automatic stale-lock detection and cleanup when an owner PID exits
- Optional XCB_WAIT_LOG=1 diagnostics showing the active lock holder and command
- Transparent exit-code passthrough and signal-safe cleanup traps
Usage example
./ios/xcb.sh xcodebuild -project ./ios/App.xcodeproj -scheme App build
XCB_WAIT_LOG=1 ./ios/xcb.sh xcrun simctl boot "iPhone 17 Pro"