gpt4 book ai didi

swift - 在 Swift 4 项目中使用 Swift 5 库

转载 作者:行者123 更新时间:2023-11-30 10:37:47 25 4
gpt4 key购买 nike

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

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

我正在尝试在安装最新版本的库后修改库中的代码。但工作量却非常大。有什么好的办法吗??帮帮我..

最佳答案

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

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 不太喜欢向后兼容。

然后,唯一的解决方案是升级项目(也许 swift migration assistant 可以提供帮助)或降级库,就像您现在所做的那样。

关于swift - 在 Swift 4 项目中使用 Swift 5 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57551244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com