使用Expo构建React Native iOS应用时Xcode提示找不到GoogleService-Info.plist
错误信息
error: Build input file cannot be found: '/Users/expo/workingdir/build/.../ios/GoogleService-Info.plist'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
你已经尝试添加文件、加入Copy Bundle Resources、清理构建但仍无效?结合Expo的构建逻辑,试试这些针对性排查:
1. 确认文件放置路径正确
Expo构建时,只会同步项目根目录下ios子文件夹内的文件到构建容器对应路径。别把GoogleService-Info.plist放在项目最外层根目录,必须移到<你的项目>/ios/文件夹内,再重新构建。
2. 让Expo构建流程识别该文件
如果用EAS Build,需要在app.json或app.config.js中明确声明这个资源,避免构建时被过滤:
{ "expo": { "ios": { "resources": ["./ios/GoogleService-Info.plist"] } } }
这样Expo打包时会确保文件被复制到构建容器的正确位置。
3. 检查Xcode文件引用路径
若通过expo prebuild生成Xcode项目,手动添加文件后可能存在路径问题。打开Xcode选中GoogleService-Info.plist,查看右侧File Inspector:
- 确保Location选择Relative to Project
- 路径设置为
./GoogleService-Info.plist(因文件已在ios文件夹内),避免使用绝对路径
4. 云构建需检查Git提交状态
使用EAS云构建时,要确认GoogleService-Info.plist已提交到Git仓库。如果文件被.gitignore排除,构建服务器拉取不到文件,自然会报错。
5. 用构建脚本强制复制文件(极端情况)
如果上述方法都无效,可在eas.json中添加预构建脚本,手动将文件复制到正确路径:
{ "build": { "production": { "ios": { "prebuildCommand": "cp ./GoogleService-Info.plist ./ios/GoogleService-Info.plist" } } } }
注意根据实际文件位置调整路径。
内容的提问来源于stack exchange,提问作者Relie Essom

