0

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.

Ezequiel Santos
  • 162
  • 2
  • 16
  • How is the config created (Creator app?) and downloaded into the app (downloaded or installed during build for your test)? – Wain Dec 19 '14 at 18:16
  • This config is generate with parameters based on image. For now, we are using a PHP web service to generate. – Ezequiel Santos Dec 19 '14 at 18:47
  • And you have verified that the config is valid, so you know the problem is in finding / loading the data into the app? If not, start there. – Wain Dec 21 '14 at 21:17
  • I tested The same file in Assets NSBundle and worked fine. The problem is in load outside Bundle. – Ezequiel Santos Dec 22 '14 at 02:06
  • Next have you logged `markerlessTrackingFile` ? You aren't using the best API methods to create it so the path could be invalid (multiple slashes). – Wain Dec 22 '14 at 11:28

0 Answers0