Skip to content

Commit

Permalink
Merged in development (pull request #1)
Browse files Browse the repository at this point in the history
Added automatic versioning script.
  • Loading branch information
zetxek committed Nov 8, 2015
2 parents 1eb9e80 + 14b3604 commit e68fe02
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 9 deletions.
40 changes: 38 additions & 2 deletions Kodi Remote/Kodi Remote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
/* Begin PBXBuildFile section */
0A016C731AC4AEB900590E32 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A016C711AC4AEB900590E32 /* Main.storyboard */; };
0A1E6C131ACB579700142684 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1E6C121ACB579700142684 /* SettingsViewController.swift */; };
0A2A1BA81BEFD6A700587FAE /* ProjectTexts.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0A2A1BA71BEFD6A700587FAE /* ProjectTexts.strings */; };
0A3F9EF91AC0C2BC008C6A4E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A3F9EF81AC0C2BC008C6A4E /* AppDelegate.swift */; };
0A3F9F001AC0C2BC008C6A4E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A3F9EFF1AC0C2BC008C6A4E /* Images.xcassets */; };
0A4C62CB1B6584BD00178BF5 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A4C62CA1B6584BD00178BF5 /* MainViewController.swift */; };
0A4C62D11B659FCD00178BF5 /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A4C62D01B659FCD00178BF5 /* MainViewModel.swift */; };
0A4C62D31B66E68700178BF5 /* PreferenceUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A4C62D21B66E68700178BF5 /* PreferenceUtils.swift */; };
0A524BF51BF00A750095740C /* APIKeys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0A524BF41BF00A750095740C /* APIKeys.plist */; };
0A7177091B55AB59000CA6E0 /* Fabric.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7177071B55AB59000CA6E0 /* Fabric.framework */; };
0A71770B1B55AB59000CA6E0 /* Crashlytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7177081B55AB59000CA6E0 /* Crashlytics.framework */; };
0A71770E1B55ABDF000CA6E0 /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A71770D1B55ABDF000CA6E0 /* libc++.dylib */; };
Expand Down Expand Up @@ -43,6 +45,7 @@
0AA7A1E01B8E78490014FCF4 /* TransparentButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA7A1DF1B8E78490014FCF4 /* TransparentButton.swift */; };
0AA7A1E31B8E7C9A0014FCF4 /* secondary_action.png in Resources */ = {isa = PBXBuildFile; fileRef = 0AA7A1E11B8E7C9A0014FCF4 /* secondary_action.png */; };
0AA7A1E41B8E7C9A0014FCF4 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0AA7A1E21B8E7C9A0014FCF4 /* [email protected] */; };
0AF2EE5A1BEFCA3000395313 /* automatic_versioning.sh in Resources */ = {isa = PBXBuildFile; fileRef = 0AF2EE591BEFCA3000395313 /* automatic_versioning.sh */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -62,6 +65,7 @@
/* Begin PBXFileReference section */
0A016C721AC4AEB900590E32 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
0A1E6C121ACB579700142684 /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
0A2A1BA71BEFD6A700587FAE /* ProjectTexts.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = ProjectTexts.strings; sourceTree = "<group>"; };
0A3F9EF31AC0C2BC008C6A4E /* Kodi Remote.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Kodi Remote.app"; sourceTree = BUILT_PRODUCTS_DIR; };
0A3F9EF71AC0C2BC008C6A4E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0A3F9EF81AC0C2BC008C6A4E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -72,6 +76,7 @@
0A4C62CD1B65878600178BF5 /* SwiftLog.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftLog.framework; path = "Pods/../build/Debug/Pods-Kodi Remote/SwiftLog.framework"; sourceTree = "<group>"; };
0A4C62D01B659FCD00178BF5 /* MainViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MainViewModel.swift; path = ViewModels/MainViewModel.swift; sourceTree = "<group>"; };
0A4C62D21B66E68700178BF5 /* PreferenceUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferenceUtils.swift; sourceTree = "<group>"; };
0A524BF41BF00A750095740C /* APIKeys.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = APIKeys.plist; path = Resources/Strings/APIKeys.plist; sourceTree = SOURCE_ROOT; };
0A7177071B55AB59000CA6E0 /* Fabric.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Fabric.framework; sourceTree = "<group>"; };
0A7177081B55AB59000CA6E0 /* Crashlytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Crashlytics.framework; sourceTree = "<group>"; };
0A71770D1B55ABDF000CA6E0 /* libc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.dylib"; path = "usr/lib/libc++.dylib"; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -100,6 +105,7 @@
0AA7A1DF1B8E78490014FCF4 /* TransparentButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransparentButton.swift; sourceTree = "<group>"; };
0AA7A1E11B8E7C9A0014FCF4 /* secondary_action.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = secondary_action.png; sourceTree = "<group>"; };
0AA7A1E21B8E7C9A0014FCF4 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
0AF2EE591BEFCA3000395313 /* automatic_versioning.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = automatic_versioning.sh; sourceTree = "<group>"; };
14042A5C9B757E5A202DEC29 /* Pods-Kodi Remote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kodi Remote.release.xcconfig"; path = "Pods/Target Support Files/Pods-Kodi Remote/Pods-Kodi Remote.release.xcconfig"; sourceTree = "<group>"; };
20E51806F2D31FE52785684C /* Pods-Kodi Remote.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kodi Remote.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Kodi Remote/Pods-Kodi Remote.debug.xcconfig"; sourceTree = "<group>"; };
52B2AE5329A537DA9172082B /* Pods_Kodi_Remote.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Kodi_Remote.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -129,6 +135,7 @@
0A016C491AC36C3C00590E32 /* Resources */ = {
isa = PBXGroup;
children = (
0A2A1BA61BEFD6A700587FAE /* Strings */,
0A016C4A1AC36C4600590E32 /* Imgs */,
);
path = Resources;
Expand Down Expand Up @@ -168,9 +175,19 @@
path = Views;
sourceTree = "<group>";
};
0A2A1BA61BEFD6A700587FAE /* Strings */ = {
isa = PBXGroup;
children = (
0A524BF41BF00A750095740C /* APIKeys.plist */,
0A2A1BA71BEFD6A700587FAE /* ProjectTexts.strings */,
);
path = Strings;
sourceTree = "<group>";
};
0A3F9EEA1AC0C2BC008C6A4E = {
isa = PBXGroup;
children = (
0AF2EE591BEFCA3000395313 /* automatic_versioning.sh */,
0A3F9EF51AC0C2BC008C6A4E /* Kodi Remote */,
0A3F9F0B1AC0C2BC008C6A4E /* Kodi RemoteTests */,
0A3F9EF41AC0C2BC008C6A4E /* Products */,
Expand Down Expand Up @@ -321,7 +338,8 @@
F2C8BBF503771874FFF16E09 /* Embed Pods Frameworks */,
F2B7443FE76BCECC014B3414 /* Copy Pods Resources */,
0A71771E1B55B149000CA6E0 /* Embed Frameworks */,
0AC0E3181B62D4EB003D940C /* ShellScript */,
0AC0E3181B62D4EB003D940C /* Run script: Fabric */,
0AF2EE581BEFC9D600395313 /* Run Script: Automatic Versioning */,
);
buildRules = (
);
Expand Down Expand Up @@ -374,10 +392,13 @@
0AA7A1E31B8E7C9A0014FCF4 /* secondary_action.png in Resources */,
0AA7A1D81B8E749E0014FCF4 /* [email protected] in Resources */,
0AA7A1D11B8E749E0014FCF4 /* back.png in Resources */,
0A2A1BA81BEFD6A700587FAE /* ProjectTexts.strings in Resources */,
0AA7A1D41B8E749E0014FCF4 /* [email protected] in Resources */,
0A3F9F001AC0C2BC008C6A4E /* Images.xcassets in Resources */,
0AA7A1D21B8E749E0014FCF4 /* [email protected] in Resources */,
0AF2EE5A1BEFCA3000395313 /* automatic_versioning.sh in Resources */,
0AA7A1DE1B8E749E0014FCF4 /* [email protected] in Resources */,
0A524BF51BF00A750095740C /* APIKeys.plist in Resources */,
0AA7A1DB1B8E749E0014FCF4 /* right.png in Resources */,
0AA7A1D61B8E749E0014FCF4 /* [email protected] in Resources */,
0AA7A1DC1B8E749E0014FCF4 /* [email protected] in Resources */,
Expand All @@ -395,19 +416,34 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0AC0E3181B62D4EB003D940C /* ShellScript */ = {
0AC0E3181B62D4EB003D940C /* Run script: Fabric */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run script: Fabric";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "./Fabric.framework/run 887247ff2f9ad003c64692515d957f39c279b45f 7e55f8835ec9d902cac6fb40edde02b6b3912de2e4f9793f4c932d9a210c9a4b";
};
0AF2EE581BEFC9D600395313 /* Run Script: Automatic Versioning */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script: Automatic Versioning";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = ./automatic_versioning.sh;
};
D2C7D2BD8DD1684C4401C13D /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
24 changes: 21 additions & 3 deletions Kodi Remote/Kodi Remote/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Cocoa
import XCGLogger
import Fabric
import Crashlytics
import Parse

let log = XCGLogger.defaultInstance()

Expand All @@ -18,12 +19,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(aNotification: NSNotification) {
log.setup(.Debug, showLogLevel: true, showFileNames: true, showLineNumbers: true)

// SDKs
Fabric.with([Crashlytics.self])

if let path = NSBundle.mainBundle().pathForResource("APIKeys", ofType: "plist") {

if let keys = NSDictionary(contentsOfFile: path) {
let applicationId = keys["parseApplicationId"] as? String
let clientKey = keys["parseClientKey"] as? String

// Initialize Parse.
Parse.setApplicationId(applicationId!, clientKey: clientKey!)
PFAnalytics.trackAppOpenedWithLaunchOptions(nil)

}

}

}

func applicationWillTerminate(aNotification: NSNotification) {

}

}

