Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash Mapper initializer when running in a XCTestCase #1117

Open
ppamorim opened this issue Apr 10, 2021 · 2 comments
Open

Crash Mapper initializer when running in a XCTestCase #1117

ppamorim opened this issue Apr 10, 2021 · 2 comments

Comments

@ppamorim
Copy link

ppamorim commented Apr 10, 2021

Your JSON dictionary:

{
  "id": 123,
  "name": "Pedro"
}

Your model:

@objc
final class User: RealmSwift.Object, Mappable {

  var id: Int = -1
  var name: String = ""
  
  required convenience init?(map: Map) {
    self.init()
  }

  init(_ map: Map) {
    id <- map["id"]
    name <- map["name"]
  }
}

What you did:

let users = Mapper<User>().mapArray(JSONString: string)

What you expected:

I exepected something like:

[User]

What you got:

Screenshot 2021-04-10 at 01 23 43

The crash happens when the unit test calls Mapper<User>(), I tried to replace it with Mapper<User>(shouldIncludeNilValues: true) and tried to remove final from the class User but no success.

Xcode: 12.4
Cocoapods: 1.10.1 (It's not using use_frameworks! nor use_modular_headers!)
Swift: 5.3.2

@crownvic
Copy link

crownvic commented Jul 13, 2021

@ppamorim, have you solved this problem? I have the same issue when Mapper<Object> works anywhere except test classes.

@ppamorim
Copy link
Author

@crownvic Not yet, We cannot use the library anymore. We are migrating to Decodable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants