I'm trying to add In-App Purchase to my iPhone app. But when i run my app or try to purchase a item my app crashes and shows the next error:
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found). (gdb)
I placed the StoreKit code in a NSObject class, look the code bellow.
StorePurchase.h:
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface StorePurchase : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver> {
}
- (void)loadStore;
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;
- (void)purchase;
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response;
@end
StorePurchase.m:
#import "StorePurchase.h"
@implementation StorePurchase
- (void)loadStore {
if ([SKPaymentQueue canMakePayments]) {
NSLog(@"Parental-controls are disabled");
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"testding2"]];
request.delegate = self;
[request start];
}
else {
NSLog(@"Parental-controls are enabled");
}
}
- (void)purchase {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"testding2"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
SKProduct *validProduct = nil;
int count = [response.products count];
if (count > 0) {
validProduct = [response.products objectAtIndex:0];
NSLog(@"Products found, joepie!!!");
} else if (!validProduct) {
NSLog(@"No products available");
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"An error encounterd");
}
else {
NSLog(@"Cancelled!");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
}
}
}
@end
I call the method "loadStore" like this:
StorePurchase *classStorePurchase = [[StorePurchase alloc] init];
[classStorePurchase loadStore];
I hope someone can help me with this...