I write SDK for iOS and I want to validate if StoreKit.framework
is linked to application that uses my SDK, so I run:
if ([SKStoreProductViewController class]) {
SKStoreProductViewController *storeController =
[[ SKStoreProductViewController alloc ] init ];
// ...
}
However even if StoreKit.framework
is not linked [SKStoreProductViewController class
still returns true
.
How to solve this problem?
Edit 1
as @x4h1d pointed I created new empty project and added to default Controller:
BOOL isStoreKitAvailable =
(NSClassFromString(@"SKStoreProductViewController") != nil);
// => YES (there is no linked frameworks at all, why I get YES?)
Edit 2
My Provisioning profile has In-App Purchase
enabled (not a project itself)
from iOS App IDs:
However from Xcode:
Maybe this is a reason why even empty application has build-in StoreKit?
StoreKit provides a simple and secure way to purchase digital goods or services in your apps across all Apple platforms, so people can start playing, gaming, reading, and more, right away.
In-App Purchase allows you to embed a store inside your app using the Store Kit framework. The framework connects to the AppStore on your app's behalf to securely process payments from users, prompting them to authorize payment.
You can check the storekit availibility using following code.
func checkStoreKitAvailibility() -> Bool {
for bundle in Bundle.allFrameworks {
if ((bundle.classNamed("SKStoreProductViewController")) != nil) {
return true;
}
}
return false;
}
Edit: For Objective-C you can use:
- (BOOL)checkStoreKitAvailibility {
for (NSBundle *bundle in NSBundle.allFrameworks) {
if ([bundle classNamed:@"SKStoreProductViewController"]) {
return YES;
}
}
return NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With