ios Xcode 6 iPhone Simulator 应用程序支持位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24290989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:57:26  来源:igfitidea点击:

Xcode 6 iPhone Simulator Application Support location

iosxcodecore-dataios8xcode6

提问by Henry Glendening

In Xcode 6, I have an app I'm using Core Data in, but there is no folder in Application Support for the iOS 8 iPhone Simulator. Where are my files and Core Data sqlite database being stored?

在 Xcode 6 中,我有一个使用 Core Data 的应用程序,但在 iOS 8 iPhone 模拟器的应用程序支持中没有文件夹。我的文件和 Core Data sqlite 数据库存储在哪里?

回答by Scott Gardner

The simulator directory has been moved with Xcode 6 beta to...

模拟器目录已随 Xcode 6 beta 移至...

~/Library/Developer/CoreSimulator

Browsing the directory to your app's Documents folder is a bit more arduous, e.g.,

将目录浏览到应用程序的 Documents 文件夹有点困难,例如,

~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

回答by ucangetit

I would suggest that you use SimPholdersto find your Simulator files. It is a menu bar item that tracks your simulator apps and lets you go directly to their folders and content. It's awesome.

我建议您使用SimPholders来查找您的模拟器文件。它是一个菜单栏项,用于跟踪您的模拟器应用程序并让您直接转到其文件夹和内容。这很棒。

回答by Amar

I found SimulatorManagerapplication very useful. It takes you directly to the application folder of installed simulators. I have tried with 7.1, 8.0 and 8.1 simulators.

我发现SimulatorManager应用程序非常有用。它会将您直接带到已安装模拟器的应用程序文件夹。我尝试过 7.1、8.0 和 8.1 模拟器。

SimulatorManager resides as an icon in the system tray and provides an option to "Launch At Login".

SimulatorManager 作为图标驻留在系统托盘中,并提供“登录时启动”选项。

enter image description here

在此处输入图片说明

Note: This works only with Xcode 6 (6.1.1 in my case) and above.

注意:这仅适用于 Xcode 6(在我的情况下为 6.1.1)及更高版本。

Hope that helps!

希望有帮助!

回答by himan

To know where your .sqlite file is stored in your AppDelegate.m add the following code

要知道您的 .sqlite 文件在 AppDelegate.m 中的存储位置,请添加以下代码

- (NSURL *)applicationDocumentsDirectory
{
    NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory      inDomains:NSUserDomainMask] lastObject]);

    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory     inDomains:NSUserDomainMask] lastObject];
 }

now call this method in AppDelegate.m

现在在 AppDelegate.m 中调用这个方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  //call here
   [self applicationDocumentsDirectory];

}

回答by Nate Uni

This worked for me in swift:

这很快对我有用:

let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")

回答by Nagarjun

Open finder>Library>Developer>CoreSimulator>Devices

打开finder>Library>Developer>CoreSimulator>Devices

Then Change Arrangement icon from finder select Date Added

然后从查找器中更改排列图标选择添加日期

Select your app >data>Container>data>Applications>

选择您的应用>数据>容器>数据>应用程序>

choose your app >Documents>Here is your db file

选择你的应用>文档>这是你的数据库文件

In my case:

就我而言:

/Users/pluto/Library/Developer/CoreSimulator/Devices/A75107D2-A535-415A-865D-978B2555370B/data/Containers/Data/Application/265A12BC-FF5B-4235-B5EF-6022B83754B4/Documents/dboPhotoBucket.sqlite

Otherwise do this :

否则这样做:

NSLog(@"app dir: %@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]); 

- It will print the full path to data folder.

- 它将打印数据文件夹的完整路径。

Swift:

迅速:

let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
println("App Path: \(dirPaths)")

回答by seabass

I wrestled with this for some time. It became a huge pain to simply get to my local sqlite db. I wrote this script and made it a code snippet inside XCode. I place it inside my appDidFinishLaunching inside my appDelegate.

我为此纠结了一段时间。简单地访问我的本地 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

This creates a simlink at the root of your drive. (You might have to create this folder yourself the first time, and chmod it, or you can change the location to some other place) Then I installed the xcodewayplugin https://github.com/onmyway133/XcodeWay

这会在驱动器的根目录创建一个 simlink。(你第一次可能需要自己创建这个文件夹,然后chmod它,或者你可以将位置更改到其他地方)然后我安装了xcodeway插件https://github.com/onmyway133/XcodeWay

I modified it a bit so that it will allow me to simply press cmd+d and it will open a finder winder to my current application's persistent Documents directory. This way, not matter how many times XCode changes your path, it only changes on run, and it updates your simlink immediately on each run.

我稍微修改了它,以便它允许我简单地按 cmd+d 并且它会打开一个查找器绕线器到我当前应用程序的持久文档目录。这样,无论 XCode 更改您的路径多少次,它只会在运行时更改,并且在每次运行时都会立即更新您的 simlink。

I hope this is useful for others!

我希望这对其他人有用!

回答by user1039695

Use Finder-->go to folder and enter given basepath to reach application folders

使用 Finder--> 转到文件夹并输入给定的基本路径以到达应用程序文件夹

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;

NSLog(@"%@",basePath);

回答by Ohmy

The simulator puts the file in ~/Library/Developer/CoreSimulator/Devices/... but the path after /Devices is different for everyone.

模拟器把文件放在~/Library/Developer/CoreSimulator/Devices/...但是/Devices后面的路径每个人都不一样。

Use this handy method. It returns the path of the temporary directory for the current user and takes no argument.

使用这个方便的方法。它返回当前用户的临时目录的路径并且不接受任何参数。

NSString * NSTemporaryDirectory ( void );

So in my ViewController class I usually put this line in my viewDidLoad just for a reference when I need to grab my CoreData stored file. Hope this helps.

所以在我的 ViewController 类中,我通常将这一行放在我的 viewDidLoad 中,仅供参考,当我需要获取我的 CoreData 存储文件时。希望这可以帮助。

  NSLog(@"FILE PATH :%@", NSTemporaryDirectory());

(Note: to go to the path, from the finder menu click on Go and type ~/Library to open hidden directory then in the Finder Window you can click on the path shown on your console.)

(注意:要转到路径,请从查找器菜单中单击转到并键入 ~/Library 以打开隐藏目录,然后在查找器窗口中您可以单击控制台上显示的路径。)

回答by kakubei

This location has, once again, changed, if using Swift, use this to find out where the folder is (this is copied from the AppDelegate.swift file that Apple creates for you so if it doesn't work on your machine, search in that file for the right syntax, this works on mine using Xcode 6.1 and iOS 8 simulator):

此位置再次更改,如果使用 Swift,请使用它来找出文件夹的位置(这是从 Apple 为您创建的 AppDelegate.swift 文件复制的,因此如果它在您的机器上不起作用,请搜索该文件用于正确的语法,这适用于我使用 Xcode 6.1 和 iOS 8 模拟器):

let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
println("Possible sqlite file: \(urls)")