PEPhotoCropEditor icon indicating copy to clipboard operation
PEPhotoCropEditor copied to clipboard

nil URL argument

Open ctoto93 opened this issue 9 years ago • 5 comments

I got this exception, after returning from imagepicker and present crop controller. Below is my code

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
    let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage
    let controller = PECropViewController()
    controller.delegate = self
    controller.image = selectedImage

    let width = selectedImage!.size.width
    let height = selectedImage!.size.height
    let length = min(width,height)
    controller.imageCropRect = CGRectMake((width - length) / 2,
        (height - length) / 2,
        length,
        length)

    picker.dismissViewControllerAnimated(true, completion: nil)
    let navController = UINavigationController(rootViewController: controller)
    self.presentViewController(navController, animated: true, completion: nil)

}

ctoto93 avatar Nov 16 '15 04:11 ctoto93

I got this error by some CocoaPods lib. The reason is the path of Pod lib bundle is changed with option use_framework!. We have to use static pod lib to avoid this error. In additional, to support framework build, the pod lib should use [NSBundle bundleForClass:] instead of [NSBundle mainBundle] (here is in PECropViewController.m)

duongpq-rs avatar Nov 25 '15 12:11 duongpq-rs

Having the same issue as well.

mrchristopher124 avatar Mar 09 '16 12:03 mrchristopher124

@kishikawakatsumi Please merge gdunkle's commit. As you probably are aware, libs cannot access main bundle when using dynamic frameworks (just returns nil), which has been adopted standard (use_framework!) for cocoapods since iOS 8.

klivin avatar Jul 29 '16 19:07 klivin

Hi, is there any new version with this fix?

miguelpenades avatar Nov 29 '16 10:11 miguelpenades

Find this fine in resources : PECropViewController.m

Replace below line:

NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"PEPhotoCropEditor" withExtension:@"bundle"]; bundle = [[NSBundle alloc] initWithURL:bundleURL];

With:

NSString *Path=[[NSBundle mainBundle]pathForResource:@"PEPhotoCropEditor" ofType:@"bundle"];

bundle=[[NSBundle alloc]initWithPath:Path];

dipesh1604 avatar Jan 24 '18 11:01 dipesh1604