iOS development debuging error record - 1
Error description
Showing Recent Errors Only
Multiple commands produce '/Users/yuanlaihe/Library/Developer/Xcode/DerivedData/Sep769_project-bhiaxmkofcqtukgaxxpgtjmmcxbu/Build/Products/Debug-iphonesimulator/Sep769_project.app/Info.plist'
我从firebase的example项目中复制了一个Info.plist文件过来后编译时报了如上错误。
这个报错意味着在构建过程中,存在两个命令或步骤都试图生成或复制到相同的输出路径,即 Sep769_project.app/Info.plist
。这种情况可能会在你向项目中添加文件或配置,或从其他项目中复制内容时发生。
由于你提到是从 Firebase 的示例项目中复制过来的,可能是在复制过程中不小心添加了额外的 Info.plist
文件或相关的构建阶段。
要解决这个问题,你可以按照以下步骤操作:
-
打开 Xcode 并选择你的项目文件(通常在 Navigator 面板的最顶部)。
-
选择你的 target,然后点击 Build Phases 选项卡。
-
展开 “Copy Bundle Resources” 阶段。在这里,检查是否有两个
Info.plist
文件。如果有,删除其中一个。 -
展开 “Compile Sources” 阶段。确保这里没有
Info.plist
文件。通常,Info.plist
文件不应该被编译,所以它不应该出现在这里。 -
清理构建文件夹。这可以通过选择菜单栏上的
Product
>Clean Build Folder
或使用快捷键Shift + Command + K
来完成。 -
重新构建项目。
按照上述步骤操作后,该问题应该得到解决。如果问题仍然存在,你可能需要深入检查其他构建设置和阶段,或考虑检查 .xcodeproj
文件或 .xcworkspace
文件是否有冲突或错误配置。
这是基于多年iOS开发经验以及对Xcode的深入了解所得出的结论。开发过程中常见的错误和问题,尤其是与构建和配置相关的问题,往往在社区中被反复提及和讨论。当开发者遇到这些问题并解决它们后,这些解决方案往往会留存在他们的经验和知识库中。
“Multiple commands produce”这一错误提示,尤其是与Info.plist
文件相关的提示,通常指示了构建过程中有多个步骤试图操作相同的文件或资源。考虑到Info.plist
文件的特殊性和重要性(每个iOS应用只应该有一个),一个常见的解决方法是检查“Copy Bundle Resources”阶段,因为这是Xcode用来复制资源文件到应用bundle中的地方。
要成为一个高效的问题解决者,以下是一些建议:
-
了解工具:花时间深入了解你使用的工具和技术。对Xcode的深入了解可以帮助你更好地理解其构建和配置过程。
-
搜索和社区:当遇到问题时,尝试在Stack Overflow、Apple Developer Forums和其他相关社区中搜索相同或类似的问题。很可能有人已经遇到并解决了相同的问题。
-
逐步调试:当遇到问题时,尝试逐步回退到最后一个已知的工作状态,并逐步应用更改,直到你能够准确地识别问题的来源。
-
持续学习:技术和工具总是在进化。定期为自己分配时间来学习新的技术、工具和最佳实践。
-
与同事讨论:两个脑袋总比一个脑袋好。如果你有困惑或遇到问题,尝试与团队成员或同事讨论。他们可能会提供一个不同的视角或解决方案。
最后,遇到问题并学会解决它们是成长的一部分。每次遇到并克服一个问题,你都会学到新的东西并增强你的问题解决能力。
Error 2
Sandbox: rsync.samba(12698) deny(1) file-write-create /Users/shrek/Library/Developer/Xcode/DerivedData/PhotoPC-dejmlgrmwbxazrgvfwpxvhadwsuy/Build/Products/Debug-iphonesimulator/PhotoPC.app/Frameworks/Alamofire.framework/.Alamofire.ihLdr1
Sandbox: rsync.samba(12698) deny(1) file-write-create /Users/shrek/Library/Developer/Xcode/DerivedData/PhotoPC-dejmlgrmwbxazrgvfwpxvhadwsuy/Build/Products/Debug-iphonesimulator/PhotoPC.app/Frameworks/Alamofire.framework/.Info.plist.vn2fty

Check that ENABLE_USER_SCRIPT_SANDBOXING is disabled in the project’s build settings.
The fix if you want to keep ENABLE_USER_SCRIPT_SANDBOXING enabled is to add the files as inputs and outputs. I use a script to set the build number in the build info plist file. I just need to set “${TARGET_BUILD_DIR}/${INFOPLIST_PATH}” as an output of the script
build setting ENABLE_USER_SCRIPT_SANDBOXING was added in Xcode 14 but enabled in the update to recommend setting in Xcode 15
From the Xcode 14 Release Notes:
You can now enable sandboxing for shell script build phases using the ENABLE_USER_SCRIPT_SANDBOXING build setting. Sandboxing blocks access to files inside the source root of the project as well as the Derived Data directory unless you list those files as inputs or outputs. When enabled, the build fails with a sandbox violation if a script phase attempts to read from or write to an undeclared dependency, preventing incorrect builds.
Thanks to Daniel Jalket’s Blog Post: Xcode Build Script Sandboxing - https://indiestack.com/2023/06/xcode-build-script-sandboxing/
Enjoy Reading This Article?
Here are some more articles you might like to read next: