Unity 3D In-App Purchase for tvOS


Recently I was adding a Coin Shop with In-App purchase to a couple of my Unity 3D games.  I had successfully forward ported these games from Unity 5 to Unity 2019 and I had successfully added my coin shop with In-App purchase and built for macOS and iOS.

But when I tried to build for tvOS I got these errors:

Undefined symbols for architecture arm64:
“_OBJC_CLASS_$_SKProductsRequest”, referenced from:
objc-class-ref in UnityPurchasing.o
“_OBJC_CLASS_$_SKProductStorePromotionController”, referenced from:
objc-class-ref in UnityPurchasing.o
“_OBJC_CLASS_$_SKMutablePayment”, referenced from:
objc-class-ref in UnityPurchasing.o
“_OBJC_CLASS_$_SKReceiptRefreshRequest”, referenced from:
objc-class-ref in UnityPurchasing.o
“_OBJC_CLASS_$_SKPaymentQueue”, referenced from:
objc-class-ref in UnityEarlyTransactionObserver.o
objc-class-ref in UnityPurchasing.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After a bit of googling it appears that Unity 2019 does not automatically add the StoreKit.framework to the UnityFramework target.

A first I was a bit confused as I had added the StoreKit.framework to the Unity-iPhone target but that is not correct, it must be added to the UnityFramework target.

What you need to do, specifically, is this:

  1. Show the Project Navigator by clicking the Folder Icon on the top left hand side of Xcode
  2. Under the Folder Icon, click to select the Unity-iPhone target
  3. Under PROJECT, under TARGETS, click to select UnityFramework
  4. Click Build Phases
  5. Click the disclosure triangle to the left of Link Binary With Libraries
  6. Click + to Add items
  7. Click StoreKit.framework
  8. Click Add

Now you can Archive for tvOS and everything will work just as it did with macOS and iOS.

Here is a picture:

Sigh.

Leave a comment