在RELEASE ONLY SWIFT 4.2中使用RxSwift,Moya和Alamofire的特定API响应导致应用程序崩溃

时间:2019-05-16 18:29:19

标签: ios swift alamofire rx-swift moya

我的应用程序发生奇怪的崩溃,仅在一个请求的RELEASE构建配置中发生。

关于我的项目的一些信息,最后是豆荚和东西

这不起作用

所以基本上我正在调用一个GET API,该API发送回以下json响应:

{"minAge":25,"maxAge":35,"minHeight":130,"maxHeight":220,"minWeight":35,"maxWeight":200,"cigarette":{"id":3,"value":"Peut fumer régulièrement"},"educationLevel":{"id":0},"searchRadius":50,"childrenQuantity":{"id":8,"value":"Ca n'a pas d'importance"},"location":{"id":0,"type":"Point","coordinates":[5.394581538212958,43.32484360763759]},"searchZone":{"type":"Polygon","coordinates":[[[4.776465440894579,42.87518351047025],[6.012697635531339,42.87518351047025],[6.012697635531339,43.77450370480493],[4.776465440894579,43.77450370480493],[4.776465440894579,42.87518351047025]]]},"id":"1"}

然后映射到该对象模型(忽略模型中不存在的json中的元素):

struct UserSearchCriteriaEntity: Mappable, Codable {

    let id: String?
    var minAge: Int?
    var maxAge: Int?
    var minHeight: Int?
    var maxHeight: Int?
    var minWeight: Int?
    var maxWeight: Int?
    var cigarette: GenericElementEntity?
    var educationLevel: GenericElementEntity?
    var searchRadius: Int?
    var childrenQuantity: GenericElementEntity?
    var location: LocationEntity?

    init(map: Mapper) throws {
        id = map.optionalFrom("id")
        minAge = map.optionalFrom("minAge")
        maxAge = map.optionalFrom("maxAge")
        minHeight = map.optionalFrom("minHeight")
        maxHeight = map.optionalFrom("maxHeight")
        minWeight = map.optionalFrom("minWeight")
        maxWeight = map.optionalFrom("maxWeight")
        cigarette = map.optionalFrom("cigarette")
        educationLevel = map.optionalFrom("educationLevel")
        searchRadius = map.optionalFrom("searchRadius")
        childrenQuantity = map.optionalFrom("childrenQuantity")
        location = map.optionalFrom("location")
    }
}

,并且收到该响应后,该应用就会崩溃(请参见下面的屏幕截图):

enter image description here

我已经搜索了所有内容,但没有找到崩溃的任何解释。

在早期版本的swift和pod中运行正常

这有效

响应,模型或映射应该没有问题,因为我将同一对象作为一部分或更大的User对象返回,并且不会崩溃(请参见下面的代码和响应):

struct UserEntity: Mappable, Codable {

    // ...other stuff

    var searchCriteria: UserSearchCriteriaEntity?

    // ...other stuff

    init(map: Mapper) throws {
        // ...other stuff mapping

        searchCriteria = map.optionalFrom("_searchCriteria")

        // ...other stuff mapping
    }
}

是从包含以下内容的json映射的:

{..., "_searchCriteria" : {"minAge":25,"maxAge":35,"minHeight":130,"maxHeight":220,"minWeight":35,"maxWeight":200,"cigarette":{"id":3,"value":"Peut fumer régulièrement"},"educationLevel":{"id":0},"searchRadius":50,"childrenQuantity":{"id":8,"value":"Ca n'a pas d'importance"},"location":{"id":0,"type":"Point","coordinates":[5.394581538212958,43.32484360763759]},"searchZone":{"type":"Polygon","coordinates":[[[4.776465440894579,42.87518351047025],[6.012697635531339,42.87518351047025],[6.012697635531339,43.77450370480493],[4.776465440894579,43.77450370480493],[4.776465440894579,42.87518351047025]]]},"id":"1"}, ...}

项目信息

    Swift 4.2    
    Xcode 10.2.1 (10E1001)

    **PODS**
  - Alamofire (4.8.2)
  - ModelMapper (10.0.0):
    - ModelMapper/Core (= 10.0.0)
  - ModelMapper/Core (10.0.0)
  - Moya (13.0.1):
    - Moya/Core (= 13.0.1)
  - Moya-ModelMapper/Core (9.0.0):
    - ModelMapper (~> 10.0)
    - Moya (~> 13.0)
  - Moya-ModelMapper/ReactiveSwift (9.0.0):
    - Moya-ModelMapper/Core
    - Moya/ReactiveSwift (~> 13.0)
    - ReactiveSwift
  - Moya-ModelMapper/RxSwift (9.0.0):
    - Moya-ModelMapper/Core
    - Moya/RxSwift (~> 13.0)
    - RxSwift
  - Moya/Core (13.0.1):
    - Alamofire (~> 4.1)
    - Result (~> 4.1)
  - Moya/ReactiveSwift (13.0.1):
    - Moya/Core
    - ReactiveSwift (~> 5.0)
  - Moya/RxSwift (13.0.1):
    - Moya/Core
    - RxSwift (~> 4.0)
  - RxSwift (4.5.0)

0 个答案:

没有答案