Can I use Swift 2.3 frameworks in a Swift 3 projec

2019-04-09 01:29发布

In my project I migrated all my private swift 2.3 files to swift 3. I would like to use my legacy frameworks written in swift 2.3 until they have a swift 3 version.

I tried to add "Use Legacy Swift Version = Yes". Clear/Build my project but I have still some trouble and xCode ask me to migrate my frameworks to swift 3 (which is just not possible because they are libraries)....

How can I continue to use my 2.3 libraries?

2条回答
够拽才男人
2楼-- · 2019-04-09 01:59

You cay try using this:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '2.3'
    end
  end
end

Note that this will set all of your targets to swift 2.3. If you want one specific, you can do something like that:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.pod_name == 'DesiredPod'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '2.3'
      end
    end
  end
end
查看更多
干净又极端
3楼-- · 2019-04-09 02:04

You can set Build Settings->Swift Compiler - Version-> Use Legacy Swift Language Version for Yesenter image description here

查看更多
登录 后发表回答