Skip to content

Commit

Permalink
Clean up version reporting
Browse files Browse the repository at this point in the history
- No more `(null)` output when building against the static lib
- Share a common script between targets for copying the git SHA into the Info.plist
  • Loading branch information
Brian Croom committed Sep 14, 2015
1 parent 37b7c53 commit 04e62b4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
37 changes: 26 additions & 11 deletions Cedar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
AEEE225A11DC2C0200029872 /* Build universal static lib */,
AEEE225E11DC2C5E00029872 /* Copy headers to framework */,
3444602A190CC3320076655A /* Copy Info.plist to framework */,
34446027190CAA930076655A /* Set Git SHA on Framework */,
344077C41BA7544F00037486 /* Set Git SHA on Framework */,
);
dependencies = (
);
Expand Down Expand Up @@ -2526,6 +2526,7 @@
AE4864F31B067620005DB302 /* Sources */,
AE4864F41B067620005DB302 /* Frameworks */,
AE4864F61B067620005DB302 /* Resources */,
344077C51BA76D1700037486 /* Set Git SHA on Framework */,
);
buildRules = (
);
Expand Down Expand Up @@ -2562,7 +2563,7 @@
AEEE1FB211DC271300029872 /* Resources */,
AEEE1FB311DC271300029872 /* Sources */,
AEEE1FB411DC271300029872 /* Frameworks */,
3468B7AA1909595200203B87 /* Set Git SHA on Framework */,
344077C11BA74D7B00037486 /* Set Git SHA on Framework */,
);
buildRules = (
);
Expand Down Expand Up @@ -2781,7 +2782,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
34446027190CAA930076655A /* Set Git SHA on Framework */ = {
344077C11BA74D7B00037486 /* Set Git SHA on Framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -2792,24 +2793,24 @@
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env ruby";
shellScript = "key = \"CDRBuildVersionSHA\"\nver = `git rev-parse HEAD`.strip\nputs \"Git commit SHA is #{ver}\"\npath = \"#{ENV['BUILD_DIR']}/#{ENV['CONFIGURATION']}-iphoneuniversal/#{ENV['PRODUCT_NAME']}.framework/Resources/Info.plist\"\n`/usr/libexec/PlistBuddy -c \"Add :#{key} string #{ver}\" \"#{path}\"`";
shellPath = /bin/sh;
shellScript = "/usr/bin/env ruby scripts/set_git_sha_on_framework.rb";
};
3444602A190CC3320076655A /* Copy Info.plist to framework */ = {
344077C41BA7544F00037486 /* Set Git SHA on Framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Info.plist to framework";
name = "Set Git SHA on Framework";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cp \"${SRCROOT}/Cedar-Info.plist\" \"${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal/${PRODUCT_NAME}.framework/Resources/Info.plist\"";
shellScript = "PLIST_PATH=../${CONFIGURATION}-iphoneuniversal/${PRODUCT_NAME}.framework/Resources/Info.plist\nINFOPLIST_PATH=${PLIST_PATH} /usr/bin/env ruby scripts/set_git_sha_on_framework.rb";
};
3468B7AA1909595200203B87 /* Set Git SHA on Framework */ = {
344077C51BA76D1700037486 /* Set Git SHA on Framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -2820,8 +2821,22 @@
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env ruby";
shellScript = "key = \"CDRBuildVersionSHA\"\nver = `git rev-parse HEAD`.strip\nputs \"Git commit SHA is #{ver}\"\npath = \"#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['INFOPLIST_PATH']}\"\nputs \"Updating #{path}\"\n`/usr/libexec/PlistBuddy -c \"Add :#{key} string #{ver}\" \"#{path}\"`";
shellPath = /bin/sh;
shellScript = "/usr/bin/env ruby scripts/set_git_sha_on_framework.rb";
};
3444602A190CC3320076655A /* Copy Info.plist to framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Info.plist to framework";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cp \"${SRCROOT}/Cedar-Info.plist\" \"${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal/${PRODUCT_NAME}.framework/Resources/Info.plist\"";
};
96B5FA0F144A81A8000A6A5D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion Source/CDRFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BOOL CDRClassIsOfType(Class class, const char * const className) {
versionDetails = [cedarFrameworkBundle objectForInfoDictionaryKey:CDRBuildVersionKey];
}

return [releaseVersion stringByAppendingFormat:@" (%@)", versionDetails];
return versionDetails ? [CDRVersion stringByAppendingFormat:@" (%@)", versionDetails] : CDRVersion;
}

#pragma mark - Globals
Expand Down
8 changes: 8 additions & 0 deletions scripts/set_git_sha_on_framework.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/ruby

key = "CDRBuildVersionSHA"
ver = `git rev-parse HEAD`.strip
puts "Git commit SHA is #{ver}"
path = "#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['INFOPLIST_PATH']}"
puts "Updating #{path}"
`/usr/libexec/PlistBuddy -c "Add :#{key} string #{ver}" "#{path}"`

0 comments on commit 04e62b4

Please sign in to comment.