XcodeではUTが実行できるのにxcodebuildではhungしてUTが動かなくなった時

# はじめに
XCTestで実装されたUnitTestがXcodeを用いて`Command + U`でテスト実行することはできるのに、以下のような`xcodebuild`コマンドでのUnitTest実行を行った時にテストが開始されずhangしてしまう事象に突然見舞われました。
```
xcodebuild -project <プロジェクトファイルのパス> \
-scheme <スキーム名> \
-configuration Debug \
-destination "OS=18.1,name=iPhone 16" \
-testPlan <テストプランの名前> \
-skip-testing <UIテストのターゲット名> \
clean test | bundle exec xcpretty
```

```
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:63E10B92-8C1E-4CC3-97A1-561536C41F7A, OS:18.1, name:iPhone 16 }
{ platform:iOS Simulator, id:63E10B92-8C1E-4CC3-97A1-561536C41F7A, OS:18.1, name:iPhone 16 }
▸ Processing empty-Alamofire_Alamofire.plist
▸ Linking QiitaWatch.debug.dylib
▸ Linking QiitaWatch
▸ Processing Info.plist
▸ Processing empty-QiitaWatchTests.plist
▸ Linking QiitaWatchTests
▸ Processing empty-QiitaWatchUITests.plist
▸ Linking QiitaWatchUITests

// ここからずっと動かない
```

# 原因
結局わかりませんでした！
直近心当たりあることとしては、Xcode16からXcode16.1に切り替えたことぐらいです、、
なので、一旦対処方法をお伝えして締めようと思います！(｀・∀・´)

# 対処方法
単純に`xcodebuild`でのUT実行でhungするとググっても合致する記事が出なかったので、まずはどの状況で起こる事象なのかもう少し調査しました。
調査を進めると、どうやらテストの並列実行をしている時のみ発生していそうでした。
以下でUT実行した場合は並列での実行はされないようになります。

一つのシミュレータでシリアルにUnitTestを行う
```
xcodebuild -project <プロジェクトファイルのパス> \
-scheme <スキーム名> \
-configuration Debug \
-destination "OS=18.1,name=iPhone 16" \
-testPlan <テストプランの名前> \
-skip-testing <UIテストのターゲット名> \
-maximum-concurrent-test-simulator-destinations 1 \ // 最大同時起動シミュレータ数
-parallel-testing-enabled NO \ // 並列実行を行うかどうか
clean test | bundle exec xcpretty
```

ここまでわかれば改めて「並列実行時にUT実行がhungする」でググってみるとApple Developer Forumsで似たような事象について議論されていました。

https://forums.developer.apple.com/forums/thread/735645

>こんにちは！すべてのシミュレーターを削除すると、この状況は改善しました。
>
>リストをチェックして xcrun simctl list 実行しました xcrun simctl delete id1 id2 id3...最後に、必要なシミュレーターを再度追加し、CMD+U を試しました。すべて正常です。

その中で、上記にようにシミュレーターを削除すると治ったといった投稿があったので、素直に全てのシミュレーターを削除しました。

### シミュレーターの全削除
シミュレーターの全削除は以下記事を参考にして行いました。

https://sussan-po.com/2022/05/22/delete-unused-simulators/

まず下記コマンドで何のシミュレーターがインストールされているか確認します。
```
xcrun simctl list
```

