On demand resources in iOS 9 - how to find out exact location of downloaded resources?

1.4k Views Asked by At

I'm trying to use ODR in my game which doesn't use xcassets.

So, I've got a texture with a tag (e.g. "tutorial"), made it ODR in project settings and used the code below the get it downloaded:

NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
    if (resourcesAvailable) {
        // Upload the texture
    }
    else
    {
        [resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
            if (error) {
                NSLog(@"Failed to load assets pack");
            }
            else
            {
                // Upload the texture
            }
        }];

    }
}];

The main bundle doesn't contain the texture in question (I've looked the bundle through in simulator folder). After calling the code above XCode and logs report that it was successfully downloaded and is ready to use.

Where the comment // Upload the texture is I need to call my code for uploading the texture into video memory, but the problem is - I can't get exact location of the downloaded file to do so.

Is there any way to know the location of downloaded assets?

2

There are 2 best solutions below

0
On

There is a bundle provided in NSBundleResourceRequest which you can use to get the resources. See Apple's Docs on NSBundleResourceRequest

0
On

This happened to me today, it was asset image that was linked under TARGET -> Resource Tags check if any image from assets is added there or not. If its there than remove and rebuild.