'Getting a (null) reference in the Xcode pbxproj file
Upon updating/bumping up the version and the build # in Xcode version 9.1, I saw the following upon doing git diff
diff --git a/star.xcodeproj/project.pbxproj b/star.xcodeproj/project.pbxproj
index c4601526..8fa3c762 100644
--- a/star.xcodeproj/project.pbxproj
+++ b/star.xcodeproj/project.pbxproj
@@ -767,7 +767,7 @@
- F4487BE11FB28C400079BAAD /* BuildFile in Sources */ = {isa = PBXBuildFile; };
+ F4487BE11FB28C400079BAAD /* (null) in Sources */ = {isa = PBXBuildFile; };
@@ -5625,7 +5625,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- F4487BE11FB28C400079BAAD /* BuildFile in Sources */,
+ F4487BE11FB28C400079BAAD /* (null) in Sources */,);
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>2.11.4</string>
+ <string>2.11.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
@@ -39,7 +39,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
- <string>02110400</string>
+ <string>02110500</string>
<key>FacebookAppID</key>
<string>70858204300</string>
<key>FacebookBetaAppID</key>
All I did was bump up the version of the project. But upon doing a git status and a git diff, I see some null references in the .pbxproj file. Has anybody else seen this. As a side-note we also use Cocoapods in our project.
Solution 1:[1]
Remove all occurrences of (null) in Sources
lines in your project.pbxproj
:
sed -i '' '/(null) in Sources /d' YOURPROJECT.xcodeproj/project.pbxproj
Solution 2:[2]
I created simple shell script to remove all null references in project file.
Save as file, give execute permission and call it.
#!/bin/sh
sed -i '' '/(null) in Sources /d' ProjectName.xcodeproj/project.pbxproj
sed -i '' '/(null) in Resources /d' ProjectName.xcodeproj/project.pbxproj
sed -i '' '/(null) in Frameworks /d' ProjectName.xcodeproj/project.pbxproj
Solution 3:[3]
I removed all (null) references in project file and all IDs which mentioned with them. Then tried to build run and archive App - all worked fine. Looks like Xcode did not removed them itself by some reason.
In your case try to remove F4487BE11FB28C400079BAAD with (null), and all lines with this F4487BE11FB28C400079BAAD too. And do this with other (null) references.
Solution 4:[4]
Here's an alternative method for removing the lines using Fastlane based on muhasturk's answer.
desc 'Clean up null references in project.pbxproj file'
lane :remove_null_references_in_pbxproj_file do
path_to_pbxproj = '../YourApp.xcodeproj/project.pbxproj'
['Sources', 'Resources', 'Frameworks'].each { |section|
`sed -i '' '/(null) in #{section} /d' #{path_to_pbxproj}`
}
end
This assumes you've got a default Fastlane installation in your project, so the we need a relative path up one level from the fastlane
folder for the project.
Within Fastlane, you can just call this lane with remove_null_references_in_pbxproj_file
. Note the sed
command is surrounded by backticks, not single quotes, which is why interpolation works for dumping vars into the command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | muhasturk |
Solution 3 | Nikolay Shubenkov |
Solution 4 | Adrian |