2013-09-29 2 views
1


YouTube SDK를 내 iOS 앱에 통합하려면이 예제 https://code.google.com/p/google-api-objectivec-client/source/browse/#svn/trunk/Examples/YouTubeSample을 따르고 있습니다.
내가 한 일은 다음과 같습니다.
- 내 프로젝트에 GTL.project를 추가하고 헤더 검색 경로의 소스 경로를 설정하십시오.
- GTLTouchStaticLib을 프로젝트의 라이브러리와 이진 링크로 연결하십시오.
- 내 프로젝트에 GTLYouTube_Sources.m을 추가하십시오. -
YouTubeSample에서 일부 코드를 복사, 여기에 코드입니다 : 내가 페이지에서 동의를 클릭하면
iOS 앱과 Youtube 통합 - 예기치 않은 오류

빌드 후
#import "ViewController.h" 

#import "GTLYouTube.h" 

#import "GTLUtilities.h" 
#import "GTMHTTPUploadFetcher.h" 
#import "GTMHTTPFetcherLogging.h" 
#import "GTMOAuth2ViewControllerTouch.h" 
. 
. 
- (IBAction)Login:(id)sender { 

    GTMOAuth2ViewControllerTouch *viewController; 
    viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeYouTube 
                   clientID:kMyClientID 
                  clientSecret:kMyClientSecret 
                 keychainItemName:kKeychainItemName 
                   delegate:self 
                 finishedSelector:@selector(viewController:finishedWithAuth:error:)]; 

    [self presentViewController:viewController animated:YES completion:NULL]; 
} 

- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController 
     finishedWithAuth:(GTMOAuth2Authentication *)auth 
       error:(NSError *)error { 
    if (error == nil) { 
     self.youTubeService.authorizer = auth; 
//  [self dismissViewControllerAnimated:YES completion:NULL]; 
     [self fetchMyChannelList]; 
    } else { 
     NSLog(@"Auth failed: %@", error); 
    } 
} 

- (void)fetchMyChannelList { 
    NSLog(@"fetchMyChannelList"); 
    _myPlaylists = nil; 
    _channelListFetchError = nil; 

    GTLServiceYouTube *service = self.youTubeService; 

    GTLQueryYouTube *query = [GTLQueryYouTube queryForChannelsListWithPart:@"contentDetails"]; 

    query.mine = YES; 

    // maxResults specifies the number of results per page. Since we earlier 
    // specified shouldFetchNextPages=YES, all results should be fetched, 
    // though specifying a larger maxResults will reduce the number of fetches 
    // needed to retrieve all pages. 
    query.maxResults = 50; 

    // We can specify the fields we want here to reduce the network 
    // bandwidth and memory needed for the fetched collection. 
    // 
    // For example, leave query.fields as nil during development. 
    // When ready to test and optimize your app, specify just the fields needed. 
    // For example, this sample app might use 
    // 
    // query.fields = @"kind,etag,items(id,etag,kind,contentDetails)"; 

    _channelListTicket = [service executeQuery:query 
          completionHandler:^(GTLServiceTicket *ticket, 
               GTLYouTubeChannelListResponse *channelList, 
               NSError *error) { 
           // Callback 

           // The contentDetails of the response has the playlists available for 
           // "my channel". 
           if ([[channelList items] count] > 0) { 
            GTLYouTubeChannel *channel = channelList[0]; 
            _myPlaylists = channel.contentDetails.relatedPlaylists; 
            NSLog(@"_myPlaylists: %@", _myPlaylists); 
           } 
           _channelListFetchError = error; 
           _channelListTicket = nil; 

           if (_myPlaylists) { 
            [self fetchSelectedPlaylist]; 
           } 

           [self fetchVideoCategories]; 
          }]; 

} 

