开发者

Is it even possible for one iOS app to access another app's Caches directory?

I'm writing a unit test with GHUnit. I would like to check if a file is being generated in the Caches directory within the Library directory of an开发者_运维知识库other app. Is this feasible, or are apps prevented from accessing each others' Library directories? And if so, are there any possible workarounds for creating a unit test for this? Could I possibly store the generated file in a different directory, such as Documents, or would that not help?


On device it is not possible at all. In simulator you can theoretically do it if you know the random UUID that names the directory that the application is installed in.

But I would highly discourage you from even trying. Instead make the code you intend to test stand enough of it's own to be testable. A unit test that verifies if another application behaves is on it's own almost as useless as a unit test that verifies that you call an API with the correct arguments.


I don't understand the context that you're attempting to unit test, so maybe my answer is wrong, but what I get is that you want to access your other app because GHUnit builds as a separate app.

There should be no reason to do this - instead of beating the sandbox problem, let's go around the whole issue.

Why not run whatever cache-creating code you are trying to test in the first place from the test target app, and then check the Libary/Cache directory of your bundle?

That's all there should be to it.


Apps can only access their own folders within their sandbox. Is your unit testing app separate from your app that you want to verify the cache contents of?


No, what you would need to do is use url prefixes and have the methods to do whatever you need done registered by that application on install.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