Coder Social home page Coder Social logo

Comments (11)

kgaidis avatar kgaidis commented on August 20, 2024 77

Wanted to reference this workaround for people who have problems in the future:
Alamofire/Alamofire#1271 (comment)

import enum Result.Result
import Alamofire

from result.

kgaidis avatar kgaidis commented on August 20, 2024 3

To note, the above solution import enum Result.Result for some reason fails when trying to build for Release. Swift compiler had an error: no such "decl" in module

The ResultResult doesn't seem to be the most flexible either, got error in a protocol:
Cannot specialize non-generic type JsonResult (aka 'Result<String, NSError>')

While it might be a Swift bug, the pain is pretty real.

I'll get my workarounds, but it isn't too intuitive for anyone who is relatively new to Swift (and/or iOS). It be nice for this issue to be open, or at least clearly documented. Alamofire is one of the most popular libraries so the chance of encountering this problem is relatively high.

from result.

neilpa avatar neilpa commented on August 20, 2024

You'll have to use the fully qualified name Result.Result<MyDataType, MyErrorType> to avoid the ambiguity.

from result.

kiliankoe avatar kiliankoe commented on August 20, 2024

That seems logical, but Xcode doesn't interpret this correctly and is complaining.

Reference to generic type 'Result' requires arguments in <...>

from result.

robrix avatar robrix commented on August 20, 2024

This is a Swift bug:

from result.

kiliankoe avatar kiliankoe commented on August 20, 2024

Ah, thank you. I'll be duping that then :)

I guess this issue can be closed if it'll hopefully be resolving itself soon?

from result.

MrAlek avatar MrAlek commented on August 20, 2024

I ran into the same issue. Until the radars are fixed, a work-around is to make your own struct with a type-alias in a separate file.

// ResultResult.swift
import Foundation
import Result

// TO-DO: As soon as https://github.com/antitypical/Result/issues/77 is resolved, this file should be removed
struct ResultResult<T, Error : ErrorType> {
    typealias t = Result<T, Error>
}
// API.swift
import Foundation
import Alamofire

typealias StringResult = ResultResult<String, NSError>.t

Works like a charm!

from result.

kiliankoe avatar kiliankoe commented on August 20, 2024

That's a nifty workaround, thanks!

from result.

hiragram avatar hiragram commented on August 20, 2024

@kiliankoe @MrAlek
Is the bug of swift resolved? or still needs ResultResult?

from result.

robrix avatar robrix commented on August 20, 2024

Swift still has this bug.

from result.

hiragram avatar hiragram commented on August 20, 2024

thx

from result.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.