在Swift 4项目中使用Swift 5库 [英] Using Swift 5 Libraries in a Swift 4 Project

查看:68
本文介绍了在Swift 4项目中使用Swift 5库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在当前项目中使用的是Swift 4版本.但是,Cocoapods库的Swift版本是5.

I am using Swift 4 version in my current project. However, the Swift version of Cocoapods library is 5.

我无法降级该库,因为该库的最新版本具有我想要的功能.此外,立即提高项目版本有很多困难.

I can't downgrade the library because the latest version of the library has the features I want. In addition, there are a lot of difficulties in raising the version of the project immediately.

在安装库的最新版本后,我正在尝试修改库中的代码.但是工作量很重.有什么好办法吗?救救我.

I'm trying to modify the code in a library after installing the latest version of the library. But the workload is very heavy. Is there a good way?? Help me..

推荐答案

尝试在podfile上手动设置pod swift版本:

Try setting the pod swift version manually on the podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
      if ['INSERT POD NAME HERE'].include? target.name
          target.build_configurations.each do |config|
              config.build_settings['SWIFT_VERSION'] = '4.0'
          end
      end
  end
end

如果从pod收到语法错误,则表示该语言不兼容.不幸的是,xCode不太喜欢向后兼容性.

If you get a syntax error from the pod, it means that the language is not compatible. Unfortunately xCode don't like backward compatibility very much.

然后,唯一的解决方案是升级项目(也许 swift迁移助手可能会有所帮助)或降级lib,就像您现在所做的那样.

Then, the only solution would be upgrade the project (maybe the swift migration assistant could help) or downgrade the lib, as you are doing right now.

这篇关于在Swift 4项目中使用Swift 5库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