【问题标题】:CocoaPods pods crashesCocoaPods pod 崩溃
【发布时间】:2014-03-26 19:58:39
【问题描述】:

我有一个使用 CocoaPods 的项目,它很棒,直到我开始遇到一些问题。

我正在为 UIActionSheetUIAlertView 使用一个带有块的 pod,这些块通过类别扩展了这些类。

我将 pod 添加到 .podsfile 并将标题导入到我的项目中。当我将代码添加到项目中时,Xcode 并没有抱怨什么,我什至在自动完成建议中看到了类别方法。

但是,当我运行该应用程序时,它总是在执行类别方法时崩溃,说“无法识别的选择器发送到(UIActionSheetUIAlertView)”。

我已将这些类直接添加到我的项目中,效果很好,所以我认为这是 CocoaPods 的问题。

这里以代码为例:

 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        RIButtonItem *selectPhotoButton = [RIButtonItem itemWithLabel:NSLocalizedString(@"Choose from library",nil) action:^{
            [self selectPhoto];
        }];
        RIButtonItem *takePhotoButton = [RIButtonItem itemWithLabel:NSLocalizedString(@"Take a photo",nil) action:^{
            [self takePhoto];
        }];
        UIActionSheet *ac = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Image source",nil) cancelButtonItem:[RIButtonItem itemWithLabel:NSLocalizedString(@"Cancel",nil)] destructiveButtonItem:nil otherButtonItems:takePhotoButton,selectPhotoButton, nil];
        [ac showInView:self.view];
    }
    else
    {
        [self selectPhoto];
    }

应用程序在 initWithTitle:cancelButtonItem:destructiveButtonItem:otherButtonItems 上崩溃

这是我的 Podsfile

pod 'MBProgressHUD'
pod 'Facebook-iOS-SDK'
pod 'UIAlertView-Blocks'

有什么想法吗?

【问题讨论】:

  • 您可以发布您的Podfile 和一些导致您的应用程序崩溃的示例代码吗?
  • 添加示例,谢谢
  • 好吧,我觉得不错。您是否在编辑完 podfile 后运行了 pod install 并且正在使用 .xcworkspace 文件?
  • 还要确保您使用#import <UIAlertView-Blocks/UIActionSheet+Blocks.h>导入
  • 正如我所说 - Xcode 识别方法并且 eve 建议自动完成。谢谢

标签: ios cocoapods


【解决方案1】:

我在这里找到了答案 - linking objective-c categories in a static library

我在其他链接器标志中缺少 -ObjC 标志,这是实现类别的静态库所必需的。

还是谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-17
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 2020-10-09
    相关资源
    最近更新 更多