首页 > 解决方案 > iOS 12.4.1 发布在苹果商店拒绝 ipad 设备时崩溃

问题描述

你好我是IOS swift的新手,

我的应用在 iPhone/iPad 模拟器上运行良好,但是,我从苹果应用商店收到了应用拒绝消息。

我相信崩溃的原因是调用 api,因为根据拒绝消息,他们试图使用电子邮件和密码登录,一旦他们点击提交按钮,应用程序就会崩溃,应用程序在提交按钮点击时我们称之为登录 api。

苹果的崩溃报告

{"app_name":"gogetGONE","timestamp":"2019-09-24 13:37:46.50 -07
    00","app_version":"6.0","slice_uuid":"5958bf7b-689e-306b-8b81-0ad61cdb32b2","adam_id":1466582359,"build_version":"1","bundleID":"com.gogetgone.gogetgonepro","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 12.4.1 (16G102)","incident_id":"D1DE09EF-3CC3-47C8-A03B-49108C8B3BFC","name":"gogetGONE"}
    Incident Identifier: D1DE09EF-3CC3-47C8-A03B-49108C8B3BFC
    CrashReporter Key:   c201dc074338fd6214efc8c4bfbbe19377d79d89
    Hardware Model:      xxx
    Process:             gogetGONE [4259]
    Path:                /private/var/containers/Bundle/Application/E7D0CB5E-929F-43F5-AEA9-400B122CD35E/gogetGONE.app/gogetGONE
    Identifier:          com.gogetgone.gogetgonepro
    Version:             1 (6.0)
    AppStoreTools:       11A1002b
    Code Type:           ARM-64 (Native)
    Role:                Non UI
    Parent Process:      launchd [1]
    Coalition:           com.gogetgone.gogetgonepro [1698]


    Date/Time:           2019-09-24 13:37:46.3466 -0700
    Launch Time:         2019-09-24 13:20:36.4938 -0700
    OS Version:          iPhone OS 12.4.1 (16G102)
    Report Version:      104

    Exception Type:  EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000001, 0x0000000102e50348
    Termination Signal: Trace/BPT trap: 5
    Termination Reason: Namespace SIGNAL, Code 0x5
    Terminating Process: exc handler [4259]
    Triggered by Thread:  0

    Thread 0 name:  Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:
    0   gogetGONE                       0x0000000102e50348 0x102df8000 + 361288
    1   gogetGONE                       0x0000000102e1c1f0 0x102df8000 + 147952
    2   Alamofire                       0x0000000102f4a920 0x102f1c000 + 190752
    3   Alamofire                       0x0000000102f2d074 0x102f1c000 + 69748
    4   libdispatch.dylib               0x0000000182983a38 0x182924000 + 391736
    5   libdispatch.dylib               0x00000001829847d4 0x182924000 + 395220
    6   libdispatch.dylib               0x0000000182932008 0x182924000 + 57352
    7   CoreFoundation                  0x0000000182ed732c 0x182e2d000 + 697132
    8   CoreFoundation                  0x0000000182ed2264 0x182e2d000 + 676452
    9   CoreFoundation                  0x0000000182ed17c0 0x182e2d000 + 673728
    10  GraphicsServices                0x00000001850d279c 0x1850c8000 + 42908
    11  UIKitCore                       0x00000001af5c4c38 0x1aed08000 + 9161784
    12  gogetGONE                       0x0000000102dff9f4 0x102df8000 + 31220
    13  libdyld.dylib                   0x00000001829958e0 0x182994000 + 6368

代码片段 info.Plist。

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

登录.swift

func save() {
    let parameters: Parameters = [
        "email": self.emailTextField.text!,
        "password": self.passwordTextField.text!,
    ]
    loginButton.isEnabled = false
    Alamofire.request(ApiRequest.API_URL+"/auth/login", method : .post,parameters:parameters).responseJSON { response in
        if((response.result.value) != nil) {
            let json = JSON( response.result.value!)
            print("JSON: \(json)") // serialized json response
            if(json["success"].boolValue){
                //TODO login login
                self.gotoHome()
            }
            else{
                self.showAlert(for: json["message"].stringValue)
            }
        }
    }

}

标签: iosswiftiphonealamofireappstore-approval

解决方案


Instead of localHost your info plist should contain DNS of your live server

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

As much as i undestand it can be nil response or Type casting is causing the issue so.

  • First of all replace

        if((response.result.value) != nil)
    

    to

    if let swiftyResponse=response, swiftyResponse.result.value !=nil { 
     guard let json = swiftyResponse.result.value else{return }}
    
  • further verify json["success"].boolValue actually returns bool values or success contains a string or Integer etc.

  • More check your self.gotoHome method i will suggest you to post it too in your code


推荐阅读