Bug in StoreKit 2 in iOS 15.5-7

I am implementing the new StoreKit 2 api code in my app and came across a weird bug that appears to be in the Apple code. I've simplified it down and can recreate in the SKDemo code with one line.

   func requestProducts() async {
...
      for product in storeProducts {
...
        case .autoRenewable:
          let monthlyPriceFormat = product.priceFormatStyle
..
  }

Running this on either the iOS 15.5 simulator or a iOS 15.7 device causes a linker error on startup.

dyld[96041]: Symbol not found: _$s8StoreKit12BackingValueO5value9atKeyPath8sentinel9transformxSSd_xyXKxSgACXEtlF
 Referenced from: /Users/aUser/Library/Developer/CoreSimulator/Devices/B3B66803-93C2-41A7-A700-B6AF78C6CB60/data/Containers/Bundle/Application/07BBCBFC-EFFD-41B7-8C69-209E44AA4D4D/SKDemo.app/SKDemo
 Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/StoreKit.framework/StoreKit
Symbol not found: _$s8StoreKit12BackingValueO5value9atKeyPath8sentinel9transformxSSd_xyXKxSgACXEtlF
 Referenced from: /Users/aUser/Library/Developer/CoreSimulator/Devices/B3B66803-93C2-41A7-A700-B6AF78C6CB60/data/Containers/Bundle/Application/07BBCBFC-EFFD-41B7-8C69-209E44AA4D4D/SKDemo.app/SKDemo
 Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.5.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/StoreKit.framework/StoreKit

The Product priceFormatStyle instance property is supposed to be available in iOS 15.0+ but doesn't appear to be there. It works fine on iOS 16.0 simulator and devices. The subscriptionPeriodFormatStyle instance property appears to have the same issue.

Also get the same type of error when trying to access the Product subscriptionPeriodFormatStyle instance variable.

Hi, unfortunately this is an issue in Xcode 14.0. The issue is resolved in Xcode 14.1 RC, so if you build your app with that version it will be able to use these properties on iOS versions earlier than iOS 16.0. There is a workaround you can use to use these APIs in apps built with Xcode 14.0 and 14.0.1 listed in the Xcode 14.0 release notes, I'll quote it here:

Using the following StoreKit properties and methods on apps with a minimum deployment target below iOS 16, macOS 13, watchOS 9, and tvOS 16 will cause the app to crash at launch when running on systems earlier than iOS 16, macOS 13, watchOS 9 and tvOS 16:

  • priceFormatStyle and subscriptionPeriodFormatStyle on Product values
  • environmentStringRepresentation and recentSubscriptionStartDate on Product.SubscriptionInfo.RenewalInfo values
  • environmentStringRepresentation on Transaction values
  • dateRange(referenceDate:) and formatted(_:referenceDate:) on Product.SubscriptionPeriod values (99962885) (FB11516463)

Workaround: For each target using a StoreKit API listed above, navigate to the “Build Phases” tab in the project editor with the target selected and add StoreKit.framework under “Link Binary With Libraries” if it isn’t already present. Set the “Status” column to “Optional.”

I am still experiencing this issue in Xcode 14.2 (14C18)

Bug in StoreKit 2 in iOS 15.5-7
 
 
Q