我为iOS编写SDK,我想验证是否StoreKit.framework链接到使用我的SDK的应用程序,所以我运行:
if ([SKStoreProductViewController class]) {
SKStoreProductViewController *storeController =
[[ SKStoreProductViewController alloc ] init ];
// ...
}
Run Code Online (Sandbox Code Playgroud)
但即使StoreKit.framework没有链接[SKStoreProductViewController class仍然返回true.
如何解决这个问题呢?
编辑1
因为@ x4h1d指出我创建了新的空项目并添加到默认的Controller:
BOOL isStoreKitAvailable =
(NSClassFromString(@"SKStoreProductViewController") != nil);
// => YES (there is no linked frameworks at all, why I get YES?)
Run Code Online (Sandbox Code Playgroud)
编辑2
我的配置文件已In-App Purchase启用(不是项目本身)
来自iOS App ID:
但是来自Xcode:
也许这就是为什么即使是空应用程序内置 StoreKit也是如此?
在链接框架和库中,将其Optional替换为Required. 因此,如果应用程序开发人员希望实现它,他会将框架标记为Required应用程序中的框架。现在,如果您使用[SKStoreProductViewController class]. 它可能会崩溃,请使用它NSStringFromClass(@"SKStoreProductViewController")来确定使用它是否安全。
| 归档时间: |
|
| 查看次数: |
1691 次 |
| 最近记录: |