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 ?