问题
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