简体   繁体   中英

Apple Mach-O Linker Error (IAP)

I'm struggling with in-app purchases. Whenever I import StoreKit, I receive this error.
I've been at this for days with no luck.. Someone help?

Header File:

#import <StoreKit/StoreKit.h>    

#define kInAppPurchaseManagerProductsFetchedNotification          @"kInAppPurchaseManagerProductsFetchedNotification"

@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate>
{
    SKProduct *proUpgradeProduct;
    SKProductsRequest *productsRequest;
}
@end

Implementation File:

#import "IAPManager.h"

@implementation InAppPurchaseManager 

- (void)requestProUpgradeProductData
{
    NSSet *productIdentifiers = [NSSet 
       setWithObject:@"com.runmonster.runmonsterfree.upgradetopro" ];
    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    [productsRequest start];
}

#pragma mark -
#pragma mark SKProductsRequestDelegate methods

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *products = response.products;
    proUpgradeProduct = [products count] == 1 ? [[products firstObject] retain] : nil;
    if (proUpgradeProduct)
    {
        NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
        NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
        NSLog(@"Product price: %@" , proUpgradeProduct.price);
        NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }


    [productsRequest release];

    [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
@end

The error thats killing me:

    Undefined symbols for architecture armv7:
      "_OBJC_CLASS_$_SKProductsRequest", referenced from:
          objc-class-ref in IAPManager.o
    ld: symbol(s) not found for architecture armv7
    collect2: ld returned 1 exit status

"_OBJC_CLASS_$_SKProductsRequest", referenced from:    
Objc-class-ref in IAPManager.o    
Symbol(s) not found for architecture armv7    
Collect2: Id returned 1 exit status

Because you have added the "Header", not the binary. Put the StoreKitFramework into the buildPhase->Link binary with libraries. Magically this will work ;)

You forgot to add the StoreKit.framework to the libraries you link against.

This link shows how you can add it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM