iOS开发

iOS 使用 StoreKit Configuration Fi

2026-01-20  本文已影响0人  _浅墨_

创建 StoreKit Configuration 文件用于本地测试内购功能。

确认了产品 ID:

现在创建 StoreKit Configuration 文件。

Products.storekit:

{
  "identifier" : "7A3F8B2E-1234-5678-9ABC-DEF012345678",
  "nonRenewingSubscriptions" : [

  ],
  "products" : [
    {
      "displayPrice" : "298",
      "familyShareable" : false,
      "internalID" : "lifetime_001",
      "localizations" : [
        {
          "description" : "一次购买,永久使用所有高级功能",
          "displayName" : "终身会员",
          "locale" : "zh_CN"
        },
        {
          "description" : "One-time purchase, lifetime access to all premium features",
          "displayName" : "Lifetime Membership",
          "locale" : "en_US"
        }
      ],
      "productID" : "SpeechNote.Membership.Lifetime",
      "referenceName" : "Lifetime Membership",
      "type" : "NonConsumable"
    }
  ],
  "settings" : {
    "_applicationInternalID" : "1234567890",
    "_developerTeamID" : "ABCD1234EF",
    "_failTransactionsEnabled" : false,
    "_locale" : "zh_CN",
    "_storefront" : "CHN",
    "_storeKitErrors" : [
      {
        "current" : null,
        "enabled" : false,
        "name" : "Load Products"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Purchase"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Verification"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "App Store Sync"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Subscription Status"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "App Transaction"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Manage Subscriptions Sheet"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Refund Request Sheet"
      },
      {
        "current" : null,
        "enabled" : false,
        "name" : "Offer Code Redeem Sheet"
      }
    ]
  },
  "subscriptionGroups" : [
    {
      "id" : "group_speechnote_membership",
      "localizations" : [
        {
          "description" : "SpeechNote Pro 会员订阅",
          "displayName" : "SpeechNote Pro",
          "locale" : "zh_CN"
        },
        {
          "description" : "SpeechNote Pro Membership Subscription",
          "displayName" : "SpeechNote Pro",
          "locale" : "en_US"
        }
      ],
      "name" : "SpeechNote Membership",
      "subscriptions" : [
        {
          "adHocOffers" : [

          ],
          "codeOffers" : [

          ],
          "displayPrice" : "18",
          "familyShareable" : false,
          "groupNumber" : 1,
          "internalID" : "monthly_001",
          "introductoryOffer" : {
            "displayPrice" : "0",
            "internalID" : "monthly_intro_001",
            "numberOfPeriods" : 1,
            "paymentMode" : "free",
            "subscriptionPeriod" : "P3D"
          },
          "localizations" : [
            {
              "description" : "每月订阅 SpeechNote Pro,随时可取消",
              "displayName" : "月度会员",
              "locale" : "zh_CN"
            },
            {
              "description" : "Monthly subscription to SpeechNote Pro, cancel anytime",
              "displayName" : "Monthly Membership",
              "locale" : "en_US"
            }
          ],
          "productID" : "SpeechNote.Membership.Monthly",
          "recurringSubscriptionPeriod" : "P1M",
          "referenceName" : "Monthly Membership",
          "subscriptionGroupID" : "group_speechnote_membership",
          "type" : "RecurringSubscription"
        },
        {
          "adHocOffers" : [

          ],
          "codeOffers" : [

          ],
          "displayPrice" : "128",
          "familyShareable" : false,
          "groupNumber" : 2,
          "internalID" : "yearly_001",
          "introductoryOffer" : {
            "displayPrice" : "0",
            "internalID" : "yearly_intro_001",
            "numberOfPeriods" : 1,
            "paymentMode" : "free",
            "subscriptionPeriod" : "P1W"
          },
          "localizations" : [
            {
              "description" : "年度订阅 SpeechNote Pro,比月付节省41%",
              "displayName" : "年度会员",
              "locale" : "zh_CN"
            },
            {
              "description" : "Yearly subscription to SpeechNote Pro, save 41% compared to monthly",
              "displayName" : "Yearly Membership",
              "locale" : "en_US"
            }
          ],
          "productID" : "SpeechNote.Membership.Yearly",
          "recurringSubscriptionPeriod" : "P1Y",
          "referenceName" : "Yearly Membership",
          "subscriptionGroupID" : "group_speechnote_membership",
          "type" : "RecurringSubscription"
        }
      ]
    }
  ],
  "version" : {
    "major" : 3,
    "minor" : 0
  }
}

产品配置包含:

产品 Product ID 类型 价格
月度会员 SpeechNote.Membership.Monthly 自动续订订阅 ¥18/月
年度会员 SpeechNote.Membership.Yearly 自动续订订阅 ¥128/年
终身会员 SpeechNote.Membership.Lifetime 非消耗型 ¥298

额外配置:


在 Xcode 中启用

  1. 打开 Scheme 配置

    • 菜单:ProductSchemeEdit Scheme...(或按 ⌘ + <
  2. 设置 StoreKit Configuration

    • 左侧选择 Run
    • 点击 Options 标签
    • StoreKit Configuration 下拉菜单中选择 Products.storekit
  3. 运行测试


测试功能

运行应用后,可以通过 Xcode 菜单测试各种场景:

菜单路径 功能
DebugStoreKitManage Transactions 查看/管理测试交易
DebugStoreKitTime Rate 加速订阅时间(1秒=1天等)
DebugStoreKitSubscription Renewal Rate 控制续订频率
DebugStoreKitDelete All Transactions 清除所有测试交易

常用测试场景:

Debug → StoreKit → Manage Transactions

真机测试会员订阅示例:

上一篇 下一篇

猜你喜欢

热点阅读