実行結果はこちら。
めちゃくちゃインストールされています。
```
% xcrun simctl list
== Device Types ==
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPhone SE (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE)
iPhone 7 (com.apple.CoreSimulator.SimDeviceType.iPhone-7)
iPhone 7 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus)
iPhone 8 (com.apple.CoreSimulator.SimDeviceType.iPhone-8)
iPhone 8 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus)
iPhone X (com.apple.CoreSimulator.SimDeviceType.iPhone-X)
iPhone Xs (com.apple.CoreSimulator.SimDeviceType.iPhone-XS)
iPhone Xs Max (com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max)
iPhone Xʀ (com.apple.CoreSimulator.SimDeviceType.iPhone-XR)
iPhone 11 (com.apple.CoreSimulator.SimDeviceType.iPhone-11)
iPhone 11 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro)
iPhone 11 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max)
iPhone SE (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE--2nd-generation-)
iPhone 12 mini (com.apple.CoreSimulator.SimDeviceType.iPhone-12-mini)
iPhone 12 (com.apple.CoreSimulator.SimDeviceType.iPhone-12)
iPhone 12 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro)
iPhone 12 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro-Max)
iPhone 13 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro)
iPhone 13 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro-Max)
iPhone 13 mini (com.apple.CoreSimulator.SimDeviceType.iPhone-13-mini)
iPhone 13 (com.apple.CoreSimulator.SimDeviceType.iPhone-13)
iPhone SE (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation)
iPhone 14 (com.apple.CoreSimulator.SimDeviceType.iPhone-14)
iPhone 14 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Plus)
iPhone 14 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro)
iPhone 14 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro-Max)
iPhone 15 (com.apple.CoreSimulator.SimDeviceType.iPhone-15)
iPhone 15 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Plus)
iPhone 15 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro)
iPhone 15 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro-Max)
iPhone 16 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro)
iPhone 16 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro-Max)
iPhone 16 (com.apple.CoreSimulator.SimDeviceType.iPhone-16)
iPhone 16 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Plus)
iPod touch (7th generation) (com.apple.CoreSimulator.SimDeviceType.iPod-touch--7th-generation-)
iPad mini 4 (com.apple.CoreSimulator.SimDeviceType.iPad-mini-4)
iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
iPad Pro (9.7-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)
iPad (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-)
iPad Pro (12.9-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-)
iPad Pro (10.5-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-)
iPad (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-)
iPad (7th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--7th-generation-)
iPad Pro (11-inch) (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-)
iPad Pro (12.9-inch) (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-)
iPad Pro (11-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch---2nd-generation-)
iPad Pro (12.9-inch) (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---4th-generation-)
iPad mini (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-mini--5th-generation-)
iPad Air (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation-)
iPad (8th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--8th-generation-)
iPad (9th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-9th-generation)
iPad Air (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air--4th-generation-)
iPad Pro (11-inch) (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-3rd-generation)
iPad Pro (12.9-inch) (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-5th-generation)
iPad Air (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-5th-generation)
iPad (10th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-10th-generation)
iPad mini (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-mini-6th-generation)
iPad Pro (11-inch) (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-4th-generation-8GB)
iPad Pro (11-inch) (4th generation) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-4th-generation-16GB)
iPad Pro (12.9-inch) (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-6th-generation-8GB)
iPad Pro (12.9-inch) (6th generation) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-6th-generation-16GB)
iPad Air 11-inch (M2) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-11-inch-M2)
iPad Air 13-inch (M2) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-13-inch-M2)
iPad mini (A17 Pro) (com.apple.CoreSimulator.SimDeviceType.iPad-mini-A17-Pro)
iPad Pro 11-inch (M4) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-M4-8GB)
iPad Pro 11-inch (M4) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-M4-16GB)
iPad Pro 13-inch (M4) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M4-8GB)
iPad Pro 13-inch (M4) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M4-16GB)
Apple TV (com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple TV 4K (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K)
Apple TV 4K (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p)
Apple TV 4K (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-4K)
Apple TV 4K (2nd generation) (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p)
Apple TV 4K (3rd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-4K)
Apple TV 4K (3rd generation) (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p)
Apple Watch Series 2 (38mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)
Apple Watch Series 3 (38mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm)
Apple Watch Series 3 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm)
Apple Watch Series 4 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm)
Apple Watch Series 4 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm)
Apple Watch Series 5 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm)
Apple Watch Series 5 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm)
Apple Watch SE (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-40mm)
Apple Watch SE (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm)
Apple Watch Series 6 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-40mm)
Apple Watch Series 6 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm)
Apple Watch Series 7 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-41mm)
Apple Watch Series 7 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-45mm)
Apple Watch SE (40mm) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-40mm-2nd-generation)
Apple Watch SE (44mm) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm-2nd-generation)
Apple Watch Series 8 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-8-41mm)
Apple Watch Series 8 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-8-45mm)
Apple Watch Ultra (49mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-49mm)
Apple Watch Series 9 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-9-41mm)
Apple Watch Series 9 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-9-45mm)
Apple Watch Ultra 2 (49mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-2-49mm)
Apple Watch Series 10 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-10-42mm)
Apple Watch Series 10 (46mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-10-46mm)
Apple Vision Pro (com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro)
== Runtimes ==
iOS 16.4 (16.4 - 20E247) - com.apple.CoreSimulator.SimRuntime.iOS-16-4
iOS 17.0 (17.0 - 21A328) - com.apple.CoreSimulator.SimRuntime.iOS-17-0
iOS 17.4 (17.4 - 21E213) - com.apple.CoreSimulator.SimRuntime.iOS-17-4
iOS 18.0 (18.0 - 22A3351) - com.apple.CoreSimulator.SimRuntime.iOS-18-0
iOS 18.1 (18.1 - 22B81) - com.apple.CoreSimulator.SimRuntime.iOS-18-1
== Devices ==
-- iOS 16.4 --
    iPhone SE (3rd generation) (9D709A7F-F611-4A65-81B2-192A45B82ED3) (Shutdown) 
    iPhone 14 (7DB679EE-8F10-40C7-AA97-49E826757BF1) (Shutdown) 
    iPhone 14 Plus (704D2D6D-391D-45E6-A1E7-E0D8FCA36816) (Shutdown) 
    iPhone 14 Pro (512C3E90-5CCC-403C-A335-D79D5C6FAD75) (Shutdown) 
    iPhone 14 Pro Max (2031418B-9317-4ED7-AA89-C51FFDE2735E) (Shutdown) 
    iPad Air (5th generation) (1289CAF6-1E38-4B52-899B-C4A0A37926E6) (Shutdown) 
    iPad (10th generation) (C9D2ACAF-D3C1-4CE5-9FAD-9B4BF415E526) (Shutdown) 
    iPad mini (6th generation) (8F6DAD04-5FCB-47A4-A424-ED33FD832D23) (Shutdown) 
    iPad Pro (11-inch) (4th generation) (B20CDB17-54C9-4EC5-8284-71672C361055) (Shutdown) 
    iPad Pro (12.9-inch) (6th generation) (5E2A16C7-D0E8-4DF0-8F3D-A36BFB40B43B) (Shutdown) 
-- iOS 17.0 --
-- iOS 17.4 --
    iPhone SE (3rd generation) (C0FF59D8-4105-40B0-B91D-933C5B7FFC84) (Shutdown) 
    iPhone 15 (4AF7798C-3B8B-45F5-888D-E2AAE42BE7DC) (Shutdown) 
    iPhone 15 Plus (1967DFEE-A7DB-45CE-95A1-CAEFE60DD529) (Shutdown) 
    iPhone 15 Pro (02CBD8D5-FE1D-475B-9E4E-20AAB548C38A) (Shutdown) 
    iPhone 15 Pro Max (33614639-A593-4BFF-9C80-2C7A23248C61) (Shutdown) 
    iPad Air (5th generation) (CD7E682E-B779-4F2D-8E12-86C6F406C3EB) (Shutdown) 
    iPad (10th generation) (AE3BB042-E56C-4758-A8A8-0FCEF16D0772) (Shutdown) 
    iPad mini (6th generation) (DF603B68-77DE-4570-BCD7-0BF9A29ED619) (Shutdown) 
    iPad Pro (11-inch) (4th generation) (33C0BD42-9FD8-4D27-88D8-2BD399A6B438) (Shutdown) 
    iPad Pro (12.9-inch) (6th generation) (FD9AB328-1A73-4D5E-A786-F4325ACE6063) (Shutdown) 
    iPad Air 11-inch (M2) (4A9E86EE-931C-47AE-80DD-2A9876C9DD93) (Shutdown) 
    iPad Air 13-inch (M2) (F1ADEE1E-9CB2-4629-9D9B-0FF900D92909) (Shutdown) 
    iPad Pro 11-inch (M4) (ADC73B82-049D-4F32-845B-66A5AA271102) (Shutdown) 
    iPad Pro 13-inch (M4) (B609711B-628B-4346-9943-2B6EF6603ABC) (Shutdown) 
-- iOS 18.0 --
    iPhone Xs (AB235626-9147-4545-9C75-F822B31916A5) (Shutdown) 
    iPhone Xs Max (4CAD27B2-D345-401C-BE88-9F8A04B217FD) (Shutdown) 
    iPhone Xʀ (E88511C6-D484-4A05-802E-81684379B229) (Shutdown) 
    iPhone 11 (6315A4B6-CF01-458F-AE79-011C06F183FE) (Shutdown) 
    iPhone 11 Pro (96419A8E-E2F3-48CD-AB6A-BA87562B0941) (Shutdown) 
    iPhone 11 Pro Max (10ADC9FD-405B-434C-AE7B-1511D9CFD8EA) (Shutdown) 
    iPhone SE (2nd generation) (35CBA45B-588D-471F-995F-27B29D5BAF08) (Shutdown) 
    iPhone 12 mini (4DDE264B-9A88-4C77-8EFC-916BA8AAC9C8) (Shutdown) 
    iPhone 12 (AEE5A725-069D-44FA-AC0E-1A16E8969C28) (Shutdown) 
    iPhone 12 Pro (D3F771C5-486A-4D0B-B53A-572914926C99) (Shutdown) 
    iPhone 12 Pro Max (42BD99E9-EECA-4C45-9040-E9EB0C403B88) (Shutdown) 
    iPhone 13 Pro (A7C1EFC5-0ACA-42C3-A9F8-06001DBF7D23) (Shutdown) 
    iPhone 13 Pro Max (0D0E086E-6DE7-406D-9FCE-53C728CA49AD) (Shutdown) 
    iPhone 13 mini (6275F79C-6AE4-4FC5-B13C-840B46C32122) (Shutdown) 
    iPhone 13 (0D3D9258-7544-4D9F-AB7E-F7D4ABE40D3B) (Shutdown) 
    iPhone SE (3rd generation) (12D19517-1CFE-47C7-886A-755AF4437B60) (Shutdown) 
    iPhone 14 (0748DFD1-5122-4B8E-8BBF-1365E059F2D8) (Shutdown) 
    iPhone 14 Plus (388BD571-CB2C-4339-BF84-AA2CAFFD6959) (Shutdown) 
    iPhone 14 Pro (F3BE98BD-26E3-4615-9D19-2299B0989A81) (Shutdown) 
    iPhone 14 Pro Max (F23CB0DF-E78B-4E46-B5A1-32B95935D58F) (Shutdown) 
    iPhone 15 (CC6116C5-7538-45B4-8DEA-74D451CA7D9D) (Shutdown) 
    iPhone 15 Plus (D25648DD-9BB1-41E9-8E27-C5A5EEAE9716) (Shutdown) 
    iPhone 15 Pro (A02839E5-DC54-449C-B072-1BA4541502B4) (Shutdown) 
    iPhone 15 Pro Max (D893B032-5984-4CB4-AA44-65B837C86C88) (Shutdown) 
    iPhone 16 Pro (49594689-A472-43E2-8274-F59C66CE92EE) (Shutdown) 
    iPhone 16 Pro Max (FFD6382C-E524-4586-8345-CECFA794A424) (Shutdown) 
    iPhone 16 (A18F08AC-2377-4EE2-816B-FAE9EB4D31B1) (Shutdown) 
    iPhone 16 Plus (47D83563-A978-4500-9914-221DA370908E) (Shutdown) 
    iPad (7th generation) (8670AD59-0088-4997-9928-62E2F6EFE6F9) (Shutdown) 
    iPad Pro (11-inch) (1st generation) (30117C23-ED2D-44D1-B352-B47951BDDF56) (Shutdown) 
    iPad Pro (12.9-inch) (3rd generation) (B55B7987-E8AE-44E2-AFFA-B4D7CC353481) (Shutdown) 
    iPad Pro (11-inch) (2nd generation) (22B77359-808F-4C87-8D5B-4FFD5659A238) (Shutdown) 
    iPad Pro (12.9-inch) (4th generation) (210085A5-2D2E-49C8-BAC3-8CBFF2590B91) (Shutdown) 
    iPad mini (5th generation) (638512BE-010C-40D2-89B9-41A5AD725FF2) (Shutdown) 
    iPad Air (3rd generation) (AB0BC219-3D32-46AB-ABDE-CA4CD8C228F7) (Shutdown) 
    iPad (8th generation) (232AE803-1ED3-4283-AA7F-043FFC4B3C3C) (Shutdown) 
    iPad (9th generation) (B870C28C-9AC0-4709-AFA0-3986F70D8CF5) (Shutdown) 
    iPad Air (4th generation) (40A271B3-8110-436D-B80F-31E181E319E9) (Shutdown) 
    iPad Pro (11-inch) (3rd generation) (5902E959-0446-4BF6-9E43-918BBDD6A8BA) (Shutdown) 
    iPad Pro (12.9-inch) (5th generation) (313893BB-EF23-4523-8075-92EE41DAA57B) (Shutdown) 
    iPad Air (5th generation) (28D54EC5-71C1-4B9A-A19E-F1DE2D5A9C2B) (Shutdown) 
    iPad (10th generation) (4E1BAD21-C1A7-42D2-8F2F-18AE08AA892D) (Shutdown) 
    iPad mini (6th generation) (B26832DB-0A4B-47A7-9D3D-8D522B508A37) (Shutdown) 
    iPad Pro (11-inch) (4th generation) (050B35B4-AE8C-429D-9594-33E10CC44135) (Shutdown) 
    iPad Pro (11-inch) (4th generation) (16GB) (FA8403DF-F24E-41AB-A367-A36E1C10C320) (Shutdown) 
    iPad Pro (12.9-inch) (6th generation) (DEBAD3A4-400F-4AED-9671-AEFDF6221C2D) (Shutdown) 
    iPad Pro (12.9-inch) (6th generation) (16GB) (3226C280-5D70-49E4-826C-4DE2D8664633) (Shutdown) 
    iPad Air 11-inch (M2) (C877088E-C46B-487A-8CFE-C806B25ED2C6) (Shutdown) 
    iPad Air 13-inch (M2) (97422F8A-8EE2-4CFD-97DD-94064A9B1590) (Shutdown) 
    iPad Pro 11-inch (M4) (9E0D8365-C924-49A2-9FA8-73A6B1BAF850) (Shutdown) 
    iPad Pro 11-inch (M4) (16GB) (529EF484-0B13-42A0-AAC5-1E5E61B5201C) (Shutdown) 
    iPad Pro 13-inch (M4) (6D3AF314-91F7-4C1C-9A22-80E7779FAF13) (Shutdown) 
    iPad Pro 13-inch (M4) (16GB) (1E7C256F-0EE4-4C4E-9748-3A0EFBAD1A64) (Shutdown) 
-- iOS 18.1 --
    iPhone SE (3rd generation) (59DE8CF9-B4F4-46D3-9069-49E841E1D647) (Shutdown) 
    iPhone 16 Pro (C906F4F4-E840-4329-80B4-1A57119A81F6) (Shutdown) 
    iPhone 16 Pro Max (50DC7AE0-4A88-46F0-9B62-FED5F451051E) (Shutdown) 
    iPhone 16 (BC2228A6-9A18-46F4-A1C0-0A413E2FEA7C) (Shutdown) 
    iPhone 16 Plus (5A7321C9-2B7D-4E15-AD3D-02526C9209C6) (Shutdown) 
    iPad (10th generation) (3E537526-5D5A-4F5D-8313-EB180FB5726A) (Shutdown) 
    iPad mini (6th generation) (F10CCF97-AA7A-4170-8C35-82DADD95219A) (Shutdown) 
    iPad Air 11-inch (M2) (CDCD3150-38A2-4A2C-B37D-484C0D1048EE) (Shutdown) 
    iPad Air 13-inch (M2) (FCEBB132-FA90-4ED8-9827-DBCE2DE0DC9F) (Shutdown) 
    iPad mini (A17 Pro) (8CB0169F-4ACB-423F-9585-140166D4E657) (Shutdown) 
    iPad Pro 11-inch (M4) (D28D3DE9-BD08-4EA8-8595-6F6401AC446E) (Shutdown) 
    iPad Pro 13-inch (M4) (528E28AE-E8C6-4512-8469-5758520F720A) (Shutdown) 
== Device Pairs ==
```