2 changes: 1 addition & 1 deletion Kodi Remote/Kodi Remote/Controllers/WindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WindowController : NSWindowController {

override func windowDidLoad() {

self.window?.title = "Kodi Remote"
self.window?.title = NSLocalizedString("AppTitle", comment: "")
self.window?.titlebarAppearsTransparent = true
self.window?.movableByWindowBackground = true
self.window?.backgroundColor = NSColor.blackColor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SettingsViewController : NSViewController {
}else{

let alertMessage:NSAlert = NSAlert()
alertMessage.messageText = "Ooops!"
alertMessage.messageText = NSLocalizedString("error_title", comment: "")
alertMessage.informativeText = formValidationResult.errorMessage as String
alertMessage.runModal()

Expand All @@ -98,12 +98,12 @@ extension SettingsViewController{

if (!isValidUrl(txtUrl.stringValue)){
log.debug("Invalid URL")
return (false, "You must enter a valid URL, starting with http")
return (false, NSLocalizedString("error_invalid_url", comment: ""))
}

if (!txtPort.stringValue.isEmpty && !isValidNumber(txtPort.stringValue)){
log.debug("Invalid port")
return (false, "You must enter a valid port number")
return (false, NSLocalizedString("error_invalid_port", comment: ""))
}


Expand Down
1 change: 1 addition & 0 deletions Kodi Remote/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ target 'Kodi Remote' do
pod 'Box', '~> 2.0'
pod 'Result', '0.6.0-beta.6'
pod 'XCGLogger', '~> 3.0'
pod 'Parse', '~> 1.9'
end
6 changes: 6 additions & 0 deletions Kodi Remote/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
PODS:
- Alamofire (3.1.2)
- Bolts/Tasks (1.4.0)
- Box (2.0)
- Parse (1.9.1):
- Bolts/Tasks (>= 1.4.0)
- Result (0.6.0-beta.6)
- SwiftyJSON (2.3.1)
- XCGLogger (3.0)

DEPENDENCIES:
- Alamofire (~> 3.1.2)
- Box (~> 2.0)
- Parse (~> 1.9)
- Result (= 0.6.0-beta.6)
- SwiftyJSON (~> 2.3.1)
- XCGLogger (~> 3.0)

SPEC CHECKSUMS:
Alamofire: 7c16ca65f3c7e681fd925fd7f2dec7747ff96855
Bolts: 0e9bce58b9b9f5e8a7a4d47b16d2fabec289072b
Box: 70713ca3679e4e11ad4c470e9b58265f506fc659
Parse: 54a965c8c19a6dde90284ab654dbcc77ef8c001b
Result: dc390d0b58f9ec43fcd536f1ebdd130803cc6cbc
SwiftyJSON: 592b53bee5ef3dd9b3bebc6b9cb7ee35426ae8c3
XCGLogger: 5802533aff8bafc8b3b9776ab8972576f31d0a4e
Expand Down
10 changes: 10 additions & 0 deletions Kodi Remote/Resources/Strings/APIKeys.example.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>parseApplicationId</key>
<string>1234</string>
<key>parseClientKey</key>
<string>5678</string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions Kodi Remote/Resources/Strings/ProjectTexts.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
ProjectTexts.strings
Kodi Remote

Created by Adrián Moreno Peña on 08/11/15.
Copyright © 2015 Nyan Software. All rights reserved.
*/
"AppTitle" = "Kodi Remote";

97 changes: 97 additions & 0 deletions Kodi Remote/automatic_versioning.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash

# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.

#
# Check if a variable is set
# param1 name of the variable
#
function is_set()
{
[[ -n "${1}" ]] && test -n "$(eval "echo "\${${1}+x}"")"
}

set -o errexit
set -o nounset

# First, check for git in $PATH
hash git 2>/dev/null || { echo >&2 "Git required, not installed. Aborting build number update script."; exit 0; }

# Alternatively, we could use Xcode's copy of the Git binary,
# but old Xcodes don't have this.
#GIT=$(xcrun -find git)

# Run Script build phases that operate on product files of the target that defines them should use the value of this build setting [TARGET_BUILD_DIR]. But Run Script build phases that operate on product files of other targets should use “BUILT_PRODUCTS_DIR” instead.
INFO_PLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

# Build version (closest-tag-or-branch "-" commits-since-tag "-" short-hash dirty-flag)
BUILD_VERSION=$(git describe --tags --always --dirty=+)

# Use the latest tag for short version (expected tag format "vn[.n[.n]]")
# or if there are no tags, we make up version 0.0.<commit count>
LATEST_TAG=$(git describe --tags --match 'v*' --abbrev=0 2>/dev/null) || LATEST_TAG="HEAD"
if [ $LATEST_TAG = "HEAD" ]
then COMMIT_COUNT=$(git rev-list --count HEAD)
LATEST_TAG="0.0.$COMMIT_COUNT"
COMMIT_COUNT_SINCE_TAG=0
else
COMMIT_COUNT_SINCE_TAG=$(git rev-list --count ${LATEST_TAG}..)
LATEST_TAG=${LATEST_TAG##v} # Remove the "v" from the front of the tag
fi
if [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then
SHORT_VERSION="$LATEST_TAG"
else
# increment final digit of tag and append "d" + commit-count-since-tag
# e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1
# this is the bit that requires /bin/bash
OLD_IFS=$IFS
IFS="."
VERSION_PARTS=($LATEST_TAG)
LAST_PART=$((${#VERSION_PARTS[@]}-1))
#VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))
#echo "VERSION_PARTS_LAST_PART: $VERSION_PARTS[$LAST_PART]"

SHORT_VERSION="${VERSION_PARTS[*]}.d${COMMIT_COUNT_SINCE_TAG}"
echo "SHORT_VERSION: $SHORT_VERSION"

IFS=$OLD_IFS
fi



# Bundle version (commits-on-master[-until-branch "." commits-on-branch])
# Assumes that two release branches will not diverge from the same commit on master.
if [ $(git rev-parse --abbrev-ref HEAD) = "$(git rev-parse --abbrev-ref HEAD)" ]; then
MASTER_COMMIT_COUNT=$(git rev-list --count HEAD)
BRANCH_COMMIT_COUNT=0
BUNDLE_VERSION="$MASTER_COMMIT_COUNT"
else
MASTER_COMMIT_COUNT=$(git rev-list --count $(git rev-list master.. | tail -n 1)^)
BRANCH_COMMIT_COUNT=$(git rev-list --count master..)
if [ $BRANCH_COMMIT_COUNT = 0 ]
then BUNDLE_VERSION="$MASTER_COMMIT_COUNT"
else BUNDLE_VERSION="${MASTER_COMMIT_COUNT}.${BRANCH_COMMIT_COUNT}"
fi
fi

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BUILD_VERSION+=".$CURRENT_BRANCH"
SHORT_VERSION+=".$CURRENT_BRANCH"

# For debugging:
echo "AUTOVERSION - BUILD VERSION: $BUILD_VERSION"
echo "AUTOVERSION - CURRENT BRANCH: $CURRENT_BRANCH"
echo "AUTOVERSION - LATEST_TAG: $LATEST_TAG"
echo "AUTOVERSION - COMMIT_COUNT_SINCE_TAG: $COMMIT_COUNT_SINCE_TAG"
echo "AUTOVERSION - SHORT VERSION: $SHORT_VERSION"
echo "AUTOVERSION - MASTER_COMMIT_COUNT: $MASTER_COMMIT_COUNT"
echo "AUTOVERSION - BRANCH_COMMIT_COUNT: $BRANCH_COMMIT_COUNT"
echo "AUTOVERSION - BUNDLE_VERSION: $BUNDLE_VERSION"

/usr/libexec/PlistBuddy -c "Add :CFBundleBuildVersion string $BUILD_VERSION" "$INFO_PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Set :CFBundleBuildVersion $BUILD_VERSION" "$INFO_PLIST"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $SHORT_VERSION" "$INFO_PLIST"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUNDLE_VERSION" "$INFO_PLIST"

0 comments on commit e68fe02

Please sign in to comment.