Swift5 IAP Code=0 "无法连接到iTunes Store"

The "Cannot connect to iTunes Store" issue may be due to one or more of the following reasons:

  • The sandbox may be unreachable. Check the System Status for the status of the iTunes Sandbox.
  • Your app does not have a bundle version (CFBundleVersion). See Setting the Version Number and Build String for more information.
  • Your app is running in the Simulator, which does not support in-app purchase.
  • You are attempting to purchase a product that is unavailable for sale. See Query the App Store for product information before presenting your app’s store UI for more information.

经过排查,发现项目虽然填写了build值,但是plist文件的Bundle Version字段丢失了值。

image.png

填上对应的数值后,再进行测试,就没有问题了。

附录:

In-App Purchase FAQ
SKError.Code
The status of the app receipt

你可能感兴趣的:(Swift5 IAP Code=0 "无法连接到iTunes Store")