我正在运行Xcode 6 Beta 5,但自第一次测试以来,这种情况一直在发生 . 模拟器中的应用程序目录在每次运行后都会被重命名 . 我花了一段时间来弄明白这一点 . 我正在使用它来获取doc的dir参考 .
NSString *folder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES) lastObject];
NSLog(@"Documents Dir: %@",folder);
现在例如在第一次运行时它将是:
/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE / data / Containers / Data / Application / 4B10C2E4-A5C3-4C64-93B1-4069FCCB9C46 / Documents
现在第二次运行:
/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE / data / Containers / Data / Application / 7E9EB62D-115A-4092-AD23-CB6BA3E5E10F / Documents
第三轮:
/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE / data / Containers / Data / Application / EC8F41E8-52ED-4B10-9808-B3ACC46FC6AA / Documents
这对我的应用程序造成了严重破坏,因为它存储了应用程序中某些文件的路径引用 . 这不是我的NSLog语句返回不正确的结果,我验证了这是在Finder中发生的事情 . 它每次都在改变这个名字 . 有没有人见过这种情况?这是一个我误解的“特征”吗?
5 回答
事实证明Xcode 6实际上每次运行都会更改应用程序的UUID,而我存储绝对路径的错误 .
USE SIMPHOLDERS
我在Xcode 5上使用这个应用程序,在Finder中为模拟器中当前运行的应用程序打开Documents文件夹 .
http://simpholders.com/
还没有为Xcode 6做好准备(截至2014年9月24日),但保存了所有这些麻烦 .
In Xcode 6 / iOS8 The bundle is now separate from the data./ The application GUID is regenerated between runs in Xcode (not sure why)
1. FIND THE DEVICES FOLDER in SIMULATOR
打开每个/device.plist以查看哪个GUID是XCode中的哪个设备 - 我认为这是静态的
3. FIND THE DEVICE you're running on iPad 2 - I think this is static
4. Find your application /Documents folder
请注意GUID C220D351-0BE7-46BA-B35E-D16646C61A3F每次在XCode 6中运行应用程序时都会重新生成
MAIN BUNDLE path
NEVER CACHE THE PATH to /Documents between runs it will change.
我把它连载到一个plist并且无法弄清楚它们为什么一直在消失
上面的/ GUID在运行之间不断变化但是如果在Finder中打开/ Documents文件夹保持打开状态 .
Free Solution
使用开源库OpenSim . OpenSim是SimPholders的开源替代品,用Swift编写 .
Paid Solution
使用SimPholder应用程序了解当前的应用程序位置 .
对于xcode 6.0>
下载SimPholder 2.0 alpha 2
对于xcode 5.1 <
下载SimPholders 1.5
我可以确认这是Xcode 6与iOS 8无关 .
我有两台开发机器 . 在其中一个我有Xcode 5.我一直在那台机器上工作,我的网址很好(照片应用程序,照片可见) .
昨天我在带有Xcode 6的机器上检查了git我的源代码 . 我注意到我的照片不再可见,只有在该应用程序会话期间创建的照片 .
经过一些调试,我意识到文件:/// var / mobile / Applications / B6A6BAEF-C90C-4A2A-93DB-E6700B88971F / Documents /正在改变每个应用程序运行 .
我一直在使用iOS 7设备 .
我将再次在带有Xcode 5的机器上进行检查,以确认我什么时候拿到它 .
您需要在DocumentDirectory(目录/文件名)中仅保存路径,并在每次加载文件时将其添加到DocumentDirectory ...