使用fastlane/Jenkins构建时缺少临时配置文件功能



我正在尝试使用Jenking/fastlane设置自动化的iOS构建。代码签名是使用fastlane match设置的。然而,当Jenkins运行作业并调用xcodebuild时,我得到的是:

[16:06:09]: [36m$ set -o pipefail && xcodebuild -workspace ./Runner.xcworkspace -scheme dev -configuration Release-dev -destination 'generic/platform=iOS' -archivePath /Users/Shared/Jenkins/Library/Developer/Xcode/Archives/2020-04-14/Runner 2020-04-14 16.06.09.xcarchive archive | tee /Users/Shared/Jenkins/Library/Logs/gym/Runner-dev.log | xcpretty[0m
[16:06:23]: ▸ [35m[31m❌  error: "Runner" requires a provisioning profile with the Push Notifications feature. Select a provisioning profile in the Signing & Capabilities editor. (in target 'Runner' from project 'Runner')[0m
[16:06:23]: ▸ [35m** ARCHIVE FAILED **[0m

不用说,使用的配置文件确实包含上述功能(我已经在开发者门户网站中查看过(。

我的Fastfile(相关部分(:

private_lane :build_qa do
UI.message("Building qa build...")
sync_code_signing
sync_code_signing(type: "adhoc", readonly: true)
update_code_signing_settings(
use_automatic_signing: false,
path: "Runner.xcodeproj"
)
sh("cd ../..;
flutter build ios --release --flavor dev --no-codesign"
)
build_ios_app(
scheme: "dev",
configuration: "Release-dev",
output_name: "Runner.ipa"
)
update_code_signing_settings(
use_automatic_signing: true,
path: "Runner.xcodeproj"
)
end

match:综述

+-------------------------------------------------------------------------+-------------------------------------------------------------------+
|                                                           [32mSummary for gym 2.145.0[0m                                                           |
+-------------------------------------------------------------------------+-------------------------------------------------------------------+
| scheme                                                                  | dev                                                               |
| configuration                                                           | Release-dev                                                       |
| output_name                                                             | Runner                                                            |
| catalyst_platform                                                       | ios                                                               |
| export_method                                                           | ad-hoc                                                            |
| export_options.provisioningProfiles.com.flutter.example.track.dev       | match AdHoc com.flutter.example.track.dev                         |
| export_options.provisioningProfiles.com.flutter.example.track.prod      | match AdHoc com.flutter.example.track.prod                        |
| workspace                                                               | ./Runner.xcworkspace                                              |
| destination                                                             | generic/platform=iOS                                              |
| build_path                                                              | /Users/Shared/Jenkins/Library/Developer/Xcode/Archives/2020-05-05 |
| clean                                                                   | false                                                             |
| output_directory                                                        | .                                                                 |
| silent                                                                  | false                                                             |
| skip_package_ipa                                                        | false                                                             |
| result_bundle                                                           | false                                                             |
| buildlog_path                                                           | ~/Library/Logs/gym                                                |
| skip_profile_detection                                                  | false                                                             |
| skip_package_pkg                                                        | false                                                             |
| xcode_path                                                              | /Applications/Xcode.app                                           |
+-------------------------------------------------------------------------+-------------------------------------------------------------------+

也许我迟到了一点,但这里有我的工作解决方案:

# Initial considerations: we want to have all the control over project settings,
# in particular
# - code signing
# - provisioning
# - team
# - app identifier
platform :ios do
lane :build do |values|
# All params should be dynamically passed with ENV vars

# Disable automatic code signing must be set BEFORE match
disable_automatic_code_signing(
path: PROJECT_PATH,
team_id: TEAM_ID
)

# match action... 
# In my case app_store_connect_api_key + sync_code_signing

# Provisioning update 
# NOTE: PROFILE_PATH_ENV_VAR, based on match type, is the provisioning profile path previously generated from match
# I.e. for development match type: sigh_[appBundleId]_development_profile-path
# Check https://docs.fastlane.tools/codesigning/xcode-project/#set-using-environment-variable for more info
update_project_provisioning(
xcodeproj: XCODE_PROJECT_PATH,
target_filter: TARGET_NAME,
profile: ENV["PROFILE_PATH_ENV_VAR"],
build_configuration: "Release"
)
# Project team update
update_project_team(
path: XCODE_PROJECT_PATH,
teamid: TEAM_ID
)

# App identifier update
update_app_identifier(
xcodeproj: XCODE_PROJECT_PATH,
plist_path: PLIST_PATH,
app_identifier: BUNDLE_ID
)

gym(
# ... Every custom param you need 
...
codesigning_identity: CERTIFICATE_NAME,
export_options: {
compileBitcode: false,
provisioningProfiles: ENV['MATCH_PROVISIONING_PROFILE_MAPPING'], # ENV var generated from match 
# http://docs.fastlane.tools/actions/sync_code_signing/#lane-variables
signingStyle: "manual"
}
)
end 
end

如果您使用match来管理配置文件,您可以在gym/build_ios_app中强制使用export_options,如下所示:

gym(
scheme: "dev",
configuration: "Release-dev",
output_name: "Runner.ipa"
export_options: {
compileBitcode: false,
provisioningProfiles: ENV['MATCH_PROVISIONING_PROFILE_MAPPING']
},
codesigning_identity: "Certificate name, if you want to override it as well"
)

最新更新