Swift使用pod导入的三方指定swift版本

目前最新swift是4.1,但是pod导入的三方可能是3.3版本,此时使用pod导入三方可在podfile里配置以下内容

# Swift 版本声明

post_install do |installer|

    installer.pods_project.targets.each do |target|

        if ['对应三方1', '对应三方2'].include? target.name

            target.build_configurations.each do |config|

                config.build_settings['SWIFT_VERSION'] = '3.3'

                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

            end

            else

            target.build_configurations.each do |config|

                config.build_settings['SWIFT_VERSION'] = '4.1'

                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

            end

        end

    end

end

整个podfile为

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

use_frameworks!

inhibit_all_warnings!

target 'FoxBuy' do

  ## 此处是三方库

  ## ...

end

# Swift 版本声明

post_install do |installer|

    installer.pods_project.targets.each do |target|

        if ['对应三方1', '对应三方2'].include? target.name

            target.build_configurations.each do |config|

                config.build_settings['SWIFT_VERSION'] = '3.3'

                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

            end

            else

            target.build_configurations.each do |config|

                config.build_settings['SWIFT_VERSION'] = '4.1'

                config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

            end

        end

    end

end

platform:ios,'9.0'

#source 'http://github.com/CocoaPods/Specs.git'

inhibit_all_warnings!

use_frameworks!

target 'SwiftBaseExample' do

#布局

pod 'SnapKit'

#image

pod 'Kingfisher'

pod 'Alamofire', '~> 4.9.0'

#pod 'YYKit'

pod 'SDWebImage'

#tabbar样式

pod 'ESTabBarController-swift', '~> 2.7'

#banner滚动图片

pod 'FSPagerView', '~> 0.8.3'

#解析

pod 'Moya'

pod 'HandyJSON', '~> 4.2.0'

pod 'SwiftyJSON'

# 分页

pod 'DNSPageView', '~> 1.2.0'

#跑马灯

pod 'JXMarqueeView'

#滚动页

pod 'LTScrollView', '~> 0.2.1'

#页面刷新

pod 'MJRefresh'

#pod 'SkeletonView'

#消息提示

pod 'SwiftMessages'

pod 'SVProgressHUD'

#播放网络音频

pod 'StreamingKit'

#

pod 'SlideMenuController'

#统计

pod 'UMengAnalytics-NO-IDFA'

#

pod 'CHIPageControl', '~> 0.2'

#

pod 'Charts', '~> 3.3.0'

#键盘

pod 'IQKeyboardManagerSwift', '~> 6.4.2'

#

#

#

pod 'Starscream', '3.0.6'

    swift4 = ['LTScrollView', 'SlideMenuController']

    post_install do |installer|

        installer.pods_project.targets.each do |target|

            target.build_configurations.each do |config|

                if swift4.include?(target.name)

                    config.build_settings['SWIFT_VERSION'] = '4.0'

                end

            end

        end

    end

end

发布了15 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/sundaysme/article/details/100782057