Xcode 15中fastlane scan报‘source is not valid JSON’错误求助
排查方向
升级fastlane版本
当前使用的fastlane 2.219.0发布时间较早,对Xcode 15系列(含beta版)的适配可能存在缺陷。建议升级到最新稳定版:bundle update fastlane或者选择明确适配Xcode 15的版本(如2.220.0及以上)
验证simctl的JSON输出功能
手动执行带JSON参数的命令,确认系统层面的simctl是否正常:xcrun simctl list runtimes --json如果输出仍非JSON格式,说明Simulator或Xcode命令行工具存在异常,可尝试:
- 重装Xcode命令行工具:
xcode-select --install - 重置所有模拟器:
xcrun simctl erase all,之后重启Simulator应用 - 检查Xcode配置:打开Xcode → 偏好设置 → 位置,确认“命令行工具”选择的是当前使用的Xcode版本
- 重装Xcode命令行工具:
显式指定run_tests的模拟器参数
避免fastlane自动检测模拟器出错,在lane中明确指定可用的模拟器:lane :tests do run_tests( workspace: "Foo.xcworkspace", scheme: "#{SCHEME}", testplan: "#{SCHEME}UnitTestPlan", destination: "platform=iOS Simulator,name=iPhone 15,OS=17.2" ) end也可以尝试添加
disable_simulator_detection: true参数,关闭自动检测逻辑排查环境变量与Shell配置
检查是否有环境变量干扰了命令执行:- 执行
echo $PATH,确保Xcode相关路径(如/Applications/Xcode.app/Contents/Developer/usr/bin)处于PATH最前端 - 执行
which simctl,确认输出为/usr/bin/simctl,避免自定义别名或脚本覆盖系统命令
- 执行
查看scan的详细日志
手动执行带--verbose参数的scan命令,获取更详细的错误信息,定位JSON解析失败的具体环节:fastlane scan --workspace Foo.xcworkspace --scheme #{SCHEME} --testplan #{SCHEME}UnitTestPlan --verbose
内容的提问来源于stack exchange,提问作者David Nedrow
相关产品推荐
相关产品推荐

