ios 有没有办法访问 iphone/ipad 中的文档文件夹(真机,没有模拟器)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15219511/
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
There's a way to access the document folder in iphone/ipad (real device, no simulator)?
提问by Sasha Grievus
there's a way to access a real device (iphone/ipad) document folder? I realized an app that store some data in that folder and i wanted to check if all is going in the right way.
有没有办法访问真实设备(iphone/ipad)文档文件夹?我意识到一个应用程序可以在该文件夹中存储一些数据,我想检查一切是否以正确的方式进行。
回答by smileBot
You can do this without iTunes and even if the file is somewhere else in the sandbox other than Documents.
您可以在没有 iTunes 的情况下执行此操作,即使文件位于沙箱中除文档之外的其他位置。
Go to Window/Devices in Xcode.
转到 Xcode 中的窗口/设备。
Next, select your device, and find the app in the list.
接下来,选择您的设备,然后在列表中找到该应用程序。
Now, look at the little gear icon at the bottom of the devices window. Click that bad boy.
See "Download Container..." in the list. Guess what that does? You got it. It downloads the whole sandbox with all the folders in the app's sandbox.
请参阅列表中的“下载容器...”。猜猜那有什么作用?你说对了。它会下载整个沙箱以及应用程序沙箱中的所有文件夹。
This should let you see the sandbox of apps that have not yet been released. So, good for testing on a real device.
这应该让您看到尚未发布的应用程序的沙箱。因此,非常适合在真实设备上进行测试。
If you're testing on a simulator life is way easier. Just download the free app OpenSim here. Update: These days I prefer SimSim, also free here.
如果您在模拟器上进行测试,生活会容易得多。只需在此处下载免费应用程序 OpenSim 。更新:这些天我更喜欢 SimSim,这里也是免费的。
回答by Shailesh
To anyone looking out for the exact answer:-
对于任何寻找确切答案的人:-
1.Go to plist file of your project.
1.转到项目的plist文件。
2.Add one row.
2.添加一行。
3.Then set the Boolean value of the property "Application supports iTunes file sharing" to "YES". (the key name is UIFileSharingEnabled
)
3.然后将属性“应用程序支持iTunes文件共享”的布尔值设置为“是”。(关键名称是UIFileSharingEnabled
)
And you are good to go.
你很高兴去。
Also note that you have to plugin the device in order to access the copied files (Programmatically). If you happen to go and try to access it on computer .. you wont be able to find the files.
另请注意,您必须插入设备才能访问复制的文件(以编程方式)。如果您碰巧去尝试在计算机上访问它.. 您将无法找到这些文件。
回答by WolfLink
Your question is a bit unclear, but I can see three interpretations:
你的问题有点不清楚,但我可以看到三种解释:
You can plug your iPhone into iTunes to see your documents folder for any app with iTunesFileSharing enabled, including any apps you have written or are writing.
If this is your own app, and you need help reading files from the documents folder, take a look at this question.
If this is someone else's app, and you want to access the app's documents folder without iTunes and the app does not have implementation for what you want, then I am afraid some sort of jailbreaking and hacking is necessary.
您可以将 iPhone 插入 iTunes,以查看任何启用了 iTunesFileSharing 的应用程序的文档文件夹,包括您编写或正在编写的任何应用程序。
如果这是您自己的应用程序,并且您需要帮助读取文档文件夹中的文件,请查看此问题。
如果这是其他人的应用程序,并且您想在没有 iTunes 的情况下访问该应用程序的文档文件夹,并且该应用程序没有实现您想要的内容,那么恐怕需要进行某种越狱和黑客攻击。
回答by Reno Jones
回答by KP_G
You can access documents directory from code using:
您可以使用以下代码从代码访问文档目录:
+ (NSString *) applicationDocumentsDirectory {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
return basePath;
}
And you can then go to terminal for the same path and check all the files.
然后您可以转到相同路径的终端并检查所有文件。
e.g on my system its like this:
例如在我的系统上是这样的:
~/Library/Developer/CoreSimulator/Devices/<deviceID>
回答by Mathew Christy
If you are looking for a tool that import file from iOS app document folder to Mac, install Apple configurator 2 (https://apps.apple.com/us/app/apple-configurator-2/id1037126344?mt=12)
如果您正在寻找将文件从 iOS 应用程序文档文件夹导入 Mac 的工具,请安装 Apple configurator 2 ( https://apps.apple.com/us/app/apple-configurator-2/id1037126344?mt=12)
Connect your device to Mac and in Apple configurator follow below steps
将您的设备连接到 Mac 并在 Apple 配置器中按照以下步骤操作
Double click on the Device
双击设备
Choose Actions > Export > Documents.
选择操作 > 导出 > 文档。
Select the file inside app to export, then click Choose. Save the items to the desired location in Mac.
在应用程序中选择要导出的文件,然后单击“选择”。将项目保存到 Mac 中的所需位置。