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
In the Safari on your Mac, on the Safari menu bar, choose the "Develop" menu. Scroll to the iOS Simulator option. Select the page for debugging.
You'll need to go to Settings > Advanced and check the Show Debug Menu option. Then you'll see the option to open the web inspector for the Simulator right from that menu. With the Web Inspector open, you can debug inside the Simulator just like you could right in a desktop browser with DevTools.
Open up a project in Xcode and click on the device near the Run ▶ button at the top left of your Xcode screen. Plug your iPhone into your computer. You can select your device from the top of the list. Unlock your device and (⌘R) run the application.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With