【发布时间】:2019-09-29 01:58:26
【问题描述】:
我的问题是,当使用 Firebase(尤其是cloud_firestore)时,Flutter iOS 应用程序的构建时间变得很长,以至于我在 Bitrise 上构建的 CI 达到超时(flutter build --release 为 28 分钟,对于fastlane 的build_ios_app)。所以我无法在我的 CI 上执行完整的 iOS 构建。缓存当然是可能的,但首先必须完成初始构建:/
根据this guide,在使用 Fastlane 使用 Xcode 归档时,需要重新构建 iOS 应用程序。不过,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
【问题讨论】:
-
有没有办法在 Bitrise 之外进行完整构建?这将使某人更容易获取您的示例存储库(真棒,您的问题已经包含一个!)并尝试重新创建您正在经历的内容。 (例如,Fastlane 可以使用
sh操作执行任何 shell 命令,也许这可以将full_run通道添加到您的Fastfile以在本地完成整个操作?) -
实际上你甚至可以在你的机器上构建它。我提到 Bitrise 的原因是它每次都会创建干净的 VM,因此无需拉动缓存,就需要完整的构建。所以换句话说,你可以简单地运行
flutter build ios --release,然后运行fastlane run build_ios_app。如果可以跳过 fastlane/Xcode 构建中的所有Compiling任务,那将是我的问题的解决方案。
标签: ios xcode flutter fastlane bitrise