Fastlane无法检测iOS App Development配置文件问题咨询
我在用Fastlane搭建iOS应用的CI/CD自动构建流程时,遇到了Development配置文件检测失败的问题,报错信息如下:
error: No profiles for 'my-app-identifier' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'my-app-identifie'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'My-target' from project 'App-scheme')
Xcode默认开启自动代码签名,我手动关闭该选项并指定证书后,Fastlane能正常完成构建。我已经在build_app函数里配置了配置文件信息,想问Fastlane有没有直接选择配置文件的选项?
附上我的Fastfile代码:
default_platform(:ios) platform :ios do before_all do |lane, options| APP_ID=ENV['APP_ID'] APP_SCHEME=ENV['APP_SCHEME'] setup_ci end desc "Fetches the provisioning profiles so you can build locally and deploy to your device" lane :certs do match(app_identifier: [APP_ID], type: "appstore", readonly: true, git_branch: "new-2") match(app_identifier: [APP_ID], type: "development", readonly: true, git_branch: "new-2") match(app_identifier: [APP_ID], type: "adhoc", readonly: true, git_branch: "new-2") end desc "Description of what the lane does" lane :beta do # add actions here: https://docs.fastlane.tools/actions # increment_build_number connect_appstore_api build_app( scheme: APP_SCHEME, export_method: "app-store", output_directory: "./build/appstore/", clean: true, archive_path: "./build/build", export_options: { provisioningProfiles: { APP_ID => "match AppStore #{APP_ID}", } } ) # pilot end desc "Generate certificates" lane :generate_certs do connect_appstore_api match( app_identifier: [APP_ID], type: "development", readonly: false, git_branch: "new-2" ) match( app_identifier: [APP_ID], type: "adhoc", readonly: false, git_branch: "new-2" ) match( app_identifier: [APP_ID], type: "appstore", readonly: false, git_branch: "new-2" ) end private_lane :connect_appstore_api do app_store_connect_api_key( duration: 1200, # optional (maximum 1200) in_house: false, is_key_content_base64: true ) end lane :check_ci do if is_ci puts "I'm a computer" else puts "Hi Human!" end end end
Fastlane确实提供了直接指定配置文件的选项,以下是几种可行的实现方式:
1. 扩展export_options配置指定对应类型配置文件
你当前在beta lane的build_app中仅配置了App Store类型的配置文件,若要针对Development构建指定配置文件,只需修改export_method并补充对应配置文件条目:
build_app( scheme: APP_SCHEME, export_method: "development", # 匹配配置文件类型 output_directory: "./build/development/", clean: true, archive_path: "./build/build-dev", export_options: { provisioningProfiles: { APP_ID => "match Development #{APP_ID}" # 对应match生成的Development配置文件名称 } } )
2. 用match自动关联配置文件
match工具会自动下载安装配置文件,并同步配置Xcode项目的签名设置。确保执行build_app前先运行对应的match lane(比如你的:certs lane),Fastlane会自动把配置文件关联到项目,无需手动指定。
若需强制指定match的配置文件,可在build_app中配合use_profile参数:
match(app_identifier: [APP_ID], type: "development", readonly: true, git_branch: "new-2") build_app( scheme: APP_SCHEME, use_profile: "match Development #{APP_ID}" # 直接指定配置文件名称 )
3. 手动指定签名身份与配置文件
如果需要完全控制签名流程,可在build_app中直接指定签名身份和配置文件:
build_app( scheme: APP_SCHEME, export_method: "development", codesigning_identity: "iPhone Developer: Your Name (XXXXXX)", # 替换为你的签名身份 provisioning_profile_specifier: "match Development #{APP_ID}" )
4. 允许自动签名更新(临时方案)
若不想手动管理配置文件,可开启自动签名更新,让Xcode自动生成所需配置文件:
build_app( scheme: APP_SCHEME, allow_provisioning_updates: true )
内容的提问来源于stack exchange,提问作者Amjed saleel

