シミュレーターでアプリを実行すると、「ドキュメント」フォルダーにアプリのデータを格納するフォルダーがMacに作成されます。このフォルダーは、シミュレーターからアプリを削除したとき、または一部のアプリ設定をXCodeに変更したときに変更されます。数十のアプリがある場合、手作業で適切なアプリを見つけるのは悪夢です。
このフォルダに簡単にアクセスする方法はありますか?
シミュレーターでアプリを実行すると、「ドキュメント」フォルダーにアプリのデータを格納するフォルダーがMacに作成されます。このフォルダーは、シミュレーターからアプリを削除したとき、または一部のアプリ設定をXCodeに変更したときに変更されます。数十のアプリがある場合、手作業で適切なアプリを見つけるのは悪夢です。
このフォルダに簡単にアクセスする方法はありますか?
答えてみてください。次のようにログに記録するのはどうですか。
//App Directory & Directory Contents
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]);
私がやっていることは、Finderサイドバーにシミュレーターフォルダへのリンクを作成することです。おおよそ:
/Users/userName/Library/Application/Support/iPhone/Simulator/5.0/Applications/
次に、そのフォルダを「最終変更」でソートします。作業中のアプリのアプリフォルダーを見つけたら、それを展開してアプリを表示し(アプリ名を表示)、フォルダーに色を設定します。Finderは、ウィンドウを閉じて再度開かない限り、フォルダを「最終更新日」でソートされたままにしない場合があります。
一般的な場所は次のとおりです。
/Users/yourusername/Library/Application Support/iPhone Simulator/7.1/Applications/appcode/Documents/yourdocuments.db
'yourusername':開発マシンに使用したユーザー名
'appcode':次のような一連の数字であるアプリケーション識別子:32F88907-B348-4764-9819-A5B6F9169FB7(アプリに固有)
パスのバージョン番号(7.1)は、Xcodeのバージョン、つまりシミュレーターによって異なります。
directoryContentsAtPath:は非推奨です。
代わりにcontentsOfDirectoryAtPath:errorを使用してください:
//App Directory & Directory Contents
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"App Directory is: %@", appFolderPath);
NSLog(@"Directory Contents:\n%@", [fileManager contentsOfDirectoryAtPath:appFolderPath error:nil]);
Bazingaの回答(およびsebrennerの非推奨通知)は、Objective-Cに最適です。
Swiftの場合、同等のものは次のようになります。
let appFolderPath = NSBundle.mainBundle().resourcePath
let fileManager = NSFileManager.defaultManager()
print("App Directory is: \(appFolderPath)")
print("Directory Contents:\n \(fileManager.contentsAtPath(appFolderPath!))")