실행, 나는 내 유튜브 계정으로 로그인, 응용 프로그램 충돌, 여기 쿼리의 내 인적 또는 가치를 설정할 때 오류가 발생합니다 오류 출력은 : 인증 성공하지만, fetchMyChannelList 실패처럼

 
2013-09-30 04:12:47.618 YoutubeAPITest[4153:a0b] popView 
2013-09-30 04:12:48.684 YoutubeAPITest[4153:a0b] fetchMyChannelList 
2013-09-30 04:12:48.685 YoutubeAPITest[4153:a0b] GTLRuntimeCommon: unexpected attributes TB,D for property mine 
2013-09-30 04:12:48.685 YoutubeAPITest[4153:a0b] GTLRuntimeCommon: unexpected return type class for property "mine" of class "GTLQueryYouTube" 
2013-09-30 04:12:48.686 YoutubeAPITest[4153:a0b] -[GTLQueryYouTube setMine:]: unrecognized selector sent to instance 0x1090c13e0 
2013-09-30 04:12:48.689 YoutubeAPITest[4153:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTLQueryYouTube setMine:]: unrecognized selector sent to instance 0x1090c13e0' 
*** First throw call stack: 
(
    0 CoreFoundation      0x0000000101a7c795 __exceptionPreprocess + 165 
    1 libobjc.A.dylib      0x00000001017df991 objc_exception_throw + 43 
    2 CoreFoundation      0x0000000101b0dbad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 
    3 CoreFoundation      0x0000000101a6e09d ___forwarding___ + 973 
    4 CoreFoundation      0x0000000101a6dc48 _CF_forwarding_prep_0 + 120 
    5 YoutubeAPITest      0x0000000100001ae2 -[ViewController fetchMyChannelList] + 258 
    6 YoutubeAPITest      0x000000010000197a -[ViewController viewController:finishedWithAuth:error:] + 218 
    7 CoreFoundation      0x0000000101a7222c __invoking___ + 140 
    8 CoreFoundation      0x0000000101a720d4 -[NSInvocation invoke] + 308 
    9 YoutubeAPITest      0x000000010001474d -[GTMOAuth2ViewControllerTouch signIn:finishedWithAuth:error:] + 701 
    10 CoreFoundation      0x0000000101a7222c __invoking___ + 140 
    11 CoreFoundation      0x0000000101a720d4 -[NSInvocation invoke] + 308 
    12 YoutubeAPITest      0x00000001000113cf -[GTMOAuth2SignIn invokeFinalCallbackWithError:] + 415 
    13 YoutubeAPITest      0x000000010001121e -[GTMOAuth2SignIn finishSignInWithError:] + 62 
    14 YoutubeAPITest      0x0000000100010daa -[GTMOAuth2SignIn fetchGoogleUserInfo] + 506 
    15 YoutubeAPITest      0x000000010001096b -[GTMOAuth2SignIn auth:finishedWithFetcher:error:] + 251 
    16 CoreFoundation      0x0000000101a7222c __invoking___ + 140 
    17 CoreFoundation      0x0000000101a720d4 -[NSInvocation invoke] + 308 
    18 YoutubeAPITest      0x000000010000df43 +[GTMOAuth2Authentication invokeDelegate:selector:object:object:object:] + 355 
    19 YoutubeAPITest      0x000000010000c856 -[GTMOAuth2Authentication tokenFetcher:finishedWithData:error:] + 1334 
    20 CoreFoundation      0x0000000101a7222c __invoking___ + 140 
    21 CoreFoundation      0x0000000101a720d4 -[NSInvocation invoke] + 308 
    22 YoutubeAPITest      0x000000010001add8 -[GTMHTTPFetcher invokeFetchCallback:target:data:error:] + 344 
    23 YoutubeAPITest      0x000000010001ac4c -[GTMHTTPFetcher invokeFetchCallbacksWithData:error:] + 204 
    24 YoutubeAPITest      0x000000010001c165 -[GTMHTTPFetcher connectionDidFinishLoading:] + 1333 
    25 Foundation       0x00000001014d103b __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 48 
    26 Foundation       0x000000010138476b -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 210 
    27 Foundation       0x000000010138467c -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 69 
    28 CFNetwork       0x00000001068c88b7 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107 
    29 CFNetwork       0x00000001068c6a82 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 84 
    30 CFNetwork       0x000000010690a024 ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke + 25 
    31 CoreFoundation      0x0000000101a230b4 CFArrayApplyFunction + 68 
    32 CFNetwork       0x0000000106839d7b _ZN19RunloopBlockContext7performEv + 115 
    33 CFNetwork       0x0000000106839bc1 _ZN17MultiplexerSource7performEv + 247 
    34 CFNetwork       0x00000001068399e4 _ZN17MultiplexerSource8_performEPv + 72 
    35 CoreFoundation      0x0000000101a0be61 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 
    36 CoreFoundation      0x0000000101a0b732 __CFRunLoopDoSources0 + 242 
    37 CoreFoundation      0x0000000101a275bf __CFRunLoopRun + 767 
    38 CoreFoundation      0x0000000101a26ed3 CFRunLoopRunSpecific + 467 
    39 GraphicsServices     0x0000000103b1d3a4 GSEventRunModal + 161 
    40 UIKit        0x0000000100447a63 UIApplicationMain + 1010 
    41 YoutubeAPITest      0x0000000100008c13 main + 115 
    42 libdyld.dylib      0x00000001020ef7e1 start + 0 
    43 ???         0x0000000000000001 0x0 + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

보인다. 모든 단계를 다시 확인했지만 잘못된 것이 무엇인지 파악할 수 없으므로 도와주세요.

답변

2

Google 캘린더 API를 사용하여 동일한 문제가 발생했습니다.

GTLRuntimeCommon : 당신이 다음이 원인 일 수 있습니다 코코아 포드에있는 구글-API-클라이언트를 사용하는 경우 예기치은

속성 singleEvents에 대한 TB, D 속성. 나는 코코아포드가 약간 구형이고 64 비트 아이폰에 대한 쿼리에서 불리언을 설정할 때 충돌이 일어나는 것을 발견했다. 출처는 여기 https://code.google.com/p/google-api-objectivec-client/에서 발견되었으며 수정 패치가 적용되었습니다. 경우 여기 호기심에서

그것이 내가 클라이언트 ID와 비밀 및 검색 API를 호출 할 때 인증 오류 1001 로깅을 만든

+0

https://code.google.com/p/google-api-objectivec-client/source/detail?r=364 패치 된 곳 커밋이다. 로그인하고 인증 키를 가져와야 튜브 검색 API가 필수입니까? – iGo