Can't PDetsFromPath() - ObjectiveC

I'm trying to develop an XPC plugin on OSX that uses TurboActivate, but for some reason PDetsFromPath() cannot find the data file. Maybe it's too late at night, I can't see why this isn't working.

My code (Objective C):

NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSString *ns_path = [bundle bundlePath]; NSString *dat_path = [ns_path stringByAppendingString:@"/Contents/Resources/TurboActivate.dat"]; int path_length = (int)[dat_path lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"XPC says data path at %@, string length %d", dat_path, path_length);

char *data_path = (char *)malloc((path_length+1)*sizeof(char)); [dat_path getCString:data_path maxLength:path_length+1 encoding:NSUTF8StringEncoding]; if(PDetsFromPath(data_path) != TA_OK) { NSLog(@"LM could not find TA product data"); NSLog(@"- Searched for dat file at [%s]", data_path); FILE *myfile = fopen(data_path, "rb"); if(!myfile) NSLog(@"std file could not be opened"); else { fclose(myfile); NSLog(@"std test file OK"); } }

Output to console:

15/04/2014 23:05:35.718 test3XPC[2902]: XPC says data path at /Users/me/Library/Developer/Xcode/DerivedData/test3-gqcdtgkuznwsgmgqumcnbjrvlcmi/Build/Products/Debug/test3App.app/Contents/PlugIns/test3XPC.pluginkit/Contents/Resources/TurboActivate.dat, string length 20015/04/2014 23:05:35.732 test3XPC[2902]: LM could not find TA product data15/04/2014 23:05:35.733 test3XPC[2902]: - Searched for dat file at [/Users/me/Library/Developer/Xcode/DerivedData/test3-gqcdtgkuznwsgmgqumcnbjrvlcmi/Build/Products/Debug/test3App.app/Contents/PlugIns/test3XPC.pluginkit/Contents/Resources/TurboActivate.dat]15/04/2014 23:05:35.733 test3XPC[2902]: std test file OK

The path is very long because (a) it's in the Xcode output directory and (b) due to the structure required for this kind of plugin. As you can see, a standard C file handle can be opened on the same path.

By the way, the string length in the output above is 13 chars too long because I obfuscated a small bit of the path.

OK, what was the return code for PDetsFromPath()? If it was TA_FAIL then that means the TurboActivate.dat file you're trying to load has already been loaded. If the error code was TA_E_PDETS then that means the TurboActivate.dat couldn't be loaded (because the file doesn't exist or it's corrupt or the path is wrong).

Yes, the product data was (unintentionally) being loaded twice; my mistake.

I didn't expect that the error would be TA_FAIL for such an instance, especially since it was the same data twice. It's a shame that PDetsFromPath() only returns 3 codes.

Thank you for the help.