我在 GDrive 快速入门 iOS 页面 ( https://developers.google.com/drive/quickstart-ios )上看到了视频。我一步一步地跟着它,在我的 iPhone 应用程序中重试了几次,甚至还观看了视频。我正在尝试将 GDrive 集成到我现有的 iphone 应用程序中。
我导入了 GTMOAuth2ViewControllerTouch.h 和 GTLDrive.h 并将其添加到我的 .h 文件中:@property (nonatomic, strong) GTLServiceDrive *driveService;
在 .m 中:
// Helper to check if user is authorized
- (BOOL)isAuthorized
{
return [((GTMOAuth2Authentication *)self.driveService.authorizer) canAuthorize];
}
// Handle completion of the authorization process, and updates the Drive service
// with the new credentials.
- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController
finishedWithAuth:(GTMOAuth2Authentication *)authResult
error:(NSError *)error
{
if (error != nil)
{
NSLog(@"Authentication Error - %@", error.localizedDescription);
self.driveService.authorizer = nil;
}
else
{
self.driveService.authorizer = authResult;
}
}
-(void) uploadFile : (NSString *) appFile {
NSLog(@"uploadFile %@", appFile);
// Initialize the drive service & load existing credentials from the keychain if available
self.driveService = [[GTLServiceDrive alloc] init];
self.driveService.authorizer = [GTMOAuth2ViewControllerTouch
authForGoogleFromKeychainForName : kGDriveKeychainItem
clientID : kGDriveClientID
clientSecret : kGDriveClientSecret];
NSLog(@"auth done");
GTLDriveFile *file = [GTLDriveFile object];
file.title = fileStat;
file.descriptionProperty = @"App Info";
file.mimeType = @"text/plain";
NSData *data = [NSData dataWithContentsOfFile : appFile];
GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:file.mimeType];
GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:file
uploadParameters:uploadParameters];
NSLog(@"Uploading to GDrive");
[self.driveService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLDriveFile *insertedFile, NSError *error) {
if (error == nil)
{
NSLog(@"File ID: %@ ; GDrive file saved!", insertedFile.identifier);
}
else
{
NSLog(@"GDrive - An error occurred: %@", error);
}
}];
}
我收到错误
dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty_nonatomic_copy
Expected in: /usr/lib/libobjc.A.dylib
在“上传文件”行之后(它打印此行然后崩溃)。
有人可以帮忙吗?