Fastlane使用错误账号获取Provisioning Profiles问题咨询
Fastlane iOS签名账号不一致问题解决方案
首先看一下你的控制台输出:
+---------------+---------------------------------------------------+ | Summary for cert 2.96.1 | +---------------+---------------------------------------------------+ | development | false | | force | false | | username | correctappleid@gmail.com | | team_id | CSCORRECTTEAMID | | keychain_path | /Users/bartek/Library/Keychains/login.keychain-db | | platform | ios | +---------------+---------------------------------------------------+ [09:01:23]: Starting login with user 'correctappleid@gmail.com' [09:01:27]: Successfully logged in [09:01:28]: Certificate 98TLCZS7BR (iOS Distribution) can't be found on your local computer [09:01:29]: Found the certificate 6K5C2MFHUL (iOS Distribution) which is installed on the local machine. Using this one. [09:01:30]: Verifying the certificate is properly installed locally... [09:01:30]: Successfully installed certificate 6K5C2MFHUL [09:01:30]: Use signing certificate '6K5C2MFHUL' from now on! [09:01:30]: -------------------------------------- [09:01:30]: --- Step: get_provisioning_profile --- [09:01:30]: -------------------------------------- +-------------------------------------+-------------------------------------------+ | Summary for sigh 2.96.1 | +-------------------------------------+-------------------------------------------+ | adhoc | false | | development | false | | skip_install | false | | force | false | | app_identifier | my.app.identifier | | username | wrongname@company.com | | team_id | CSTEAMID | | ignore_profiles_with_different_name | false | | cert_id | 6K5C2MFHUL | | skip_fetch_profiles | false | | skip_certificate_verification | false | | platform | ios | | readonly | false | +-------------------------------------+-------------------------------------------+ [09:01:30]: Starting login with user 'wrongname@company.com' ------------------------------------------------------------------------------------- Please provide your Apple Developer Program account credentials The login information you enter will be stored in your macOS Keychain You can also pass the password using the `FASTLANE_PASSWORD` environment variable
针对你的三个问题,我逐一解答:
1. 问题原因是什么?
这是因为Fastlane的cert和sigh工具读取了不一致的账号配置:
- 大概率是你在
Fastfile里给get_provisioning_profile(对应sigh工具)步骤单独指定了错误的username参数,和cert步骤的账号没对齐 - 也可能是全局/项目级的环境变量里,
FASTLANE_USER被设置成了错误账号,cert步骤显式指定了正确账号,而sigh默认读取了环境变量 - 还有一种可能是sigh之前缓存了错误的账号信息,这次执行直接复用了旧配置
2. 如何强制修改为正确账号?
有几种快速解决的方法,你可以按需选择:
- 命令行临时指定:执行Fastlane lane时直接带上正确账号参数,比如:
fastlane your_lane_name username:"correctappleid@gmail.com" - 修改Fastfile:找到
get_provisioning_profile的配置代码,显式添加username参数,确保和cert步骤一致,示例:get_provisioning_profile( username: "correctappleid@gmail.com", app_identifier: "my.app.identifier" # 其他原有参数... ) - 清除sigh缓存:执行以下命令重置sigh的缓存,之后重新运行lane:
fastlane sigh reset - 设置环境变量:在终端会话中设置全局环境变量,让所有Fastlane工具统一使用正确账号:
export FASTLANE_USER=correctappleid@gmail.com
3. 账号配置位置在哪里?
账号配置可能存在以下几个地方:
- 项目本地配置:项目根目录下的
Fastlane/Envfile或者Fastlane/.env.*(比如.env.production)文件,里面可能定义了FASTLANE_USER变量 - 全局Fastlane配置:用户主目录下的
~/.fastlane/.env文件,这个配置会影响所有本地的Fastlane项目 - Fastfile代码:直接在lane的步骤中硬编码了
username参数,比如前面提到的get_provisioning_profile配置块 - macOS钥匙串:Fastlane会把账号凭据存在系统钥匙串里,你可以通过「钥匙串访问」工具搜索“fastlane”来查看和管理存储的账号信息
内容的提问来源于stack exchange,提问作者kunass2
相关产品推荐
相关产品推荐

