LoginSignup
1
3

More than 5 years have passed since last update.

iOS シミュレータのアプリ用 Documents はどこにあるのか探る

Last updated at Posted at 2016-12-27

RN で iTunes で同期したファイルを見るだけのシンプルなファイラーを作ってるんだけど、下記の記事にある通り、 iOS 8 以降のシミュレータでは随分とややこしいところにそのファイルが配置される。
[iOS] iOS8シミュレータでのDocumentsディレクトリの場所

どうやらいいアプリもあるみたいなんだけど、なんかこんなことでアプリインストールしたくないなと思ってしまったので、下記の手順で無理やり調べてみた。

# シミュレータを起動して、そのデバイス ID を調べる↓
$ xcrun simctl get_app_container booted {Bundle ID}
/Users/.../Library/Developer/CoreSimulator/Devices/{device_id}/data/Containers/Bundle/Application/.../AwesomeFinder.app

# {device_id} を上記の値使って埋めて移動
$ cd /Users/.../Library/Developer/CoreSimulator/Devices/{device_id}/data/Containers/Data/Application

# どれが自分の作ったアプリケーションのフォルダか調べる (silver searcher 使ってるけど grep とかでもできると思う)
$ ag --hidden --search-binary AwesomeProject **/.com.apple.mobile_container_manager.metadata.plist
Binary file {ID}/.com.apple.mobile_container_manager.metadata.plist matches.

# 上記の ID 使って移動
$ cd {ID}/Documents

バイナリファイルの中の文字列を読み取ってるあたりがやばい。趣味アプリだからまぁいいけど、自動テストやろうと思ったらこんなゴリ押しな方法しかないの……?

1
3
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
3