Access files stored in [NSFileManager containerURLForSecurityApplicationGroupIdentifier] for debugging - objective-c

I have an app with the following code:
NSURL *containerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:#"group.com.myCo.myApp"];
[containerURL URLByAppendingPathComponent:#"Myfile"]];
Reading and writing from Myfile is working, but I'd like to be able to access the file directly on my phone for debugging and testing purposes.
It's not in App's container (Window > Devices >> Download container), is it really not accessible to developers who have the device attached to the computer? I feel like I'm missing something here?

Related

-1001 error when NSURLSession via httpproxy and /etc/hosts

I am trying to setup a http proxy server in my computer to simulate a virtual development environment.
To access the local url, I put the DNS info into computers' /etc/hosts.
Here is my test code:
NSURLSession *session = [NSURLSession sharedSession];
NSURL *url = [NSURL URLWithString:#"http://someurl.local/bluh/bluh/path"];
NSURLSessionDataTask *dataTask =
[session dataTaskWithURL:url
completionHandler:^(NSData *data, NSURLResponse *response,
NSError *error) {
NSLog(#"data is %# error is %#", data, error);
}];
[dataTask resume];
My Experiments:
1. Browsers like safari or chrome can access both local web services and remote web services.
2. NSURLSession will response a NSURLErrorDomain Code=-1001 "The request timed out." when access local urls.
3. NSURLSession works correct if url not in /etc/hosts.
I also tried the NSURLConnection, same output as NSURLSession's.
so, is it means the NSURLConnection/NSURLSession and browsers use a different strategy to do the DNS?
how to deal or bypass this?
update
I build this environment for ios 7.0+.
Environment:
computer system: OS X 10.9.4 (13E28) which set up a proxy and have server in.
device system: iOS 7.1.2(11D257)
.local is treated as a special TLD on OS X, and I think iOS. I believe this is primarily because it's used as an indicator for Bonjour lookups. Try changing to a different TLD for your development domains. I use ".localhost"; I've seen others use ".dev". Both of those work as expected.
It looks from the linked article that you might have been running into the problem specifically because you were using x.local—a single label, which will be looked up via Bonjour instead of by DNS, so you might also find that x.y.local works, too, but personally I'd just avoid .local all together.

NSFileManager's ubiquityIdentityToken always returning null, even when logged in

My Mac application in Xcode has recently begun exhibiting strange symptoms when attempting to access iCloud. There haven't been any changes to my provisioning profiles, code signing identities, etc.
However, when running this code:
id token = [fileManager ubiquityIdentityToken];
NSLog(#"Token is: %#", token);
NSURL *iCloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];
NSLog(#"iCloud URL is: %#", iCloudURL);
The output is:
2013-10-28 08:17:12.372 MyApp[21101:303] Token is: (null)
2013-10-28 08:17:12.373 MyApp[21101:303] iCloud URL is: (null)
Which I find extremely strange, especially considering I am actually signed into iCloud on this machine. To be sure, I ran a quick test with Calendar, adding an event on an iPhone and ensuring that it showed up on the Calendar on my Mac.
But I was under the impression that [fileManager ubiquityIdentityToken]; would return whether the user was logged into iCloud, regardless of whether your entitlements, code signing, etc. was properly configured - indicating that it's less an issue on my end, and more an issue of the system's ability to return this value.
I have tried logging out (and back in) to iCloud, and have ensured that "Documents & Data" is enabled in the iCloud settings.
This was resolved by upgrading from the original Mavericks GM (build 13A598) to the official release (build 13A603.)

Current receipt invalid or mismatched ds person id + Included images

I'm setting up In-App purchasing for my Mac App. I currently am able to get the product from iTunes Connect, and even request a purchase. I'm pretty stumped with this error message, and am really hoping someone has been here before and can offer some assistance.
I am getting the (very helpful) localized error: Transaction error: Unknown Error.
I've included the two images of successful Mac App Store authentication, and error message. All I'm able to figure out is that the failedTransaction is being called from the SKPaymentTransaction.
Here's what I did. Archive in Xcode. Then distribute -> mac installer -> double-click .pkg file & install.
That seems to download the _MASReceipt and all is well when including
if(![[NSFileManager defaultManager] fileExistsAtPath:[[[NSBundle mainBundle] appStoreReceiptURL] path]]) {
NSLog(#"to get sandbox receipt, the app must be launched from outside xcode");
exit(173);
}

Using a certificate from Keychain in a Mac application

I am trying to build a mini-application to codesign one Mac OS X application with codesign utility and my developer certificate in keychain. To do that I use NSTask, like that :
[task setLaunchPath:#"/usr/bin/codesign"];
// ...
NSString *certificateName = #"\"3rd Party Mac Developer Application: Firstname Lastname\"";
NSString *appName = #"\"/path/to/My App.app\"";
NSArray *args = [NSArray arrayWithObjects:#"-s", certificateName, appName, nil];
// ...
[task launch];
I use a NSPipe to catch the output and I got this error message : no identity found...
But if I launch this command manually via Terminal, the application is well signed (so it's not a problem of certificate badly installed, etc).
I think issue comes because my application can't access the certificate in keychain (but me I can via Terminal).
Does someone already experienced this problem ?
Thanks in advance, Best.
You should not embed additional quotation marks in the arguments to NSTask:
NSString *certificateName = #"3rd Party Mac Developer Application: Firstname Lastname";
NSString *appName = #"/path/to/My App.app";
Spaces in the arguments are handled automatically, and do not require quotation marks.

Can I include a custom XML file in my application for default content?

I want to load content into my application from a web server, but if the internet is not available, I would like the user to have access to either default or old, downloaded content. It will be XML formatted. I know how to download XML from the web server into my app and I can store the XML-as-string and reload. But, how do I "ship" the product with a default XML data file? I tried to create a new resource with add-to-project, but I cannot find the file in my application's directory.
Is this possible?
Ok, I am back on this task. I have my XML properly download from my webserver with a URL pointing to the server's file, however, when I detect the network is 'unreachable' I simply point the URL to my application's local XML and I get the following error. I cannot find detail description, but I think it is saying that the URL is pointing to an inaccessible location. Am I storing this resource in the wrong location? I think I want it in the HomeDirectory / Library??
Debug output
loadMyXml: /var/mobile/Applications/950569B0-6113-48FC-A184-4F1B67A0510F/MyApp.app/SampleHtml.xml
2009-10-14 22:08:17.257 MyApp[288:207] Wah! It didn't work.
Error Domain=NSXMLParserErrorDomain Code=5 "Operation could not be completed. (NSXMLParserErrorDomain error 5.)"
2009-10-14 22:08:17.270 MyApp[288:207] Operation could not be completed. (NSXMLParserErrorDomain error 5.)
Totally! Just include it into your project and make sure it's included in the "Copy Bundle Resources" phase. Then it will be copied into ./YourApp.app/Contents/Resources/. This will work on both Mac and iPhone.
You can easily retrieve it by doing something like this (assuming your file is named "MyXMLFile.plist"):
NSString * pathToMyXMLFile = [[NSBundle mainBundle] pathForResource:#"MyXMLFile" ofType:#"plist"];