如何使用 fastlane 缩短 Flutter iOS 应用程序的构建时间
How to shorten build time of Flutter iOS app using fastlane
我的问题是,当使用 Firebase(特别是 cloud_firestore
)时,Flutter iOS 应用程序的构建时间变得很长,以至于我在 Bitrise 上的 CI 构建超时(28 flutter build --release
的分钟,而 fastlane 的 build_ios_app
又超过 20 分钟)。所以我无法在我的 CI 上执行完整的 iOS 构建。缓存当然是可能的,但首先必须完成初始构建:/
根据this guide it's necessary to rebuild iOS app when archiving with Xcode using Fastlane. There is, however, a discussion on official Github repo介绍了直接从 Flutter 发布 IPA 文件的命令,但目前还不可能。
我的问题是 - 有什么方法可以缩短构建时间,例如通过跳过 fastlane 步骤中的构建,只是辞职并将 .app 文件归档到 .ipa?我一个人搞不定。
Here you may find a sample Flutter app 启用 cloud_firestore
。
您可以在下面找到我的 Bitrise 和 fastlane 配置:
---
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
这里是快车道:
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-sdk-frameworks 的 Cloud Firestore 框架的预编译二进制文件修复了同样的问题,如下所示:
# ...
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.26.0'
# ...
end
可在此处找到完整说明https://github.com/FirebaseExtended/flutterfire/issues/2751
我的问题是,当使用 Firebase(特别是 cloud_firestore
)时,Flutter iOS 应用程序的构建时间变得很长,以至于我在 Bitrise 上的 CI 构建超时(28 flutter build --release
的分钟,而 fastlane 的 build_ios_app
又超过 20 分钟)。所以我无法在我的 CI 上执行完整的 iOS 构建。缓存当然是可能的,但首先必须完成初始构建:/
根据this guide it's necessary to rebuild iOS app when archiving with Xcode using Fastlane. There is, however, a discussion on official Github repo介绍了直接从 Flutter 发布 IPA 文件的命令,但目前还不可能。
我的问题是 - 有什么方法可以缩短构建时间,例如通过跳过 fastlane 步骤中的构建,只是辞职并将 .app 文件归档到 .ipa?我一个人搞不定。
Here you may find a sample Flutter app 启用 cloud_firestore
。
您可以在下面找到我的 Bitrise 和 fastlane 配置:
---
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
这里是快车道:
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-sdk-frameworks 的 Cloud Firestore 框架的预编译二进制文件修复了同样的问题,如下所示:
# ...
target 'Runner' do
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.26.0'
# ...
end
可在此处找到完整说明https://github.com/FirebaseExtended/flutterfire/issues/2751