tristanhimmelman/AlamofireObjectMapper

Can't Build with Xcode 10.2

devny opened this issue ยท 23 comments

devny commented

Hi. I have updated xcode to version 10.2, and then I get Build Failed Task failed with exit code 65.

Hi, also facing Xcode 10.2 compilation issue "Ambiguous use of 'mapArray(JSONObject:)" on AlamofireObjectMapper.swift line 167.

This code resolves issue on line 167
/// ImmutableMappable Array Serializer

  public static func ObjectMapperImmutableSerializer<T: ImmutableMappable>(_ keyPath: String?, context: MapContext? = nil) -> DataResponseSerializer<T> {
       return DataResponseSerializer { request, response, data, error in
           if let error = checkResponseForError(request: request, response: response, data: data, error: error){
               return .failure(error)
           }
           
           if let currentJSONObject = processResponse(request: request, response: response, data: data, keyPath: keyPath) {
               let mapper = Mapper<T>(context: context, shouldIncludeNilValues: false)
               do {
                   let parsedObject = try mapper.map(JSONObject: currentJSONObject)
                   // if parsedObject != nil { // if let parsedObject = parsedObject {
                   return .success(parsedObject)
               } catch {}
           }
           
           let failureReason = "ObjectMapper failed to serialize response."
           let error = newError(.dataSerializationFailed, failureReason: failureReason)
           return .failure(error)
       }
   }

So adding do/catch resolves this which is available also in earlier Swift versions, means we do not need another branch here. Please check and add this fix.

Same kind of issue in the public static func ObjectMapperImmutableArraySerializer<T: ImmutableMappable>(_ keyPath: String?, context: MapContext? = nil) -> DataResponseSerializer<[T]>

This is the new version which is compilable with Xcode 10.2 and Swift 5.
Could not test this yet, but the changes should be OK.

AlamofireObjectMapper.swift.zip

Waiting for your replies. Thanks.

I've fixed the issue by branching from 5.2.0 tag and running carthage update to update Alamofire from 4.7.3 to 4.8.2 (it is 4.8.0 moved to swift4) and ObjectMapper from 3.4.1 to 3.4.2:

openium@b933e78

Here are the commands to test with this version:

mkdir /tmp/alamobjectmapper-carthage-swift5/ && cd /tmp/alamobjectmapper-carthage-swift5/
echo 'github "openium/AlamofireObjectMapper" "b933e7816faa0c76a8d227b4e4c3323ab3cf6e9f"' >Cartfile
carthage update

@tristanhimmelman can a 5.3.0 or 5.2.1 be released with these updates ?

Having the same issue. Will go back to Xcode 10.1 until this gets resolved (and subscribing to this thread)...

I have XCode 10.2 with Alamofire 5.0.0-beta.4 & AlamofireObjectMapper 6.0.0 it compiles with 4 similar errors in responseObject methods which says:
Value of optional type 'DispatchQueue?' must be unwrapped to a value of type 'DispatchQueue'
screenshot:
Screen Shot 2019-04-04 at 9 24 00 AM

Drusy commented

@tristanhimmelman Could you branch from tag 5.2.0 so we can pull request on this branch and think of a 5.2.1 ?
The master is currently not usable as it's based on AlamofireObjectMapper 6.0 and Alamofire 5.
The fix is ready and just needs a branch to be hosted!

55533907-71d26e00-56bb-11e9-8814-8432aebbbaa0

I also have this question

I have created a new release 5.2.1 as requested. Let me know if there are any issues

https://github.com/tristanhimmelman/AlamofireObjectMapper/releases/tag/5.2.1

Drusy commented

Just worked with Xcode 10.2.1, thank you ๐Ÿ‘

@tristanhimmelman I am not getting 5.2.1 available on Cocoapods.

Not able to install 5.2.1 version

[!] CocoaPods could not find compatible versions for pod "AlamofireObjectMapper":
In Podfile:
AlamofireObjectMapper (~> 5.2.1)

None of your spec sources contain a spec satisfying the dependency: AlamofireObjectMapper (~> 5.2.1).

You have either:

  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

That's because it was not released on cocoapods, if you check the branch you can see that the podspec was not updated.

ps : i tried to build our lib directly using the branch with the fix, can confirm pod spec lint will fail with xcode 10.2 and AlamofireObjectMapper as a dependency, got the same issue as tbechtum

For anyone interested you can pull my fork in the meantime (i am also waiting for a release).
Version 6.0.1 is swift 5 ready and removing the build issues that appear only during a pod lib lint.
You can get it from here : https://github.com/tirrorex/Podspecs or here https://github.com/tirrorex/AlamofireObjectMapper

Just add this to your podfile :

source 'https://github.com/tirrorex/Podspecs.git'
source 'https://github.com/CocoaPods/Specs.git'

and specify the version either in your podfile or your podspec (6.0.1)

Hi, there isn't version 5.2.1 on Cocoapods repo, did you plan to release it?

This is the new version which is compilable with Xcode 10.2 and Swift 5.
Could not test this yet, but the changes should be OK.

AlamofireObjectMapper.swift.zip

This worked for me, thanks for the fix!

I am trying to build using Xcode 11.3 and Swift 5, getting the same error: Ambiguous use of 'map(JSONObject:)'. Is there a fix for this, or everyone is already moving to the latest Alamofire version?

I am trying to build using Xcode 11.3 and Swift 5, getting the same error: Ambiguous use of 'map(JSONObject:)'. Is there a fix for this, or everyone is already moving to the latest Alamofire version?

Seeing the same problem with a project I'm trying to get up and running with. @o15a3d4l11s2 Were you able to find a solution that worked for you?

For what its worth we have this in our Podfile.lock

- Alamofire (4.9.0)
- AlamofireObjectMapper (5.2.1):
  - Alamofire (~> 4.7)
  - ObjectMapper (~> 3.4)

@IsaiahByDayah, unfortunately not. I am still using Swift 4 for it.

Do you use GRDB? Them remove this statement: import GRDB