在Swift 4项目中使用Swift 5库

编程入门 行业动态 更新时间:2024-10-27 02:24:45
本文介绍了在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库

本文发布于:2023-11-26 17:37:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634532.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   Swift

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!