gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:33:02 29 4
gpt4 key购买 nike

我正在开发 iOS 应用程序,该应用程序目前正在 Xcode 7 swift 2.3 上运行,并且它具有 cocoa pods 依赖项。我正在尝试从 swift 2 --> swift 4 迁移应用程序并同时更新 cocoa pod 。每次我尝试迁移应用程序时;我收到了很多错误消息。我进入 pod 文件并更新每个 pod 以支持 swift 4 no luck。任何人都可以帮助我逐步完成此迁移。

 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

最佳答案

你不需要一次更新所有的 cocoapods。我建议将它们保留在旧版本并先迁移您自己的代码。然后您仍然可以一次迁移一个 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

关于ios - 从 Swift 2.3 (xCode 7) 迁移 --> Swift 4(xCode 9) + 更新 Cocoapods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51698135/

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