【问题标题】:sqlite.swift tons of errors after installationsqlite.swift 安装后出现大量错误
【发布时间】:2018-04-19 02:29:22
【问题描述】:

我的第一个问题,yoroshiku。

将 SQLite.swift (0.11.5) 作为子项目或通过 cocoapods 手动安装到我的项目时,安装成功。但是 Xcode (9.3) 在一些 SQLite.swift 文件中给了我一堆错误。

我之前已经成功安装到三个项目。这些项目今天仍然有效。但突然之间,我无法在任何新项目上安装 SQlite.swift。

我得到的错误是......

  • “Dictionary.Keys”类型的值没有成员 'compactMap'

  • “[Expressible?]”类型的值没有成员“compactMap”

  • 无法将“Self.IndexDistance”类型的值转换为预期值 参数类型'Int'

  • 调用中的参数 #2 缺少参数

以上错误出现在 16 个不同的位置。如有必要,我可以提供有关此问题的更具体信息,但在我看来,问题更有可能出现在设置或安装过程中。

我要做的是以下

我遵循https://github.com/stephencelis/SQLite.swift 上的官方指南,但我也观看并阅读了我在这里和那里找到的教程。

  • 创建一个全新的单视图应用程序。
  • 我退出 Xcode
  • 然后在终端中

...

Computer:Desktop user$ cd SQLtest6

Computer:SQLtest6 user$ sudo gem install cocoapods

Password:
Successfully installed cocoapods-1.5.0

Parsing documentation for cocoapods-1.5.0

Done installing documentation for cocoapods after 4 seconds

1 gem installed

...

Computer:SQLtest6 user$ pod init

Computer:SQLtest6 user$ nano Podfile

Computer:SQLtest6 user$ cat Podfile 

 # Uncomment the next line to define a global platform for your project

platform :ios, '11.0' #also tried commenting this out

target 'SQLtest6' do

  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks

  use_frameworks!

  # Pods for SQLtest6

pod 'SQLite.swift', '~> 0.11.5'

end

...

Computer:SQLtest6 user$ pod install --repo-update

Updating local specs repositories

  $ /usr/bin/git -C /Users/user/.cocoapods/repos/master fetch origin
  --progress

  remote: Counting objects: 18, done.        

  remote: Compressing objects: 100% (16/16), done.        

  remote: Total 18 (delta 10), reused 0 (delta 0), pack-reused 0        

  From https://github.com/CocoaPods/Specs

     ab34143d0fd..18642c110f8  master     -> origin/master

  $ /usr/bin/git -C /Users/user/.cocoapods/repos/master rev-parse
  --abbrev-ref HEAD

  master

  $ /usr/bin/git -C /Users/user/.cocoapods/repos/master reset --hard
  origin/master

  HEAD is now at 18642c110f8 [Add] XyiLotterySDK 1.0.0

Analyzing dependencies

Downloading dependencies

Installing SQLite.swift (0.11.5)

Generating Pods project

Integrating client project

[!] Please close any current Xcode sessions and use `SQLtest6.xcworkspace` for this project from now on.

Sending stats

Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

然后我通过双击新的白色图标 .xcworkspace 打开项目。在第一次构建之前一切正常,然后出现所有错误。

在项目设置常规选项卡下,我有: 嵌入式二进制文件:无 链接的框架和二进制文件:Pods_SQLTest6.framework(必需)

我尝试将项目设置与工作项目进行比较,但似乎找不到任何不同之处。

我在新旧项目上尝试了几次。我还尝试了手动方式,方法是从 GitHub 下载 zip,将项目拖到项目导航器中,并根据上面链接的官方文档中的指南添加框架和二进制文件。

对不起,如果它含糊不清。我已经扫描了三天,试图找到类似的东西。没有运气。

有人知道吗?

【问题讨论】:

    标签: swift xcode cocoapods sqlite.swift


    【解决方案1】:

    您要导入的项目尚不兼容 Swift 4.1 中引入的最新更改。即一个明显的是将 flatMap 更改为 compactMap。

    参考:

    检查他们是否有 Swift 4.1 分支。 (更新:我检查过,他们没有)

    另一种选择是使用可能更兼容的旧 Swift 版本构建您的项目。您可以在构建设置中执行此操作,将 Swift 语言版本更改为您想要的版本。 4.0 可能会工作,它似乎没有任何重大的重大变化。

    编辑

    抱歉,我弄错了。项目has 更新到 Swift 4.1。

    之前的非 Swift 4.1 版本是 0.11.4,因此如果您在 PodFile 中指定此版本,它将解决您的问题,直到您将项目更新到 Swift 4.1。

    // install specific version of pod
    pod 'SQLite.swift', '0.11.4'
    

    【讨论】:

    • 非常感谢!这很有意义。但是我的 Xcode 中甚至没有 Swift 4.1。它设置为 4.0。我也可以选择3.2。但是 4.0 已经工作了几个月(直到两天前)。
    • 啊,我明白了,我弄错了。请参阅更新的答案。我知道编译错误与 Swift 4.1 相关。通常库的更新速度不会那么快。
    • 就是这样!非常感谢!
    猜你喜欢
    • 2020-08-16
    • 2018-01-01
    • 2014-12-07
    • 2014-12-14
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多