Swift iOS -UIImagePicker's Photo Library Is Presented On Simulator But Crashes (won't present) On Actual Device While Running Xcode -


i'm on swift 3, ios 10.3, , xcode 8.3.3.

when access photo library on simulator uiimagepicker presented no problem , can pick photos. as try access photo library on actual device (iphone 7+) app crashes because uiimagepicker won't presented (i don't point pick photo). odd thing on actual device imagepicker presents camera , can take photos no problem.

even though didn't add inside question, inside actual code have api permissions running. inside actual code used them , commented them out , problem still occurs:

import avfoundation  //there way more code put these here show i'm using them phphotolibrary.authorizationstatus() phphotolibrary.requestauthorization() avcapturedevice.authorizationstatus(formediatype: ...) avcapturedevice.requestaccess(formediatype: ...) 

update: still haven't resolved issue have found out more information. kept playing around app , tried app again after crash , let me access library. came realize app let me access library on phone long xcode isn't running. plug phone xcode , try access library again crash. don't know make of that.

as long xcode isn't hooked device can obtain photos libary. simulator have no problems obtaining photos. device not hooked xcode can obtain photos. once device , xcode connected crash. i've tried initializing uiimagepicker 3 different ways (as stated below) see if either of them change outcome it's same. app on 100 classes , 50 vcs, maybe problem happening somewhere else. if happening somewhere else should crash when xcode isn't hooked device either.

inside classes use uiimagepicker commented out unnecessary code , focused on library , camera buttons. crash happens once device , xcode intertwined. thing once not connected can access library users won't have problem because they'll never have xcode running app.

it should noted when device , xcode hooked can use camera , take pics. problem seems regulated library.

i've seen question asked several times answer

"the permissions inside info.plist have set"

in situation permissions set inside info.plist:

info.plist

source files

here pic of switch set "on" inside simulator's settings page. couldn't take photo of actual device's setting's page on there both camera , photos switches set "on"

permissions

my code:

mycontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate{   fileprivate var imagepicker = uiimagepickercontroller()  override func viewdidload() {         super.viewdidload()          imagepicker.delegate = self }  @ibaction fileprivate func librarybutton(_ sender: uibutton){          self.imagepicker.sourcetype = uiimagepickercontrollersourcetype.photolibrary         self.imagepicker.allowsediting = false         presentviewcontroller(self.imagepicker, animated: true, completion: nil)  }  @ibaction fileprivate func camerabutton(_ sender: uibutton){          self.imagepicker.sourcetype = uiimagepickercontrollersourcetype.camera         self.imagepicker.allowsediting = false         present(self.imagepicker, animated: true, completion: nil)  }  func imagepickercontroller(_ picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : any]) {          if let myimage = info[uiimagepickercontrolleroriginalimage] as? uiimage{             imageview.image = myimage         }         else if let myimage = info[uiimagepickercontrollereditedimage] as? uiimage{             imageview.image = myimage         }         else{"uiimagepicker problem")         }          imagepicker.dismiss(animated: true, completion: nil)     }  func imagepickercontrollerdidcancel(_ picker: uiimagepickercontroller) {     imagepicker.dismiss(animated: true, completion: nil) } } } 

i tried:

fileprivate var imagepicker:uiimagepickercontroller?  @ibaction fileprivate func librarybutton(_ sender: uibutton){          self.imagepicker = uiimagepickercontroller()         self.imagepicker?.delegate = self         self.imagepicker?.sourcetype = uiimagepickercontrollersourcetype.photolibrary         self.imagepicker?.allowsediting = false         present(self.imagepicker!, animated: true, completion: nil)  }  @ibaction fileprivate func camerabutton(_ sender: uibutton){          self.imagepicker = uiimagepickercontroller()         self.imagepicker?.delegate = self         self.imagepicker?.sourcetype = uiimagepickercontrollersourcetype.camera         self.imagepicker?.allowsediting = false         present(self.imagepicker!, animated: true, completion: nil)  } 

i tried:

fileprivate let imagepicker:uiimagepickercontroller?  override func viewdidload() {         super.viewdidload()          imagepicker = uiimagepickercontroller()         imagepicker!.delegate = self }   @ibaction fileprivate func librarybutton(_ sender: uibutton){          imagepicker!.sourcetype = uiimagepickercontrollersourcetype.photolibrary         imagepicker!.allowsediting = false         present(imagepicker!, animated: true, completion: nil)  }  @ibaction fileprivate func camerabutton(_ sender: uibutton){          imagepicker!.sourcetype = uiimagepickercontrollersourcetype.camera         imagepicker!.allowsediting = false         present(imagepicker!, animated: true, completion: nil)  } 

