Module compiled with swift 4.0 cannot be imported in swift 3.1

前端 未结 6 1434
轻奢々
轻奢々 2021-02-04 04:44

Apparently I have managed to build my project in Xcode 9 beta and now I only get the error

Module compiled with swift 4.0 cannot be imported in swift 3.1<

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 05:09

    Add following lines at the end of your pod file:

    post_install do |installer|
        print "Setting the default SWIFT_VERSION to 4.0\n"
        installer.pods_project.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '4.0'
        end
    
        installer.pods_project.targets.each do |target|
            if ['SomeTarget-iOS', 'SomeTarget-watchOS'].include? "#{target}"
                print "Setting #{target}'s SWIFT_VERSION to 3.0\n"
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '3.0'
                end
            else
                print "Setting #{target}'s SWIFT_VERSION to Undefined (Xcode will automatically resolve)\n"
                target.build_configurations.each do |config|
                    config.build_settings.delete('SWIFT_VERSION')
                end
            end
        end
    end
    

提交回复
热议问题