Why would my app lack an Receipt while in development?
I am running my iOS (7, 8, 9) app from Xcode 7.3.1. The app’s Receipt seems to be missing. This app is currently shipping in the App Store, so I have my developer credentials, and a “sandbox” user login.
When running the following code:
NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL];
NSLog(@"url: %@", url);
The result in the Simulator 9.3 for iPhone 6s Plus:
file:///Users/Bourque/Library/Developer/CoreSimulator/Devices/7F32850A-CC1A-45A3-8ED6-95C75CD9DD44/data/Containers/Data/Application/46BDF021-D2A3-418E-91E1-61A15215942B/StoreKit/receipt
Yet when I navigate to the folder named with the 2nd UUID, I find no StoreKit
folder.
To test on a real iOS iPod touch, I expand that code to…
…See where the Receipt should be found.
NSURL* url = [[NSBundle mainBundle] appStoreReceiptURL];
NSLog(@"url: %@", url);
…Try to load such a file.
NSString* urlContents = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSLog(@"urlContents: %@", urlContents);
…Verify if the file exists.
NSError *err;
if ( [url checkResourceIsReachableAndReturnError:&err] == NO ) {
NSLog(@"BAD No receipt found for url: %@" , url );
} else {
NSLog(@"GOOD Receipt found for url: %@" , url );
}
Results when run.
url: file:///private/var/mobile/Containers/Data/Application/21430192-6E3A-4929-B847-23FD525D804E/StoreKit/sandboxReceipt
urlContents: (null)
BAD No receipt found for url: file:///private/var/mobile/Containers/Data/Application/21430192-6E3A-4929-B847-23FD525D804E/StoreKit/sandboxReceipt
file:///private/var/mobile/Containers/Data/Application/B1497F0D-95A7-4AD8-A9D5-7AF95663A04F/StoreKit/sandboxReceipt
Since you installed the app via Xcode and not from the Store it contains no receipt. However, you can start a SKReceiptRefreshRequest
in order to get a sandbox receipt you can use for testing.
Also be aware that you need to log out of the App Store and use a test user account (created in iTunes Connect) when prompted to log in after you started the request to make it work.