this same crash info keep getting once device , xcode hooked up:

libc++abi.dylib`__cxa_throw: ->  0x18fd96e70 <+0>:   stp    x22, x21, [sp, #-0x30]!     0x18fd96e74 <+4>:   stp    x20, x19, [sp, #0x10]     0x18fd96e78 <+8>:   stp    x29, x30, [sp, #0x20]     0x18fd96e7c <+12>:  add    x29, sp, #0x20            ; =0x20      0x18fd96e80 <+16>:  mov    x19, x2     0x18fd96e84 <+20>:  mov    x20, x1     0x18fd96e88 <+24>:  mov    x21, x0     0x18fd96e8c <+28>:  bl     0x18fd96a88               ; __cxa_get_globals     0x18fd96e90 <+32>:  mov    x22, x0     0x18fd96e94 <+36>:  bl     0x18fd9756c               ; std::get_unexpected()     0x18fd96e98 <+40>:  stur   x0, [x21, #-0x60]     0x18fd96e9c <+44>:  bl     0x18fd975ac               ; std::get_terminate()     0x18fd96ea0 <+48>:  stur   x0, [x21, #-0x58]     0x18fd96ea4 <+52>:  stp    x20, x19, [x21, #-0x70]     0x18fd96ea8 <+56>:  mov    x8, #0x434c000000000000     0x18fd96eac <+60>:  movk   x8, #0x4e47, lsl #32     0x18fd96eb0 <+64>:  movk   x8, #0x432b, lsl #16     0x18fd96eb4 <+68>:  movk   x8, #0x2b00     0x18fd96eb8 <+72>:  mov    x19, x21     0x18fd96ebc <+76>:  str    x8, [x19, #-0x20]!     0x18fd96ec0 <+80>:  orr    w8, wzr, #0x1     0x18fd96ec4 <+84>:  stur   x8, [x19, #-0x58]     0x18fd96ec8 <+88>:  ldr    w8, [x22, #0x8]     0x18fd96ecc <+92>:  add    w8, w8, #0x1              ; =0x1      0x18fd96ed0 <+96>:  str    w8, [x22, #0x8]     0x18fd96ed4 <+100>: adrp   x8, 0     0x18fd96ed8 <+104>: add    x8, x8, #0xef8            ; =0xef8      0x18fd96edc <+108>: str    x8, [x19, #0x8]     0x18fd96ee0 <+112>: mov    x0, x19     0x18fd96ee4 <+116>: bl     0x190433be4               ; _unwind_raiseexception     0x18fd96ee8 <+120>: mov    x0, x19     0x18fd96eec <+124>: bl     0x18fd96f20               ; __cxa_begin_catch     0x18fd96ef0 <+128>: ldur   x0, [x21, #-0x58]     0x18fd96ef4 <+132>: bl     0x18fd975c4               ; std::__terminate(void (*)()) 

i don't have unwind segue anywhere in project i'm unsure of why says that. regardless if works on simulator should work on phone or if doesn't work on phone shouldn't work on simulator either. below here snippet of crash report , stack trace.

bug report:

enter image description here

enter image description here

enter image description here

i deleted app device, shut down xcode, relaunched it, accepted ok give access library, , same problem.

any idea of problem is?

ash furrow helped me out non obvious problem , possibly api bug. posted pics people unfamiliar process resolve it.

it turns out inside breakpoint navigator had all exceptions activated. reason when app hooked xcode , uiimagepicker presenting photo library, exceptions breakpoint triggered , there slight delay caused app crash. delay milliseconds long enough app thought there problem. ash said never saw before , said there possibly corrupted jpg photo in photo library again wild guess. simple solution deactivate or delete exceptions breakpoint , problem resolved. did possibly api problem because still causing odd crash.

it should noted said exceptions break point keep activated because find exceptions earlier later. forgot explanation in detail it's best keep on , if run problem deactivate it.

steps resolve uiimagepicker library presentation crash deactivating exceptions breakpoint:

  1. on left side of screen in navigation pane, 7th icon left looks arrow breakpoint navigator

breakpoint navigator

  1. the exceptions breakpoint activated/highlighted blue all exception activated

  2. to deactivate exceptions either click highlighted blue arrow or right click on word all exceptions , list either choose disable or delete

options deselect exception breakpoint

  1. assuming either choose disable or click blue arrow, deactivated

all exception deactivated

  1. obviously if choose delete erased form breakpoint navigator if want add again (or if never had begin with) still have inside breakpoint navigator (step 1) , in lower left corner of pane press plus button , choose exception breakpoint add it.

plust button in @ bottom of pane on left side

enter image description here


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -