Muhammed Muhammed -4 years ago 141
iOS Question

Application crash when i run it in a real device iOS

I am developing an application when using networking with Alamofire on Xcode 8.3 and when i used Alamofire code in the simulator it's working but when i tried my code in a real device iPhone 7 which has 10.2 iOS Version the application stop and getting

fatal error: unexpectedly found nil while unwrapping an Optional value

and this break point exception

libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x101b003d0 <+0>: stp x26, x25, [sp, #-0x50]!
0x101b003d4 <+4>: stp x24, x23, [sp, #0x10]
0x101b003d8 <+8>: stp x22, x21, [sp, #0x20]
0x101b003dc <+12>: stp x20, x19, [sp, #0x30]
0x101b003e0 <+16>: stp x29, x30, [sp, #0x40]
0x101b003e4 <+20>: add x29, sp, #0x40 ; =0x40
0x101b003e8 <+24>: mov x19, x6
0x101b003ec <+28>: mov x20, x5
0x101b003f0 <+32>: mov x21, x4
0x101b003f4 <+36>: mov x22, x3
0x101b003f8 <+40>: mov x23, x2
0x101b003fc <+44>: mov x24, x1
0x101b00400 <+48>: mov x25, x0
0x101b00404 <+52>: adr x8, #0xf11fc ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
0x101b00408 <+56>: nop
0x101b0040c <+60>: add x0, x8, #0x10 ; =0x10
0x101b00410 <+64>: mov w1, #0x28
0x101b00414 <+68>: orr w2, wzr, #0x7
0x101b00418 <+72>: bl 0x101b00750 ; swift_rt_swift_allocObject
0x101b0041c <+76>: mov x8, x0
0x101b00420 <+80>: stp x22, x21, [x8, #0x10]
0x101b00424 <+84>: strb w20, [x8, #0x20]
0x101b00428 <+88>: str w19, [x8, #0x24]
0x101b0042c <+92>: adr x3, #0x40440 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x101b00430 <+96>: nop
0x101b00434 <+100>: mov x0, x25
0x101b00438 <+104>: mov x1, x24
0x101b0043c <+108>: mov x2, x23
0x101b00440 <+112>: mov x4, x8
0x101b00444 <+116>: bl 0x1019e14dc ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x101b00448 <+120>: brk #0x1

and this is my code which i run

Alamofire.request(APIKeys().login, method: .post, parameters: ["email" : email , "password" : password ], encoding: JSONEncoding.default , headers: APIKeys().headers).responseJSON(completionHandler: {( response ) in
if response.result.value != nil {
let json = JSON(response.result.value ?? "")
if json["status"].intValue == 200
UserDefaults().set(json["email"].stringValue, forKey: "email")
UserDefaults().set(json["id"].intValue, forKey: "userID")



} )

Answer Source

Just Cleaned the cache and reinstalled the app and it's working well at the device

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download