続いてインストールされているiOSシミュレーターランタイムを全て削除します。
Xcodeを開いて、メニューバーのSetting -> Componentsでシミュレーターのランタイム管理画面を開きます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3359094/5f09cbaf-d9d7-86c5-d249-36c8e67a7f00.png)

この画面で、iOSの全てのバージョンを削除します。

削除したら、下記コマンドで使用不可のシミュレーターを全て削除することで、結果的にインストールしていたシミュレーターを全て削除することができます。

```
xcrun simctl delete unavailable
```

再度インストール済みのシミュレーターを確認してみると全て消えています。
```
% xcrun simctl list              
== Device Types ==
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPhone SE (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE)
iPhone 7 (com.apple.CoreSimulator.SimDeviceType.iPhone-7)
iPhone 7 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus)
iPhone 8 (com.apple.CoreSimulator.SimDeviceType.iPhone-8)
iPhone 8 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus)
iPhone X (com.apple.CoreSimulator.SimDeviceType.iPhone-X)
iPhone Xs (com.apple.CoreSimulator.SimDeviceType.iPhone-XS)
iPhone Xs Max (com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max)
iPhone Xʀ (com.apple.CoreSimulator.SimDeviceType.iPhone-XR)
iPhone 11 (com.apple.CoreSimulator.SimDeviceType.iPhone-11)
iPhone 11 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro)
iPhone 11 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max)
iPhone SE (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE--2nd-generation-)
iPhone 12 mini (com.apple.CoreSimulator.SimDeviceType.iPhone-12-mini)
iPhone 12 (com.apple.CoreSimulator.SimDeviceType.iPhone-12)
iPhone 12 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro)
iPhone 12 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro-Max)
iPhone 13 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro)
iPhone 13 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro-Max)
iPhone 13 mini (com.apple.CoreSimulator.SimDeviceType.iPhone-13-mini)
iPhone 13 (com.apple.CoreSimulator.SimDeviceType.iPhone-13)
iPhone SE (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation)
iPhone 14 (com.apple.CoreSimulator.SimDeviceType.iPhone-14)
iPhone 14 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Plus)
iPhone 14 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro)
iPhone 14 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro-Max)
iPhone 15 (com.apple.CoreSimulator.SimDeviceType.iPhone-15)
iPhone 15 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Plus)
iPhone 15 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro)
iPhone 15 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro-Max)
iPhone 16 Pro (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro)
iPhone 16 Pro Max (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro-Max)
iPhone 16 (com.apple.CoreSimulator.SimDeviceType.iPhone-16)
iPhone 16 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Plus)
iPod touch (7th generation) (com.apple.CoreSimulator.SimDeviceType.iPod-touch--7th-generation-)
iPad mini 4 (com.apple.CoreSimulator.SimDeviceType.iPad-mini-4)
iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
iPad Pro (9.7-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)
iPad (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-)
iPad Pro (12.9-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-)
iPad Pro (10.5-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-)
iPad (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-)
iPad (7th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--7th-generation-)
iPad Pro (11-inch) (1st generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-)
iPad Pro (12.9-inch) (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-)
iPad Pro (11-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch---2nd-generation-)
iPad Pro (12.9-inch) (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---4th-generation-)
iPad mini (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-mini--5th-generation-)
iPad Air (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation-)
iPad (8th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--8th-generation-)
iPad (9th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-9th-generation)
iPad Air (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air--4th-generation-)
iPad Pro (11-inch) (3rd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-3rd-generation)
iPad Pro (12.9-inch) (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-5th-generation)
iPad Air (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-5th-generation)
iPad (10th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-10th-generation)
iPad mini (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-mini-6th-generation)
iPad Pro (11-inch) (4th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-4th-generation-8GB)
iPad Pro (11-inch) (4th generation) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-4th-generation-16GB)
iPad Pro (12.9-inch) (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-6th-generation-8GB)
iPad Pro (12.9-inch) (6th generation) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-6th-generation-16GB)
iPad Air 11-inch (M2) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-11-inch-M2)
iPad Air 13-inch (M2) (com.apple.CoreSimulator.SimDeviceType.iPad-Air-13-inch-M2)
iPad mini (A17 Pro) (com.apple.CoreSimulator.SimDeviceType.iPad-mini-A17-Pro)
iPad Pro 11-inch (M4) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-M4-8GB)
iPad Pro 11-inch (M4) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-M4-16GB)
iPad Pro 13-inch (M4) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M4-8GB)
iPad Pro 13-inch (M4) (16GB) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M4-16GB)
Apple TV (com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple TV 4K (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K)
Apple TV 4K (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p)
Apple TV 4K (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-4K)
Apple TV 4K (2nd generation) (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-2nd-generation-1080p)
Apple TV 4K (3rd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-4K)
Apple TV 4K (3rd generation) (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p)
Apple Watch Series 2 (38mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)
Apple Watch Series 3 (38mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm)
Apple Watch Series 3 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm)
Apple Watch Series 4 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-40mm)
Apple Watch Series 4 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-4-44mm)
Apple Watch Series 5 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-40mm)
Apple Watch Series 5 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-5-44mm)
Apple Watch SE (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-40mm)
Apple Watch SE (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm)
Apple Watch Series 6 (40mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-40mm)
Apple Watch Series 6 (44mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-6-44mm)
Apple Watch Series 7 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-41mm)
Apple Watch Series 7 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-7-45mm)
Apple Watch SE (40mm) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-40mm-2nd-generation)
Apple Watch SE (44mm) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm-2nd-generation)
Apple Watch Series 8 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-8-41mm)
Apple Watch Series 8 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-8-45mm)
Apple Watch Ultra (49mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-49mm)
Apple Watch Series 9 (41mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-9-41mm)
Apple Watch Series 9 (45mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-9-45mm)
Apple Watch Ultra 2 (49mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Ultra-2-49mm)
Apple Watch Series 10 (42mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-10-42mm)
Apple Watch Series 10 (46mm) (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-10-46mm)
Apple Vision Pro (com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro)
== Runtimes ==
== Devices ==
== Device Pairs ==
```

