CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler


目前Swift的穩定版本是5.4

https://docs.swift.org/swift-book/index.html

XCode新建項目的build-setting中Swift Language Version 設置為 Swift5

近期在項目開發中使用到了swift,在本地可以正常編譯運行項目,但是在jenkins打包的時候拋出如下錯誤。

分析總結這個問題,避免后面的同學被同一個問題困擾。

 

參考XCode更新文檔

https://developer.apple.com/xcode/whats-new/

發現從XCode12以后才開始引入Swift5.3及以上版本

 

Swift5.3更新部分

  • Added information about multiple trailing closures to the Trailing Closures section, and added information about how trailing closures are matched to parameters to the Function Call Expression section.

 

         what's problem ?

         The following build commands failed:

             CompileSwift normal armv7 xxx.swift

             CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler

             CompileSwift normal arm64 xxx.swift

         

         why problem ?

         xxx.swift:24:10: error: consecutive statements on a line must be separated by ';'

                 } completion: { _ in

                  ^

                  ;

         xxx.swift:24:21: error: expected expression

                 } completion: { _ in

                             ^

         xxx.swift:24:11: error: use of unresolved identifier 'completion'

                 } completion: { _ in

                   ^~~~~~~~~~

         xxx.swift:24:23: error: unable to infer closure type in the current context

                 } completion: { _ in

                               ^~~~~~

         xxx.swift:24:23: error: closure expression is unused

                 } completion: { _ in

         

         How fix ?

         // xcode12 and above

         UIView.animate(withDuration: 0.3) {

             // animation actions

         } completion: { _ in

             // some finished actions

         }

 

         // below xcode12

         UIView.animate(withDuration: 0.3, animations: {

             // animation actions

         }, completion: { _ in

             // some finished actions

         })

         

         不同版本XCode編譯器在編譯swift文件,做語法檢查的時候,檢測到該語法不支持。爆出這樣的錯誤


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM