Comments (11)
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.
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.
You'll have to use the fully qualified name Result.Result<MyDataType, MyErrorType>
to avoid the ambiguity.
from result.
That seems logical, but Xcode doesn't interpret this correctly and is complaining.
Reference to generic type 'Result' requires arguments in <...>
from result.
This is a Swift bug:
from result.
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.
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.
That's a nifty workaround, thanks!
from result.
@kiliankoe @MrAlek
Is the bug of swift resolved? or still needs ResultResult?
from result.
Swift still has this bug.
from result.
thx
from result.
Related Issues (20)
- Support for higher order functions that can throw HOT 1
- Add Result to swift compatibility check HOT 1
- Replace `NoError` with `Never`? HOT 1
- Lower the `Error: Swift.Error` constraint on `Result` temporarily. HOT 4
- Why not declare 'Result' as 'Result<T>'? So it easy to deal with different types of errors. HOT 6
- [Disabled code coverage for xCode 9] HOT 1
- Unable to use the Result namespace HOT 3
- Using `init(attempt:)` always produces `Result` with `AnyError` type HOT 6
- Non-throwing dematerialize for result using NoError HOT 1
- Change (some) flatMap to compactMap? HOT 2
- 4.0 release HOT 1
- Adding a `fold` method HOT 5
- Result vs. Throws README section is out of date HOT 1
- Result initializer works in for loop but not map? HOT 1
- support required for swift 4.2 HOT 2
- How to pass an array of Swift.Errors as the right (Error) type? HOT 3
- Example os import usage for Swift 5/4 HOT 9
- Migration to Swift 4 HOT 1
- Cocoapods instructions still pin to v4 HOT 3
- Swift 5 support? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from result.