我創建了一個IPhone應用程序,並將google驅動器庫集成到了項目中,並且還在生成設置中進行了必需的設置。 I「m到處下面的錯誤在編譯時,請任何人都可以幫我這個iPhone中的Google Drive集成錯誤
#import "ViewController.h"
#import "GTMOAuth2ViewControllerTouch.h"
#import "GTLService.h"
#import "GTLQueryDrive.h"
#import "GTLDrive.h"
#import "GDUTILITY.h"
@implementation ViewController
@synthesize authButton; @synthesize addMoreButton; @synthesize
btnRefresh;
@synthesize isAuthorized; @synthesize driveService; @synthesize
driveFiles;
#define kKeychainItemName111 @"GDDEMOTESTERNONARC: Google Drive"
#define kClientId111 @"16458548056-efdl07vmtam1pa159ln9024gc239oted.apps.googleusercontent.com"
#define kClientSecret111 @"yJU-avQu3Y0dlu3tL9ooLDRo"
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use. }
#pragma mark - View lifecycle
- (void)viewDidLoad {
[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.
GTMOAuth2Authentication *auth =[GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName111
clientID:kClientId111 clientSecret:kClientSecret111];
if ([auth canAuthorize])
{
[self isAuthorizedWithAuthentication:auth];
}
}
- (GTLServiceDrive *)driveService {
static GTLServiceDrive *service = nil;
if (!service)
{
service = [[GTLServiceDrive alloc] init];
// Have the service object set tickets to fetch consecutive pages
// of the feed so we do not need to manually fetch them.
service.shouldFetchNextPages = YES;
// Have the service object set tickets to retry temporary error conditions
// automatically.
service.retryEnabled = YES;
}
return service; }
- (IBAction)authButtonMethos:(id)sender {
if (!self.isAuthorized)
{
// Sign in.
SEL finishedSelector = @selector(viewController:finishedWithAuth:error:);
GTMOAuth2ViewControllerTouch *authViewController =[[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDriveFile clientID:kClientId111
clientSecret:kClientSecret111 keychainItemName:kKeychainItemName111
delegate:self finishedSelector:finishedSelector];
[self presentModalViewController:authViewController animated:YES];
}
else
{
// Sign out
[GTMOAuth2ViewControllerTouch removeAuthFromKeychainForName:kKeychainItemName111];
[[self driveService] setAuthorizer:nil];
// self.authButton.title = @"Sign in";
self.isAuthorized = NO;
// [self toggleActionButtons:NO];
[self.driveFiles removeAllObjects];
}
}
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error {
[self dismissModalViewControllerAnimated:YES];
if (error == nil)
{
[self isAuthorizedWithAuthentication:auth];
} }
- (void)isAuthorizedWithAuthentication:(GTMOAuth2Authentication *)auth {
[[self driveService] setAuthorizer:auth];
// self.authButton.title = @"Sign out";
self.isAuthorized = YES;
// [self toggleActionButtons:YES];
[self loadDriveFiles]; }
- (void)loadDriveFiles {
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = @"mimeType = 'text/plain'";
UIAlertView *alert = [GDUTILITY showLoadingMessageWithTitle:@"Loading files"
delegate:self];
[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFileList *files,
NSError *error)
{
[alert dismissWithClickedButtonIndex:0 animated:YES];
if (error == nil) {
if (self.driveFiles == nil)
{
self.driveFiles = [[NSMutableArray alloc] init];
}
[self.driveFiles removeAllObjects];
[self.driveFiles addObjectsFromArray:files.items];
// [self.tableView reloadData];
}
else
{
NSLog(@"An error occurred: %@", error);
[GDUTILITY showErrorMessageWithTitle:@"Unable to load files"
message:[error description]
delegate:self];
}
}];
NSLog(@"Click on the login button");
}
我上simulator.So運行此代碼我收到以下錯誤
ld: duplicate symbol _OBJC_METACLASS_$_GTLDriveAbout in
/Users/bcod/Library/Developer/Xcode/DerivedData/GoogleDDemo-frrwjztsgtylsxbmkifnctrxzjfh/Build/Intermediates/GoogleDDemo.build/Debug-iphonesimulator/GoogleDDemo.build/Objects-normal/i386/GTLDriveAbout.o
and
/Users/bcod/Library/Developer/Xcode/DerivedData/GoogleDDemo-frrwjztsgtylsxbmkifnctrxzjfh/Build/Intermediates/GoogleDDemo.build/Debug-iphonesimulator/GoogleDDemo.build/Objects-normal/i386/GTLDrive_Sources.o
for architecture i386
在此先感謝
在code.Please創建
你可以顯示一點點代碼.. – Ayaz 2013-03-04 06:53:07
你顯示了錯誤的代碼。啓動Terminal.app,進入Source目錄併發布'$ fgrep GTLDriveAbout * .m'的輸出。 – trojanfoe 2013-03-04 13:25:56
另外,嘗試檢查#include用法(在h或m文件中)...嘗試刪除/評論(一步一步地)#import「GTLService.h」...「GTLQueryDrive.h」..「GDUTILITY.h 「 – TonyMkenu 2013-03-06 09:35:56