【问题标题】:Cleanse build failed on xcode 9在 xcode 9 上清理构建失败
【发布时间】:2017-10-26 11:59:21
【问题描述】:

我尝试使用 Cleanse 依赖注入器在 xcode 9 快速版本 3.2 上构建我的旧代码,但 static func configure<B: Binder>(binder: Binder) 函数出现以下错误:

对泛型“Binder”的引用需要 <...>

中的参数

我尝试了所有的分支和提交。你有什么推荐的?

【问题讨论】:

    标签: ios swift xcode9 cleanse


    【解决方案1】:

    语法好像变了

    func configure<B : Binder>(binder binder: B) {
           // Will fill out contents later
       }
    

    https://github.com/square/Cleanse

    【讨论】:

    • 在 Cleanse 的文档中,我发现这个函数被称为“func configure(binder binder: B)”是你想要实现的吗?
    • 是的。它与早期的 xcode 完美配合
    • 这是一个微小的差异,但它可能会改变一切
    • 谢谢,我觉得改的比较多,在这个文件里可以查到。它正在使用以下语法:[github.com/square/Cleanse/blob/master/… 文档可能已过时,我将向他们发送 PR。如果您编辑答案,我会将其标记为正确答案,谢谢您的帮助
    【解决方案2】:

    正确的语法如下:

    struct Singleton : Scope {
    }
    
    static func configure(binder: Binder<Singleton>) {
         // Will fill out contents later
    }
    

    您可以在此处查看示例: https://github.com/square/Cleanse/blob/master/CleansePlayground.playground/Pages/CoffeeMakerExample.xcplaygroundpage/Contents.swift

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-11
      • 2019-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多