Xcode 4 项目:清理 pbxproj 文件的实用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6064476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4 project: utility to clean up pbxproj file?
提问by memmons
I have an Xcode 4 project with 2 targets, one for iPhone and one for iPad. If I click on the iPad target and try to go to Build Settings Xcode 4 crashes:
我有一个带有 2 个目标的 Xcode 4 项目,一个用于 iPhone,一个用于 iPad。如果我单击 iPad 目标并尝试转到 Build Settings Xcode 4 崩溃:
Encountered multiple assertions. First assertion was: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-269/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/FileTypes/../PBXFileType.m:594 Details: filename should be a non-empty string, but it is nil
遇到多个断言。第一个断言是:ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-269/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/FileTypes/../PBXFileType.m:594 详细信息:文件名应该是一个非空字符串,但它是零
Obviously the pbxproj file has a bad reference in there somewhere -- likely caused by the many manual merges I've been forced to do by git. Is there some way to clean up the pbxproj file so it works correctly again or to tell which line is causing the problem?? I'd really reallyprefer not to have to recreate the project from scratch.
显然 pbxproj 文件在某处有一个错误的引用——可能是由于我被迫通过 git 进行的许多手动合并造成的。有什么方法可以清理 pbxproj 文件,使其再次正常工作或判断哪一行导致了问题?我真的真的不想从头开始重新创建项目。
采纳答案by Ben Mosher
I tried gorbster's method with no success (though it has solved similar problems for me in the past).
我尝试了 gorbster 的方法但没有成功(尽管它过去为我解决了类似的问题)。
I went into my project.pbxproj
file (inside the .xcodeproj
package for the project) and found two lines that looked a little suspicious, both of the form:
我进入我的project.pbxproj
文件(在.xcodeproj
项目的包内),发现两行看起来有点可疑,都是以下形式:
53A45F8F138FE6F40077017F /* (null) in Resources */ = {isa = PBXBuildFile; };
I deleted the lines, and voilà: I can access my build settings for this target again.
我删除了这些行,瞧:我可以再次访问此目标的构建设置。
No idea how they got in there in the first place. I would guess something to do with a faulty merge under SVN.
不知道他们一开始是怎么进去的。我猜想与 SVN 下的错误合并有关。
回答by gorbster
Ran into the same issue this morning after pulling a colleague's merge.
今天早上在拉一个同事的合并后遇到了同样的问题。
I was able to fix this with the following:
我能够通过以下方式解决这个问题:
- Close Xcode
- Open the .xcodeprojpackage in Finder
- Delete the project.xcworkspacefile/package
- Open the xcuserdatafolder and delete your user-specific .xcuserdatadfolder.
- Re-Open Xcode and project
- 关闭 Xcode
- 在 Finder 中打开.xcodeproj包
- 删除project.xcworkspace文件/包
- 打开xcuserdata文件夹并删除特定于用户的 .xcuserdatad文件夹。
- 重新打开Xcode和项目
I lost some minor user preferences (file and tab history, etc), but can now click all (9) of my targets without issue. Turns out my colleague was on an earlier version of Xcode, but I'm not sure if this contributed to the IDE crashing.
我丢失了一些次要的用户首选项(文件和标签历史记录等),但现在可以毫无问题地单击我的所有 (9) 个目标。原来我的同事使用的是早期版本的 Xcode,但我不确定这是否会导致 IDE 崩溃。
回答by Martin Magakian
Ben Mosher found the solution. And yes it is due to SVN merge problem.
Ben Mosher 找到了解决方案。是的,这是由于 SVN 合并问题。
As we working in team with SVN the error occur often so I wrote a bash script:
当我们与 SVN 合作时,错误经常发生,所以我写了一个 bash 脚本:
#!/bin/bash
sed "/(null) in/d" project.pbxproj > tmp_project.pbxproj
mv tmp_project.pbxproj project.pbxproj
回答by Mohamed A.Karim
Try the following steps while your XCode is closed.
在 XCode 关闭时尝试以下步骤。
Go to your {YOUR_PROJECT}.xcodeprojfile in finder.
Right click on the {YOUR_PROJECT}.xcodeprojfile.
Choose Show Package Contents... this will open the contents in another Finder screen.
Open file project.pbxprojand search for all lines having string "(null) in"
Delete all lines having (null) in... no worries.... delete confidently.
Save your file.
转到finder 中的{YOUR_PROJECT}.xcodeproj文件。
右键单击{YOUR_PROJECT}.xcodeproj文件。
选择Show Package Contents... 这将在另一个 Finder 屏幕中打开内容。
打开文件project.pbxproj并在“中搜索所有具有字符串” (空)的行
删除所有包含 (null) 的行...不用担心.... 自信地删除。
保存您的文件。
Now open your project using XCode and try to open the Build Settings tab... hopefully your problem will be solved.
现在使用 XCode 打开您的项目并尝试打开 Build Settings 选项卡...希望您的问题将得到解决。
Thanks, Mohamed.
谢谢,穆罕默德。
回答by Batu
Right click your .xcodeproj file and "Show Package Contents".
右键单击您的 .xcodeproj 文件并“显示包内容”。
Then open project.pbxproj file with TextEdit and duplicate.
然后用 TextEdit 打开 project.pbxproj 文件并复制。
Save duplicate file anywhere with same name and extension. (project.pbxproj)
使用相同的名称和扩展名在任何地方保存重复的文件。(project.pbxproj)
And replace with the old file.
并替换为旧文件。
回答by vmanjz
In case you also tried the remove (null) reference lines and deleting the user-specific .xcuserdatadfolder, and those did not work, here is a potential solution. FYI... This was experienced on Xcode 7.3.1 .
如果您还尝试删除 (null) 参考行并删除特定于用户的 .xcuserdatad文件夹,但这些都不起作用,这里是一个潜在的解决方案。仅供参考......这是在 Xcode 7.3.1 上经历过的。
Here is the scenario I faced:
这是我遇到的场景:
I experienced this issue that was triggered by having "twin" branches in a git repo... (i.e. one branch BRANCH_A is a development branch with some features not due for release, and another that had the same commits except for the new features, call it BRANCH_B).
我遇到了这个问题,它是由 git repo 中的“双”分支触发的......(即一个分支 BRANCH_A 是一个开发分支,其中一些功能尚未发布,另一个具有相同的提交,但新功能除外,称之为 BRANCH_B)。
The development work flow is as follows: start with BRANCH_B, create a commit branch CHANGE_C, make changes and commit, then checkout BRANCH_A, create a commit branch, then cherry-pick changes from CHANGE_C. BRANCH_A is tracking BRANCH_B in this way, with its additional feature files.
开发工作流程如下:从 BRANCH_B 开始,创建一个提交分支 CHANGE_C,进行更改并提交,然后检出 BRANCH_A,创建一个提交分支,然后从 CHANGE_C 中挑选更改。BRANCH_A 正在以这种方式跟踪 BRANCH_B 及其附加功能文件。
In my case, (for some reason during rebasing on co-worker changes from the remote that BRANCH_B tracks, the project file for BRANCH_B got corrupted.
在我的情况下,(由于某种原因,在根据 BRANCH_B 跟踪的远程同事更改重新设置时,BRANCH_B 的项目文件已损坏。
In this case, the solution is to save a copy of the project file for BRANCH_A (which is good and compiles), then checkout BRANCH_B, and replace its project file with the copy.
在这种情况下,解决方案是为 BRANCH_A 保存项目文件的副本(这是好的并且可以编译),然后检出 BRANCH_B,并用副本替换其项目文件。
Initially, it will not compile, until all references to the feature files (from BRANCH_A) are removed from Target's Build Phases > Compile Sources.
最初,它不会编译,直到从 Target 的 Build Phases > Compile Sources 中删除对功能文件(来自 BRANCH_A)的所有引用。
Works great.
效果很好。