Question

I am in the process of adding IAP to my Mac application distributed on the Mac App Store. It seems to be working fine locally on my Mac inside/outside XCode but for some reason it does not work on other Mac computers with different behaviour (SIGKILL or does not download the App Store Receipt).

Here is the code I use to ensure the App Store receipt is present or download it properly:

void EnsureAppstoreReceipt()
{
  // TODO: Note: In OS X, if the appStoreReceiptURL method is not available (on older systems), you can fall back to a hardcoded path.
  // The receipt’s path would be /Contents/_MASReceipt/receipt inside the app bundle.
  NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
  NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
  if(!receipt)
  {
    // Validation fails
    qDebug() << "No AppStore receipt found. Exiting with 173 to force OSX to generate one in " << QString::fromNSString(receiptURL.absoluteString);
    exit(173);
  }
}

I Archive the application in XCode and then choose Distribute and then Application. If I chose Don't resign then it does not download the App Store receipt even on my computer. But if I chose the "Mac Appstore Distribution" identity or the "Mac Development" profile then it properly loads the receipt on my development Mac but it does not work on other computer. It starts the app and always exit with the code 173 and nothing else.

Is it possible to test IAP in sandbox on a Mac where the application has not been built? And if so what am I missing here?

Was it helpful?

Solution

I finally found a way to do this based on a few tutorials like this one. I had to create a new provisioning profile to deploy to other Macs and for this provisionning profile I had to add each Mac machine on which I want to test my app with the "Add a device" on Certificates, Identifiers & Profiles.

Then I had to refresh the list of signing identities in XCode in Preferences => Account and had access to the new provisioning profile. Then I Archive, Distribute my build and export as an Application that I sign with the given provisioning profile and then the App properly launches with sandbox for the AppStore on other Mac computers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top