Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if iOS application uses 'StoreKit.framework'?

Tags:

ios

storekit

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 ];
        // ...
    }

enter image description here

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:

enter image description here

However from Xcode:

enter image description here

Maybe this is a reason why even empty application has build-in StoreKit?

like image 747
snaggs Avatar asked Feb 07 '17 20:02

snaggs


People also ask

What is StoreKit framework in iOS?

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.

What framework must you import in order to work with in app purchases?

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.


1 Answers

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;
}
like image 192
Hassan Aftab Avatar answered Oct 19 '22 00:10

Hassan Aftab