When running a unit test target in any of my iOS/macOS framework projects, I am experiencing random/inconsistent locks/hangs in xctest or xcodebuild. A number of test suites will run and pass but then on a few suites in particular, xcodebuild will stop reporting test results to the console and it appears to be stuck in an infinite loop/deadlock. I've actually seen the lock break in a few cases after 25-30 minutes but for the most part I cancel the test run before seeing if it restarts again.
This is completely reproducible for me just by running xcodebuild's test-without-building in a while loop in the terminal.
```
while true; do
xcodebuild -destination 'platform=iOS Simulator,name=iPad Air 2,OS=12.2' -derivedDataPath <PATH_TO_DERIVED_DATA> -xctestrun '<PATH_TO_XCTESTRUN>/Framework_iphonesimulator12.2-x86_64.xctestrun' -only-testing:<UNIT_TEST_TARGET_NAME> test-without-building
done
```
In the middle of a test suite running, the console will freeze partway through the suite. Sometimes, the lock comes after the first few runs of the command and other times it takes 20+ runs for the lock to occur.
This is happening on Xcode 10.2 and 10.2.1 with the framework projects on Swift 5. I first started noticing this on CI when my unit test jobs would fail because they exceeded to timeout limit for a job not receiving any responses from the console. That's what led me to test xcodebuild locally on my machine.
I cannot find any information online about hanging tests with the same scenario that I'm experiencing. Hoping someone on here can help me out.
Something worth noting - I actually have the exact same test suites from a framework project in an app project which experience the lock on the framework, but the lock does not happen in the app project.
This happens both when parallelization and randomization are enabled or disabled.