如何使用Fastlane缩短flutter IOS应用程序的构建时间



我的问题是,当使用firebase(尤其是 cloud_firestore(时,flutter iOS应用程序的构建时间很长,以至于我的ci构建在bitrise上到达超时(flutter build --release 28分钟,又是更多Fastlane的build_ios_app比20分钟。因此,我无法在CI上执行完整的iOS构建。当然可以缓存,但首先必须完成初始构建:/

根据本指南,使用FastLane用Xcode归档时有必要重建iOS应用程序。但是,关于官方GitHub回购的讨论涉及引入直接从Flutter发布IPA文件的命令,但现在是不可能的。

我的问题是 - 是否有任何方法可以缩短此构建时间,例如通过跳过Fastlane步骤,然后辞职并存档.App文件到.IPA?我不能让它一个人工作。

在这里,您可以找到带有cloud_firestore启用的示例幻影应用程序。

下面您可能会找到我的比特式配置:

---
format_version: '7'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: flutter
trigger_map:
- push_branch: master
workflow: test
workflows:
prepare:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - set-env-var@0.9.1:
        title: APP_NAME
        inputs:
        - destination_keys: APP_NAME
        - value: pl.flutter.buildTimeIssue
    - set-env-var@0.9.1:
        title: FL_BUILD_NUMBER
        inputs:
        - destination_keys: FL_BUILD_NUMBER
        - value: "$BITRISE_BUILD_NUMBER"
    - set-env-var@0.9.1:
        title: FL_VERSION_NUMBER
        inputs:
        - destination_keys: FL_VERSION_NUMBER
        - value: 0.1.$BITRISE_BUILD_NUMBER
    - git-clone@4.0.14: {}
    - cache-pull: {}
    - recursive-touch@0.9.0: {}
    - flutter-installer:
        inputs:
        - version: v1.2.1
    - script@1.1.5:
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x
            cd $BITRISE_FLUTTER_PROJECT_LOCATION/ios
            pod repo update
        title: Update pods repository
test:
    before_run:
    - prepare
    steps:
    - flutter-build@0.9.2:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
        - ios_additional_params: "--release --no-codesign -t lib/main.dart
            --build-name=$FL_VERSION_NUMBER --build-number=$FL_BUILD_NUMBER"
        is_always_run: true
    - fastlane@2.4.0:
        title: fastlane iOS
        inputs:
        - work_dir: "$BITRISE_FLUTTER_PROJECT_LOCATION/ios"
        - lane: ios test
    after_run:
    - finish
    envs:
    - opts:
        is_expand: false
    FLAVOR: tst
    - opts:
        is_expand: false
    TARGET_FILE: main_tst
finish:
    steps:
    - cache-push@2.1.1:
        inputs:
        - ignore_check_on_paths: "~/Library/Developer/Xcode/DerivedData"
        - cache_paths: |-
            $BITRISE_FLUTTER_PROJECT_LOCATION/build
            $BITRISE_FLUTTER_PROJECT_LOCATION/ios/Pods
            ~/Library/Developer/Xcode/DerivedData
app:
envs:
- opts:
    is_expand: false
    BITRISE_FLUTTER_PROJECT_LOCATION: ./
- opts:
    is_expand: false
    BITRISE_PROJECT_PATH: ./ios/Runner.xcworkspace
- opts:
    is_expand: false
    BITRISE_SCHEME: tst
- opts:
    is_expand: false
    BITRISE_EXPORT_METHOD: ad-hoc

这是fastlane:

default_platform(:ios)
platform :ios do
  lane :test do
    match(
      type: "adhoc",
      force_for_new_devices: true,
    )
    automatic_code_signing(
      use_automatic_signing: false
    )
    update_project_provisioning(
      profile: ENV["sigh_pl.flutter.buildTimeIssue_adhoc_profile-path"],
      build_configuration: "Release",
      code_signing_identity: "iPhone Distribution"
    )
    build_app(
      scheme: "tst",
      configuration: "Release",
      xcargs: "-allowProvisioningUpdates",
      export_options: {
        signingStyle: "manual",
        method: "ad-hoc",
        provisioningProfiles: {
          "pl.flutter.buildTimeIssue": "match AdHoc pl.flutter.buildTimeIssue"
        }
      },
      output_name: "Runner.ipa"
    )
    appcenter_upload(
      app_name: "Name",
      owner_name: "Owner",
      group: "All-users-of-Name",
      ipa: "Runner.ipa"
    )
  end
end

我遇到的问题与我用https://github.com/invertase/firestore-ios-ios-sdk-frameworks的云firestore框架预先编译的二进制文件解决了相同的问题:

# ...
target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.26.0'
# ...
end

可以在此处找到完整的说明

相关内容

  • 没有找到相关文章

最新更新