1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Swiftでiosのsimulatorが起動できなかった

Posted at

現象

xcodeを13.1にアップデートし、swiftのtemplateをpreviewで表示させようとしたが、表示がされず、ずっと[Preparing iPhone Simulator for Previews]の表示が続き、Loadingが続く
Screen Shot 2021-10-27 at 0.55.49.png

原因調査

https://qiita.com/coa00/items/6ae2766a2991424fd144
この記事を参考に原因を調査してみた

tail -f ~/Library/Logs/CoreSimulator/CoreSimulator.log
ログを見てみると。。。

Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Failed to create launchd simDataPath: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557” in the folder “tmp”." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557, NSUnderlyingError=0x6000029a4c30 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}
Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Failed to create /private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist (likely permission error or misbehaving 3rd party kext): Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUserStringVariant=Folder, NSUnderlyingError=0x6000029a6d00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUserStringVariant=Folder, NSUnderlyingError=0x6000029a6d00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUserStringVariant=Folder, NSUnderlyingError=0x6000029a6d00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Oct 27 00:59:21 mbp com.apple.dt.Xcode[14503] <Error>: Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSUserStringVariant=Folder, NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUnderlyingError=0x7ffc51719370 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

いくつかエラーが出ていた。
どれも見たことのないエラーなので、一つ一つ調べてみることに

Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Failed to create launchd simDataPath: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557” in the folder “tmp”." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557, NSUnderlyingError=0x6000029a4c30 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}

エラー分をみる感じだとtmpフォルダにcom.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557というファイルを権限エラーが原因で保存することができないと出ている。

Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Failed to create /private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist (likely permission error or misbehaving 3rd party kext): Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUserStringVariant=Folder, NSUnderlyingError=0x6000029a6d00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

エラー文をみる感じ、/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plisを権限エラーが原因で作られないと出ている。

Oct 27 00:59:21 mbp CoreSimulatorService[338] <Error>: Error Domain=NSCocoaErrorDomain Code=4 "The folder “disabled.plist” doesn’t exist." UserInfo={NSFilePath=/private/tmp/com.apple.CoreSimulator.SimDevice.6208C6B2-D5F1-4754-88BE-B60D89608557/disabled.plist, NSUserStringVariant=Folder, NSUnderlyingError=0x6000029a6d00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

上記のエラーは3回続いており、disabled.plistフォルダがないという一個前のエラーと関係のありそうなエラー文である。

解決策

上記の3つのエラー文を見た感じ、/tmp/privateディレクトリの権限周りでエラーになっていそうである。
そこで、/tmp/privateディレクトリに権限を付与してみた。

sudo chmod -R 777 /private/tmp

※-Rオプションは、複数ファイルに対して設定する場合、ディレクトリ内も設定対象とするオプションである(https://eng-entrance.com/linux-command-chmod#-R--recursive)

Screen Shot 2021-10-27 at 1.39.46.png

無事解決することができた!!
ログを確認する方法を知り、一つずつエラー文を読んだのが良かったです。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?