0

I have a project with CocoaPods and it was great, until I started having some problems.

I am using a pod for UIActionSheet and UIAlertView with blocks which extends those classes with category.

I added the pods to the .podsfile and imported the headers to my project. When I add the code to the project Xcode does not complain about nothing and I even see the category methods in the autocompletion suggestions.

But, when I run the app, it always crashes on the category method execution saying that "unrecognized selector sent to (UIActionSheet or UIAlertView)".

I have added the classes directly to my project and it works great so I think this is CocoaPods problem.

Here as an example of code:

 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];
    }

The app crashes on initWithTitle:cancelButtonItem:destructiveButtonItem:otherButtonItems

And this is my Podsfile

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

Any Idea ?

shannoga
  • 19,649
  • 20
  • 104
  • 169
  • Can you post your `Podfile` and some example code that is crashing your app? – squarefrog Mar 27 '14 at 11:41
  • OK that looks fine to me. Did you run `pod install` after editing your podfile and are you using the `.xcworkspace` file? – squarefrog Mar 27 '14 at 18:33
  • Also ensure you import using `#import ` – squarefrog Mar 27 '14 at 18:37
  • As I said - Xcode recognises the methods and eve suggests auto completion. Thanks – shannoga Mar 27 '14 at 20:21
  • Well I created a new project and used your code along with that import statement and it works fine. So there has to be something else. I also used this pod in a project at work yesterday and it works fine. Why not show your import statement? Also you might want to confirm which build of Xcode and iOS you are using. – squarefrog Mar 27 '14 at 21:09

1 Answers1

0

Well I found the answer here - linking objective-c categories in a static library

I was missing the -ObjC flag in other linker flags which was required for static libraries that implements categories.

Thanks anyway

Community
  • 1
  • 1
shannoga
  • 19,649
  • 20
  • 104
  • 169