swift2 从Swift 2.3(xCode 7)迁移-->Swift 4(xCode 9)+更新Cocoapod

0md85ypi  于 2022-11-06  发布在  Swift
关注(0)|答案(1)|浏览(207)

我正在开发iOS应用程序,该应用程序目前运行在Xcode 7 swift 2.3上,它有可可pod依赖项。我尝试将应用程序从swift 2 --〉swift 4迁移,并将cocoa pod更新为while。每次我尝试迁移应用程序;我收到了这么多的错误信息。我进入了pod文件,并更新了每个pod,以支持swift 4没有运气。有人能帮助我一步一步地完成这个迁移吗?

platform :ios, '9.2'
 use_frameworks!
 pod 'Parse'
 pod 'ParseUI'
 pod 'FBSDKCoreKit'
 pod 'FBSDKLoginKit'
 pod 'FBSDKShareKit'
 pod 'ParseFacebookUtilsV4'
 pod 'GoogleMaps', '~> 1.10.1'
 pod 'Alamofire', '~> 3.2.1'
 pod 'SwiftyJSON', '~> 2.3.0'
 pod 'Onboard'
 pod 'SWRevealViewController'
 pod 'XLForm', '~> 3.1.1'

post_install do |installer|

swift3Targets = [
'Parse'
'ParseUI'
'FBSDKCoreKit'
'FBSDKLoginKit'
'FBSDKShareKit'
'ParseFacebookUtilsV4'
'GoogleMaps'
'Alamofire'
'SwiftyJSON'
'Onboard'
'SWRevealViewController'
'XLForm'
]
   installer.pods_project.targets.each do |target|
   if swift3Targets.include? target.name
   target.build_configurations.each do |config|
   config.build_settings['SWIFT_VERSION'] = '3.0'
   end
  end
  end

   # Workaround for Cocoapods issue #7606
    installer.pods_project.build_configurations.each do |config|
    config.build_settings.delete('CODE_SIGNING_ALLOWED')
   config.build_settings.delete('CODE_SIGNING_REQUIRED')
   end

    installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
    if config.name == 'Debug'
    config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-   Onone']
   config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
end

端端端端

Will my pod file look like this? I migrated my code from swift 2.3 --> swift 3
093gszye

093gszye1#

你不需要一次更新所有的cocoapod。我建议保持它们的旧版本,只需要先移植你自己的代码。然后你仍然可以一次移植一个pod。我们仍然在Swift 3上做同样的事情,因为不是所有的pod都支持Swift的新版本:
在Pod文件的末尾,我们添加了如下内容:

post_install do |installer|

 swift3Targets = [
    'Sugar',
    'SQLite.swift',
    'SwiftyJSON',
    'Walker',
 ]

 installer.pods_project.targets.each do |target|
    if swift3Targets.include? target.name
       target.build_configurations.each do |config|
       config.build_settings['SWIFT_VERSION'] = '3.2'
    end
  end
end

# Workaround for Cocoapods issue #7606

installer.pods_project.build_configurations.each do |config|
  config.build_settings.delete('CODE_SIGNING_ALLOWED')
    config.build_settings.delete('CODE_SIGNING_REQUIRED')
end

installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    if config.name == 'Debug'
      config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-Onone']
      config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
    end
  end
end
end

希望这会对你有帮助!也检查此链接out

相关问题