Loading XML config from URL on iOS - [Metaio SDK]

290 views Asked by At

in must examples of Metaio SDK docs the xml's are loaded from Assets folder (more specifically, from NSBundle in iOS).

But in iOS, you can't write into a file in your app's bundle -- the entire bundle is read-only

https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/index.html

In my project I need download all stuff to working with Metaio SDK, things like Videos, Sounds, 3D models and trackable images and your xml configs.

For example, from the Metaio docs, to work with a XML then are in Assets, are easy like:

NSString* MarkerTrackingFile = [[NSBundle mainBundle] pathForResource:@"tracking" ofType:@"xml" inDirectory:@"Assets/tracking"];

But how I said, I need to get this XML from internet, so, to do this I make an method to download.

(This is just a dirty code for study, not optimized without threads and anything special, for now)

/*********************************************/

-(void)downloadXML{

    NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString  *documentsDirectory = [paths objectAtIndex:0];

    NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"markerless_tracking.xml"];


    NSString *contents = [NSString stringWithContentsOfFile:filePath];

    NSLog(@"%@", contents);

}

After this download, I try to use this XML in my project, I confirmed this consistence, but not work when I call him with this method, but i receive the message from error: No success loading the tracking configuration

- (void) loadTrackingConfigurationFiles
{
    // Markerless tracking configuration file

    NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString  *documentsDirectory = [paths objectAtIndex:0];
    NSString* markerlessTrackingFile = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"markerless_tracking.xml"];

    // We apply the correct one to the SDK
    if(markerlessTrackingFile)
    {
        bool success = m_metaioSDK->setTrackingConfiguration([markerlessTrackingFile UTF8String]);
        if( !success)
            NSLog(@"No success loading the tracking configuration");
    }

}

My main question is: Is possible loading a xml from outside NSBundle folder in METAIO SDK? In my project i don't have anything in local folders, everything is downloaded, tracking images, videos, sounds, xml etc, is viable the use Metaio SDK for this purpose?

I appreciate any help, examples or suggestions.

0

There are 0 answers