その後必要なシミュレーターを再インストールします。

まず必要なiOSシミュレーターランタイムを先ほどランタイムを削除した画面にてインストールします。(ランタイムのサイズはどでかいので、インストールはそこそこ時間かかります)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3359094/5f09cbaf-d9d7-86c5-d249-36c8e67a7f00.png)

ランタイムがインストールできたら、Manage Run Destinationsから具体のシミュレーターを作成します。
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3359094/1faddfa2-0277-a362-d74a-a5749fb5dbb9.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3359094/6d37229d-019f-761c-a121-6b44fb00ebac.png)

ほしいシミュレータの作成が完了したら、シミュレーターの全削除と再インストールが完了です。

### 試してみる
フォーラムの投稿にあったことを信じてシミュレータの全削除を行ったので、改めて`xcodebuild`を並列実行で実行できるか試してみました。

```
% xcodebuild -scheme <スキーム名> -configuration Debug -destination "OS=18.1,name=iPhone 16" -project <プロジェクトファイルのパス> -testPlan <テストプランの名前> -skip-testing <UIテストターゲット名> test | bundle exec xcpretty
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:63E10B92-8C1E-4CC3-97A1-561536C41F7A, OS:18.1, name:iPhone 16 }
{ platform:iOS Simulator, id:63E10B92-8C1E-4CC3-97A1-561536C41F7A, OS:18.1, name:iPhone 16 }
▸ Processing empty-Alamofire_Alamofire.plist
▸ Linking QiitaWatch.debug.dylib
▸ Linking QiitaWatch
▸ Processing Info.plist
▸ Processing empty-QiitaWatchTests.plist
▸ Linking QiitaWatchTests
▸ Processing empty-QiitaWatchUITests.plist
▸ Linking QiitaWatchUITests
2024-11-21 18:15:20.062 xcodebuild[60631:698411] [MT] IDETestOperationsObserverDebug: 653.750 elapsed -- Testing started completed.
2024-11-21 18:15:20.065 xcodebuild[60631:698411] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2024-11-21 18:15:20.066 xcodebuild[60631:698411] [MT] IDETestOperationsObserverDebug: 653.750 sec, +653.750 sec -- end
▸ Test Succeeded
2024-11-21 18:15:24.886 xcodebuild[60631:742960]  iOSSimulator: 📱<DVTiPhoneSimulator (0x11b1c5520), Clone 4 of iPhone 16, unknown class, 18.1 (22B81), 261BE7B1-6E32-45F8-9EC3-FC43106CAACE> unable to connect to "com.apple.instruments.deviceservice.lockdown" - timed out after 120 seconds
```

UTの並列実行できたぁー！
結構半信半疑でしたが、無事事象の解消はできました。

# おわり
ローカルで`xcodebuild`でUTを実行したいケースはそれほどあるわけではないのですが(CIのオペレーションを検証したい時ぐらい？)もし同じように困っている方の参考になれば幸いです。