Using Swift 5 Libraries in a Swift 4 Project

本小妞迷上赌 提交于 2021-01-29 13:09:30

问题


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..


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/57551244/using-swift-5-libraries-in-a-swift-4-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!