使用 Codemagic 在没有 Mac 的情况下构建 iOS

Posted

技术标签:

【中文标题】使用 Codemagic 在没有 Mac 的情况下构建 iOS【英文标题】:Building to iOS without Mac using Codemagic 【发布时间】:2020-04-20 18:30:18 【问题描述】:

我目前想将我的 Flutter 应用程序部署到 Apple 的 App Store,但不幸的是我没有 Mac,因为它对我来说非常昂贵。但是,我在这里找到了一种解决方法,并尝试使用 Codemagic 构建应用程序并将其部署到 AppStore。然而,在尝试在 Codemagic 中为 ios 构建时,我遇到了一个错误,它:

== Building for iOS ==


== /usr/local/bin/flutter build ios --debug --no-codesign ==

/Users/builder/clone/ios/Runner/Info.plist: Property List error: Found non-key inside <dict> at line 7 / JSON error: JSON text did not start with array or object and option to allow fragments not set.
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.example.syncshopWebview for device (ios)...

Running pod install...                                          
    4.8s

Running Xcode build...                                          

Xcode build done.                                           60.5s


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


Xcode's output:
↳
    /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.9+1/ios/Classes/FlutterWebviewPlugin.m:91:22: warning: incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'id _Nullable' [-Wint-conversion]
        _enableAppScheme = call.arguments[@"enableAppScheme"];
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.9+1/ios/Classes/FlutterWebviewPlugin.m:418:98: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]
        [channel invokeMethod:@"onHttpError" arguments:@@"code": [NSString stringWithFormat:@"%ld", error.code], @"url": url];
                                                                                               ~~~   ^~~~~~~~~~
                                                                                               %ld   (long)
    /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.9+1/ios/Classes/FlutterWebviewPlugin.m:426:98: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]
        [channel invokeMethod:@"onHttpError" arguments:@@"code": [NSString stringWithFormat:@"%ld", error.code], @"error": error.localizedDescription];
                                                                                               ~~~   ^~~~~~~~~~
                                                                                               %ld   (long)
    /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.9+1/ios/Classes/FlutterWebviewPlugin.m:434:106: warning: values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead [-Wformat]
                [channel invokeMethod:@"onHttpError" arguments:@@"code": [NSString stringWithFormat:@"%ld", response.statusCode], @"url": webView.URL.absoluteString];
                                                                                                       ~~~   ^~~~~~~~~~~~~~~~~~~
                                                                                                       %ld   (long)
    4 warnings generated.
    2020-01-01 17:20:28.170 ibtoold[1414:18701] DEBUG: Added to environment: 
        TMPDIR = "/var/folders/r7/d9twdq011sb8d3q1p8f39cdr0000gn/T/763735EC-50B9-405B-83C2-E28A2CD2AD2C";
    
    /* com.apple.actool.document.warnings */
    /Users/builder/clone/ios/Runner/Assets.xcassets:./AppIcon.appiconset: warning: A 76x76@1x app icon is required for iPad apps targeting iOS 7, 8, and 9
    /Users/builder/clone/ios/Runner/Assets.xcassets:./AppIcon.appiconset: warning: A 76x76@2x app icon is required for iPad apps targeting iOS 7.0 and later
    /Users/builder/clone/ios/Runner/Assets.xcassets:./AppIcon.appiconset: warning: A 83.5x83.5@2x app icon is required for iPad apps targeting iOS 9.0 and later
    /* com.apple.actool.document.notices */
    /Users/builder/clone/ios/Runner/Assets.xcassets:./AppIcon.appiconset/[][iphone][57x57][][][1x][][]: notice: 57x57 app icons only apply to iPhone apps targeting releases of iOS prior to 7.0
    /Users/builder/clone/ios/Runner/Assets.xcassets:./AppIcon.appiconset/[][iphone][57x57][][][2x][][]: notice: 57x57@2x app icons only apply to iPhone apps targeting releases of iOS prior to 7.0
    /* com.apple.actool.compilation-results */
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon20x20@2x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon20x20@3x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon29x29.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon29x29@2x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon29x29@3x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon40x40@2x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon40x40@3x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon57x57.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon57x57@2x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon60x60@2x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/AppIcon60x60@3x.png
    /Users/builder/clone/build/ios/Debug-iphoneos/Runner.app/Assets.car
    /Users/builder/Library/Developer/Xcode/DerivedData/Runner-edaimyiflreloheqntgnhkmwcclv/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/assetcatalog_generated_info.plist

    error: unable to read property list from file: /Users/builder/clone/ios/Runner/Info.plist: The operation couldn’t be completed. (XCBUtil.PropertyListConversionError error 1.) (in target 'Runner' from project 'Runner')
    note: Using new build system
    note: Planning build
    note: Constructing build description

════════════════════════════════════════════════════════════════════════════════
Building a deployable iOS app requires a selected Development Team with a 
Provisioning Profile. Please ensure that a Development Team is selected by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- In the 'General' tab, make sure a 'Development Team' is selected. 
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

For more information, please visit:
  https://flutter.dev/setup/#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
Encountered error while building for device.



Build failed :|
Failed to build for iOS

请多多包涵,因为我没有 Mac,所以我无法完全遵循有关将 Flutter 应用程序部署到 AppStore 的文档。

非常感谢!

如果你正在寻找我的info.plist 里面的内容,那就是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <key>io.flutter.embedded_views_preview</key>
    <true/>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>SyncShop</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

【问题讨论】:

【参考方案1】:

您的 info.plist 的开头无效,应该如下所示:

    <key>io.flutter.embedded_views_preview</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>

您可以看到io.flutter.embedded_views_preview 已粘贴在现有CFBundleDevelopmentRegion 与其值之间。

【讨论】:

你知道为什么会这样或者它是生成的吗?我没有触摸 ios 文件夹中的任何代码,因为我什至没有 iPhone 开始...... 如果您使用 google_maps_flutter 之类的东西,该字段是必需的 - 但据我所知 info.plist 不会自动更改 - 您是否可以在按照一些说明进行编辑?您是使用 flutter create 还是使用一些入门模板启动您的应用程序? 我没有以任何方式进行编辑,我只是​​弄乱了 android 文件夹,是的,我确实使用颤振创建而不是使用入门模板启动了我的应用程序。但是感谢您提供的信息,我现在构建了我的 iOS 应用程序。我想在接下来的项目中,我会先检查一下。非常感谢!

以上是关于使用 Codemagic 在没有 Mac 的情况下构建 iOS的主要内容,如果未能解决你的问题,请参考以下文章

Codemagic“获取签名文件”脚本以状态码 9 退出

魔码 | iOS 构建失败

Codemagic 自动构建没有被触发

是否可以在没有 mac 应用商店的情况下分发签名的 mac 应用程序(使用免费开发帐户)?

如何在没有 Mac 开发者计划成员资格的情况下使用 NSLogger 桌面客户端

在没有 Mac 的情况下向 Apple App Store 提交 Ionic App [重复]