Flutter:无法在 codemagic 上为 ios 构建

Posted

技术标签:

【中文标题】Flutter:无法在 codemagic 上为 ios 构建【英文标题】:Flutter: Can't build for ios on codemagic 【发布时间】:2021-06-07 07:37:56 【问题描述】:

我正在尝试在 codemagic 上为我的颤振项目创建一个 ios 版本,但它一直失败。我在应用程序中使用了flutter_config,但我的.env 文件中的值已添加到codemagic 上的环境变量中,但我仍然认为失败的构建与flutter_config 有关,但可能还有更多。这是我的日志,任何帮助都会很棒。

== Building for iOS ==


Running Xcode build...                                          

Xcode archive done.                                         19.1s

Failed to build iOS app
Error output from Xcode build:
↳
    ** ARCHIVE FAILED **


Xcode's output:
↳
    Command CompileSwift failed with a nonzero exit code
    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:107:111: error: using '!' is not allowed here; perhaps '?' was intended?
            typealias Function = (_ data: UnsafeRawPointer, _ len: CC_LONG, _ md: UnsafeMutablePointer<UInt8>) -> UnsafeMutablePointer<UInt8>!
                                                                                                                  ^                          ~
                                                                                                                                             ?
    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:188:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func MD2() -> Self 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:198:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func MD4() -> Self 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:208:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func MD5() -> Self 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:217:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func SHA1() -> Self 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:226:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func SHA224() -> Self 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:235:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func SHA256() -> Self 
        ^~~~~~~

 /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:628:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func encrypt(_ algorithm: Cipher.Algorithm, options: Cipher.Options, key: Data, iv: Data? = nil) throws -> Data 
        ^~~~~~~

    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:646:5: warning: 'public' modifier is redundant for instance method declared in a public extension
        public func decrypt(_ algorithm: Cipher.Algorithm, options: Cipher.Options, key: Data, iv: Data? = nil) throws -> Data 
        ^~~~~~~

                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:272:69: note: implicit argument conversion from '[UInt8]' to 'UnsafePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
            return type(of: self).init(Data(bytes: UnsafePointer<UInt8>(messageDigest), count: messageDigest.count))
                                                                        ^~~~~~~~~~~~~
    /Users/builder/clone/ios/Pods/SCrypto/Source/SCrypto.swift:272:69: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
            return type(of: self).init(Data(bytes: UnsafePointer<UInt8>(messageDigest), count: messageDigest.count))
   
                                                    ^
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/BuildDotenvConfig.rb' of type 'text.script.ruby' for architecture 'arm64' (in target 'flutter_config' from project 'Pods')
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/BuildXCConfig.rb' of type 'text.script.ruby' for architecture 'arm64' (in target 'flutter_config' from project 'Pods')
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/ReadDotEnv.rb' of type 'text.script.ruby' for architecture 'arm64' (in target 'flutter_config' from project 'Pods')
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/BuildDotenvConfig.rb' of type 'text.script.ruby' for architecture 'armv7' (in target 'flutter_config' from project 'Pods')
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/BuildXCConfig.rb' of type 'text.script.ruby' for architecture 'armv7' (in target 'flutter_config' from project 'Pods')
    warning: no rule to process file '/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_config-1.0.8/ios/Classes/ReadDotEnv.rb' of type 'text.script.ruby' for architecture 'armv7' (in target 'flutter_config' from project 'Pods')
Encountered error while archiveing for device.




Build failed :|
Failed to build for iOS

【问题讨论】:

【参考方案1】:

根据错误消息,我建议检查下一个解决方案https://github.com/dart-lang/crypto/issues/85#issuecomment-584256548

【讨论】:

嗨 @Mikhail 我无法在 codemagic 上设置 swift 版本,或者我可以吗? 是的,您可以使用 VNC 访问和更改 Xcode 设置。检查blog.codemagic.io/remote-access-to-virtual-mac-build-machine 我将我的 swift 版本更改为 4.2,但仍然出现相同的错误。 您是否已将更改推送到 repo?你能用最新的日志更新问题吗? 在 xcode 上更改 swift 版本是否会以任何方式影响我的代码库?我认为它所做的只是改变了 xcode 在下一次构建期间编译我的代码的方式,那么为什么需要推送呢?

以上是关于Flutter:无法在 codemagic 上为 ios 构建的主要内容,如果未能解决你的问题,请参考以下文章

Flutter - Codemagic - 自定义方案的 iOS 代码签名问题

Flutter iOS 的 Codemagic 版本控制

Codemagic IOS 构建 - 无法构建 iOS 应用程序 - 是啥原因?

Flutter / FCM 通知未到达 Codemagic iOS 版本

使用 Codemagic 将 Flutter Windows 应用程序发布到 Microsoft 合作伙伴中心

使用 Codemagic 编译 IOS 失败