0

我创建了一个 iPhone 应用程序并将谷歌驱动库集成到项目中,并且还在构建设置中进行了所需的设置。我在编译时遇到错误。请任何人都可以帮助我

#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");
}

我在模拟器上运行这段代码。所以我遇到了错误

 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

提前致谢

4

1 回答 1

0

在您的代码中创建了多个参考类。请删除 google api 所有文件并重新添加。

请参考此链接,它将对您有所帮助。

架构 i386 的重复符号

于 2013-03-04T13:26:43.913 回答