kishikawakatsumi / PEPhotoCropEditor

Image cropping library for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nil URL argument

ctoto93 opened this issue · 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)

}

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)

Having the same issue as well.

@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.

Hi, is there any new version with this fix?

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