【问题标题】:PayPal integrated iOS 8 AppPayPal 集成 iOS 8 应用程序
【发布时间】:2014-12-07 11:45:48
【问题描述】:

我已经下载并使用了 paypal ios 应用程序的 github 项目。 https://github.com/paypal/PayPal-iOS-SDK 我运行得很好,没有任何错误。当我尝试将它链接到我的 iOS 8 swift 项目时,我可以加载所有文件并连接视图控制器就好了,我相信我的桥头文件工作得很好。我基本上将示例应用程序中的所有视图控制器文件移动到我的项目中,并连接了我需要的东西。我相信我有客户 ID 和秘密 ID 工作。当我尝试创建一个 FuturePaymentViewController 时:

 - (IBAction)getUserAuthorizationForFuturePayments:(id)sender {

       NSLog(@"\n\n\nbegin getting user authorization\n\n\nPAYPAL CONFIG::::   %@", self.payPalConfig);
       PayPalFuturePaymentViewController *futurePaymentViewController = [[PayPalFuturePaymentViewController alloc] initWithConfiguration:self.payPalConfig delegate:self];

       //breaks here when trying to send the config init.


        NSLog(@"\n\n\nafter initializtion of paypal future payment view controller\n\n\n");

        [self presentViewController:futurePaymentViewController animated:YES completion:nil];
        NSLog(@"after present");
 }

我得到的错误是:

 PAYPAL CONFIG::::   <PayPalConfiguration: 0x7fb23e212af0>


 2014-10-12 16:31:38.979 Project[2161:69146] -[PayPalFuturePaymentViewController       payPalServiceManager]: unrecognized selector sent to instance 0x7fb23e2207d0
 2014-10-12 16:31:38.981 Project[2161:69146] *** Terminating app due to uncaught exception     'NSInvalidArgumentException', reason: '-[PayPalFuturePaymentViewController payPalServiceManager]:      unrecognized selector sent to instance 0x7fb23e2207d0'
 *** First throw call stack:
(
0   CoreFoundation                      0x00000001055bf3f5 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000105258bb7 objc_exception_throw + 45
2   CoreFoundation                      0x00000001055c650d -[NSObject(NSObject)     doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x000000010551e7fc ___forwarding___ + 988
4   CoreFoundation                      0x000000010551e398 _CF_forwarding_prep_0 + 120
5   CutInLineSwift                      0x000000010262c0b1 -[PayPalFuturePaymentViewController initWithConfiguration:delegate:] + 361
6   CutInLineSwift                      0x00000001025d28de -[ZZMainViewController getUserAuthorizationForFuturePayments:] + 190
7   UIKit                               0x00000001029639ee -[UIApplication sendAction:to:from:forEvent:] + 75
8   UIKit                               0x0000000102a69bd0 -[UIControl _sendActionsForEvents:withEvent:] + 467
9   UIKit                               0x0000000102a68f9f -[UIControl touchesEnded:withEvent:] + 522
10  UIKit                               0x00000001029a93b8 -[UIWindow _sendTouchesForEvent:] + 735
11  UIKit                               0x00000001029a9ce3 -[UIWindow sendEvent:] + 683
12  UIKit                               0x0000000102976ae1 -[UIApplication sendEvent:] + 246
13  UIKit                               0x0000000102983bad _UIApplicationHandleEventFromQueueEvent + 17370
14  UIKit                               0x000000010295f233 _UIApplicationHandleEventQueue + 1961
15  CoreFoundation                      0x00000001054f4ad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
16  CoreFoundation                      0x00000001054ea99d __CFRunLoopDoSources0 + 269
17  CoreFoundation                      0x00000001054e9fd4 __CFRunLoopRun + 868
18  CoreFoundation                      0x00000001054e9a06 CFRunLoopRunSpecific + 470
19  GraphicsServices                    0x00000001071eb9f0 GSEventRunModal + 161
20  UIKit                               0x0000000102962550 UIApplicationMain + 1282
21  CutInLineSwift                      0x00000001025d093e top_level_code + 78
22  CutInLineSwift                      0x00000001025d097a main + 42
23  libdyld.dylib                       0x0000000105f93145 start + 1
 )
  libc++abi.dylib: terminating with uncaught exception of type NSException

这不应该是破坏,因为与示例项目没有什么不同,但我不知道为什么会这样。请帮帮我,谢谢!

【问题讨论】:

  • 似乎没有链接某些内容或没有导入标题。

标签: ios objective-c paypal


【解决方案1】:

这里是来自 PayPal 的戴夫。

相信您的问题会通过我们integration instructions的第3步解决:

在您项目的构建设置(在TARGETS 部分,而不是PROJECTS 部分):

  • 将-lc++ -ObjC 添加到Other Linker Flags

另外,请注意我们的示例代码中的Step 1,这表明您必须先调用[PayPalMobile initializeWithClientIdsForEnvironments:] 来初始化SDK,然后才能调用其他方法。

【讨论】:

  • 我已经为添加 -lc++ 的目标完成了第 3 步。当我在我的应用程序委托中的 Swift 中使用此方法时,我在哪里调用该方法。 PayPalMobile.initializeWithClientIdsForEnvironments([PayPalEnvironmentProduction: "XXXXXXXX", PayPalEnvironmentSandbox: "XXXXXXXXX"])
  • 实际上,您的问题是缺少-ObjC。 (虽然添加-lc++ 也很重要。)对于initializeWithClientIdsForEnvironments: 方法,您的应用程序委托确实是调用它的正确位置。
  • YES YES 谢谢你是-ObjC!!谢谢!
  • 补充一点,这确实解决了我的问题,但事实证明 FacebookSDK/ParseSDK 和 Paypal 移动 SDK 中存在冲突的实例或文件并导致问题。
  • @JMStudios.jrichardson 您能否更具体地说明这些冲突是什么?
猜你喜欢
  • 2015-05-26
  • 2013-12-12
  • 2012-09-19
  • 2021-01-28
  • 2016-12-06
  • 2014-09-22
  • 2011-06-30
  • 2014-03-04
  • 2013-09-09
相关资源
最近更新 更多