Xcode 6 beta将模拟器目录移动到了...
~/Library/Developer/CoreSimulator
访问您的应用程序文档文件夹的目录有些费劲,例如:
~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite
~/Library/Developer/CoreSimulator/Devices/B2C6629C-998D-4E84-9ADB-06CAF5BA4B89/data/Containers/Data/Application/62593001-FADA-4647-AA80-FE9973956C05/Documents/
。 - harryhornremove([aliasPath UTF8String]);
[[NSFileManager defaultManager]createSymbolicLinkAtPath:aliasPath withDestinationPath:DOCS_DIR error:nil];
#endif` 现在我有一个工作的符号链接,尽管 iOS8 + XCode6 每次构建时更改我的应用程序数据 GUID。 - seabassxcrun simctl list
е‘Ҫд»ӨжҹҘзңӢжЁЎжӢҹеҷЁеҗҚз§°дёҺи®ҫеӨҮUDIDд№Ӣй—ҙзҡ„еҜ№еә”е…ізі»гҖӮжӣҙе…·дҪ“ең°иҜҙпјҢжҳҜдҪҝз”Ёxcrun simctl list devices
е‘Ҫд»ӨгҖӮ - ThomasW我建议您使用 SimPholders 查找模拟器文件。 它是一个菜单栏项目,可跟踪您的模拟器应用程序,并允许您直接访问它们的文件夹和内容。 真是太棒了。
我觉得 SimulatorManager 应用非常有用。它能直接带你进入已安装的模拟器应用程序文件夹内。我尝试过使用 7.1、8.0 和 8.1 模拟器。
SimulatorManager 将作为系统托盘图标存在,并提供了一个“登录启动”选项。
注意:这仅适用于 Xcode 6(我的版本为 6.1.1)及以上版本。
希望这能帮到你!
要知道你的 .sqlite 文件存储在哪里,可以在你的 AppDelegate.m 中添加以下代码:
- (NSURL *)applicationDocumentsDirectory
{
NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
现在在AppDelegate.m中调用这个方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//call here
[self applicationDocumentsDirectory];
}
这个在Swift中对我起了作用:
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")
我曾经为此苦苦挣扎。只是想访问本地的 SQLite 数据库变得异常麻烦。于是我写了这个脚本,并将其作为代码片段放在 XCode 中。我将其放在 appDidFinishLaunching 函数中,即我的 appDelegate 文件。
//xcode 6 moves the documents dir every time. haven't found out why yet.
#if DEBUG
NSLog(@"caching documents dir for xcode 6. %@", [NSBundle mainBundle]);
NSString *toFile = @"XCodePaths/lastBuild.txt"; NSError *err = nil;
[DOCS_DIR writeToFile:toFile atomically:YES encoding:NSUTF8StringEncoding error:&err];
if(err)
NSLog(@"%@", [err localizedDescription]);
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
NSString *aliasPath = [NSString stringWithFormat:@"XCodePaths/%@", appName];
remove([aliasPath UTF8String]);
[[NSFileManager defaultManager] createSymbolicLinkAtPath:aliasPath withDestinationPath:DOCS_DIR error:nil];
#endif
打开Finder>Library>Developer>CoreSimulator>Devices
然后在Finder中选择“按添加日期排序”图标
选择您的应用程序 >数据>容器>数据>应用程序>
选择您的应用程序 >文档>这里是您的数据库文件
以我为例:
/Users/pluto/Library/Developer/CoreSimulator/Devices/A75107D2-A535-415A-865D-978B2555370B/data/Containers/Data/Application/265A12BC-FF5B-4235-B5EF-6022B83754B4/Documents/dboPhotoBucket.sqlite
NSLog(@"app dir: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);
- 它将打印数据文件夹的完整路径。
Swift:
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")
let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) print("App 路径: \(dirPaths)")
- AtomicBoolean使用Finder-->前往文件夹,并输入给定的基础路径以到达应用程序文件夹。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSLog(@"%@",basePath);
这个位置已经再次更改,如果使用Swift,请使用以下代码查找文件夹的位置(这是从苹果为您创建的AppDelegate.swift文件中复制的,因此如果在您的机器上不起作用,请在该文件中搜索正确的语法,这对我使用的Xcode 6.1和iOS 8模拟器有效):
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
println("Possible sqlite file: \(urls)")
https://gist.github.com/Gerst20051/8ca49d5afbf09007b3696fab6e9f425c
#!/bin/bash
DESTINATION_DIR="$HOME/Desktop"
APP_PATH=$(find ~/Library/Developer/CoreSimulator/Devices/*/data/Containers/Bundle/Application/*/*.app -type d -maxdepth 0 -print0 | xargs -0 ls -td | head -n1)
APP_DIRNAME=$(dirname "$APP_PATH")
APP_BASENAME=$(basename "$APP_PATH")
FILE_NAME="${APP_BASENAME%.*}"
cd "$APP_DIRNAME"
zip -qr "$DESTINATION_DIR/$FILE_NAME.zip" "$APP_BASENAME"