diff --git a/Gruntfile.js b/Gruntfile.js index 6da3084d7..88c336fd7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,13 +21,13 @@ module.exports = function(grunt) { command: 'cordova prepare android && cordova build android --release', }, build_ios_debug: { - command: 'cordova prepare ios && cordova build ios --debug --buildFlag="-UseModernBuildSystem=0"', + command: 'cordova prepare ios && cordova build ios --debug --buildFlag="-UseModernBuildSystem=0" --buildFlag="-scheme BETA"', options: { maxBuffer: 3200 * 1024 } }, build_ios_release: { - command: 'cordova prepare ios && cordova build ios --release --buildFlag="-UseModernBuildSystem=0"', + command: 'cordova prepare ios && cordova build ios --release --buildFlag="-UseModernBuildSystem=0" --buildFlag="-scheme Bitcoin.com Wallet"', options: { maxBuffer: 3200 * 1024 } diff --git a/app-template/annotate_icon.sh b/app-template/annotate_icon.sh new file mode 100755 index 000000000..49463a98e --- /dev/null +++ b/app-template/annotate_icon.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +#usage: ./annotate_icon.sh beta BETA 003eaa + +# Required command line parameters +FOLDER_NAME=$1 +#DEST_FOLDER_RELATIVE=../resources/bitcoin.com/ios/icon/$FOLDER_NAME +DEST_FOLDER_RELATIVE=../resources/bitcoin.com/ios/icon +DEST_ICON_MASTER=$DEST_FOLDER_RELATIVE/icon-1024.png +SOURCE_ICON='resources/ios/icon/icon-1024.png' + +mkdir $DEST_FOLDER_RELATIVE + +if [ -z "$3" ]; then + cp $SOURCE_ICON $DEST_ICON_MASTER +else + ICON_TEXT=$2 + HEX_COLOR=$3 + convert $SOURCE_ICON -gravity center -pointsize 144 -draw "fill '#$HEX_COLOR' rotate -45 rectangle -500,1035,500,1200" -draw "fill white font 'bitcoincom/fonts/ProximaNova-ExtraBold.otf' rotate -45 text 0,400 '$ICON_TEXT'" $DEST_ICON_MASTER +fi + +# iPhone Notifications +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 40x40 $DEST_FOLDER_RELATIVE/icon-40.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 60x60 $DEST_FOLDER_RELATIVE/icon-60.png + +# iPhone Settings +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 29x29 $DEST_FOLDER_RELATIVE/icon-29.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 58x58 $DEST_FOLDER_RELATIVE/icon-58.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 87x87 $DEST_FOLDER_RELATIVE/icon-87.png + +# iPhone Spotlight +# 40 - already done +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 80x80 $DEST_FOLDER_RELATIVE/icon-80.png + +# iPhone App, iOS 5, 6 +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 57x57 $DEST_FOLDER_RELATIVE/icon-57.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 114x114 $DEST_FOLDER_RELATIVE/icon-114.png + +# iPhone App, iOS 7+ +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 120x120 $DEST_FOLDER_RELATIVE/icon-120.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 180x180 $DEST_FOLDER_RELATIVE/icon-180.png + +# iPad Notifications +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 20x20 $DEST_FOLDER_RELATIVE/icon-20.png +# 40 - already done + +# iPad Settings +# 29 - already done +# 58 - already done + +# iPad Spotlight, iOS 7+ +# 40 - already done +# 80 - already done + +# iPad Spotlight, iOS 5, 6 +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 50x50 $DEST_FOLDER_RELATIVE/icon-50.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 100x100 $DEST_FOLDER_RELATIVE/icon-100.png + +# iPad App, iOS 5, 6 +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 72x72 $DEST_FOLDER_RELATIVE/icon-72.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 144x144 $DEST_FOLDER_RELATIVE/icon-144.png + +# iPad App, iOS 7+ +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 76x76 $DEST_FOLDER_RELATIVE/icon-76.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 152x152 $DEST_FOLDER_RELATIVE/icon-152.png + +# iPad Pro App +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 167x167 $DEST_FOLDER_RELATIVE/icon-167.png + +# Apple Watch Notification Centre +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 48x48 $DEST_FOLDER_RELATIVE/icon-48.png +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 55x55 $DEST_FOLDER_RELATIVE/icon-55.png + +# Apple Watch Companion Settings Notification Centre +# 58 - already done +# 87 - already done + +# Apple Watch +convert $DEST_FOLDER_RELATIVE/icon-1024.png -resize 88x88 $DEST_FOLDER_RELATIVE/icon-88.png \ No newline at end of file diff --git a/app-template/bitcoincom/BETA.xcscheme b/app-template/bitcoincom/BETA.xcscheme new file mode 100644 index 000000000..59bdd6fe3 --- /dev/null +++ b/app-template/bitcoincom/BETA.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app-template/bitcoincom/import_scheme.sh b/app-template/bitcoincom/import_scheme.sh new file mode 100755 index 000000000..4f6d31a96 --- /dev/null +++ b/app-template/bitcoincom/import_scheme.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Set to your project and scheme + +export PROJECT_FILE='../../platforms/ios/Bitcoin.com Wallet.xcodeproj' +export SCHEME='BETA.xcscheme' + +# Generate path to shared schemes folder + +export SCHEMES="$PROJECT_FILE"/xcshareddata/xcschemes + +cd "$(dirname "$0")" + +if [ ! -f "$SCHEMES/$SCHEME" ]; then + + # Create folder if necessary + mkdir -p "$SCHEMES" + + # Copy scheme + cp $SCHEME "$SCHEMES/$SCHEME" +fi \ No newline at end of file diff --git a/app-template/config-template.xml b/app-template/config-template.xml index f6f99a2e4..f370712a0 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -82,6 +82,7 @@ + diff --git a/app-template/create-ios-build-configurations.js b/app-template/create-ios-build-configurations.js new file mode 100644 index 000000000..f685eece8 --- /dev/null +++ b/app-template/create-ios-build-configurations.js @@ -0,0 +1,164 @@ +'use strict'; + +const assert = require('assert'); +const fs = require('fs'); + +console.log('******'); + +fs.readFile(__dirname + '/../platforms/ios/Bitcoin.com\ Wallet.xcodeproj/project.pbxproj', function onReadFile(err, data) { + if (err) { + throw err; + } + //console.log(data.toString()); + var contents = data.toString(); + //console.log('File was read.'); + getDebugConfigurations(contents); +}); + + +function addConfiguration(contents) { + +} + +function getBuildConfig(contents, idAndName) { + const idIndex = contents.indexOf(idAndName); + assert(idIndex); + + const buildConfigOpeningBracketIndex = contents.indexOf('{', idIndex); + const buildSettingsClosingBracketIndex = contents.indexOf('};', buildConfigOpeningBracketIndex + 1); + const buildConfigClosingBracketIndex = contents.indexOf('};', buildSettingsClosingBracketIndex + 1); + + const buildConfig = contents.substring( + buildConfigOpeningBracketIndex, + buildConfigClosingBracketIndex + 2 // To include trailing semicolon + ); + + return buildConfig; +} + +function insertBuildConfiguration(contents, buildConfiguration, idAndName) { + const buildConfigsEndDelimiter = '/* End XCBuildConfiguration section */'; + const buildConfigEndIndex = contents.indexOf(buildConfigsEndDelimiter); + assert(buildConfigEndIndex >= 0); + + const newConfig = ' ' + idAndName + ' = ' + buildConfiguration + '\n' + buildConfigsEndDelimiter; + const newContents = contents.replace(buildConfigsEndDelimiter, newConfig); + + /* + fs.writeFile(__dirname + '/../platforms/ios/Bitcoin.com\ Wallet.xcodeproj/project2.pbxproj', newContents, function onWriteFile(err) { + if(err) { + return console.log(err); + } + + console.log('project2.pbxproj was written'); + }); + */ + + try { + fs.writeFileSync(__dirname + '/../platforms/ios/Bitcoin.com\ Wallet.xcodeproj/project2.pbxproj', newContents); + } catch (e) { + console.log(e); + return; + } + return newContents; +} + +function renamedBuildConfig(buildConfig, newName) { + return buildConfig.replace('name = Debug', 'name = ' + newName); +} + +function getDebugConfiguration(contents, configContents, start, newName) { + + const buildConfigId = getDebugConfigurationId(contents, configContents, start); + assert(buildConfigId); + const buildConfig = getBuildConfig(contents, buildConfigId); + assert(buildConfig) + + const renamed = renamedBuildConfig(buildConfig, newName); + assert(renamed); + + return renamed; +} + +function getDebugConfigurationId(contents, configContents, start) { + //console.log('getDebugConfiguration() starting at: ' + start); + const subContents = configContents.substring(start); + //console.log('subContents: "' + subContents.substring(0, 200) + '"'); + + //const buildConfigsRegex = /[\s\S]+buildConfigurations = \(\s*([^\)]+)/; + const buildConfigsRegex = /.+buildConfigurations = \(\s*([^\)]+)/; + const buildConfigsExec = buildConfigsRegex.exec(subContents); + assert(buildConfigsExec.length === 2); + + const buildConfigsText = buildConfigsExec[1]; + //console.log('buildConfigsText: "' + buildConfigsText + '"'); + + const buildConfigLines = buildConfigsText.split(','); + let debugIdAndName = ''; + buildConfigLines.forEach(function onLine(line) { + if (line.indexOf(' Debug ') >= 0) { + debugIdAndName = line.trim(); + } + }); + + assert(debugIdAndName); + console.log('Debug build config ID:', debugIdAndName); + + //const PBXNativeTargetExistingBuildConfig = getBuildConfig(contents, PBXNativeTargetDebugIdAndName); + //console.log('PBXNativeTargetExistingBuildConfig:', PBXNativeTargetExistingBuildConfig); + return debugIdAndName; +} + + +function getDebugConfigurations(contents) { + + + //buildConfigurations = ( + // 1D6058940D05DD3E006BFB54 /* Debug */, + // DAD7F4DA21EEE6DC00135531 /* Task */, + // 1D6058950D05DD3E006BFB54 /* Release */, + //); + + const PBXNativeTargetConfigListBeginDelimiter = '/* Build configuration list for PBXNativeTarget'; + const PBXProjectConfigListBeginDelimiter = '/* Build configuration list for PBXProject'; + const XCConfigurationListBeginDelimiter = '/* Begin XCConfigurationList section */'; + + const newName = 'Dev'; + const PBXNativeTargetId = 'AAAAAAAAAAAAAAAAAAAAAAA1'; + const PBXProjectId = 'AAAAAAAAAAAAAAAAAAAAAAA2'; + const PBXNativeTargetIdAndName = PBXNativeTargetId + ' /* ' + newName + ' */'; + const PBXProjectIdAndName = PBXProjectId + ' /* ' + newName + ' */'; + + const configListIndex = contents.indexOf(XCConfigurationListBeginDelimiter); + const configContents = contents.substring(configListIndex); + + const PBXNativeTargetBuildConfigsIndex = configContents.indexOf(PBXNativeTargetConfigListBeginDelimiter); + const PBXProjectBuildConfigsIndex = configContents.indexOf(PBXProjectConfigListBeginDelimiter); + + const PBXNativeTargetBuildConfig = getDebugConfiguration(contents, configContents, PBXNativeTargetBuildConfigsIndex, newName); + const PBXProjectBuildConfig = getDebugConfiguration(contents, configContents, PBXProjectBuildConfigsIndex, newName); + + let newContents = insertBuildConfiguration(contents, PBXNativeTargetBuildConfig, PBXNativeTargetIdAndName); + newContents = insertBuildConfiguration(newContents, PBXProjectBuildConfig, PBXProjectIdAndName); + + const newConfigListIndex = newContents.indexOf(XCConfigurationListBeginDelimiter); + + const newPBXNativeTargetBuildConfigsIndex = newContents.indexOf(PBXNativeTargetConfigListBeginDelimiter, newConfigListIndex); + let configListEndIndex = newContents.indexOf(')', newPBXNativeTargetBuildConfigsIndex); + assert(configListEndIndex >= 0); + newContents = newContents.slice(0, configListEndIndex) + PBXNativeTargetIdAndName + ',\n ' + newContents.slice(configListEndIndex); + + const newPBXProjectBuildConfigsIndex = newContents.indexOf(PBXProjectConfigListBeginDelimiter, newConfigListIndex); + configListEndIndex = newContents.indexOf(')', newPBXProjectBuildConfigsIndex); + assert(configListEndIndex >= 0); + newContents = newContents.slice(0, configListEndIndex) + PBXProjectIdAndName + ',\n ' + newContents.slice(configListEndIndex); + + try { + fs.writeFileSync(__dirname + '/../platforms/ios/Bitcoin.com\ Wallet.xcodeproj/project2.pbxproj', newContents); + } catch (e) { + console.log(e); + return; + } + + +} \ No newline at end of file diff --git a/app-template/generate-build-resources.js b/app-template/generate-build-resources.js new file mode 100644 index 000000000..d03b85e13 --- /dev/null +++ b/app-template/generate-build-resources.js @@ -0,0 +1,103 @@ +#!/usr/bin/env node + +var shell = require('shelljs'); + +console.log('Annotating icon...'); +console.log('Checking installation of ImageMagick...'); +var convertExec = shell.exec('convert -version', { silent: true }); +if (convertExec.code !== 0) { + +} else { + console.log('ImageMagick found.'); +} + +var branchExec = shell.exec('git rev-parse --abbrev-ref HEAD', { silent: true }); + +if (branchExec.code !== 0) { + console.error('Failed to get branch name, exit code: ' + branchExec.code); + return; +} +var branch = branchExec.output.trim() +console.log('Branch: "' + branch + '"'); +var branchParts = branch.split('/'); + +var branchType = 'unknown'; +var branchNumber = ''; + +switch (branchParts.length) { + case 2: + if (branchParts[1] === 'dev') { + branchType = 'dev' + } + break; + case 3: + switch (branchParts[1]) { + case 'hotfix': + branchType = 'hotfix'; + branchNumber = branchParts[2]; + break; + case 'sprint': + branchType = 'sprint'; + branchNumber = branchParts[2]; + break; + case 'task': + branchType = 'task'; + branchNumber = branchParts[2]; + break; + default: + // nop + } + break; + default: + // nop +} + +// Override for debugging +//branchType = 'dev'; +//branchNumber = '26'; + +var buildVariant = ''; +var color = ''; +var iconText = ''; + +// Normal flow of colour +// Red -> Orange -> Green as build gets more solid +// task -> sprint -> dev +// Out of band fixes (hotfixes) are an out of band colour: blue + +// Treat unidentified branches as release. +switch (branchType) { + case 'dev': + buildVariant = 'dev'; + color = '004c03'; + iconText = 'DEV'; + break; + case 'hotfix': + buildVariant = 'hotfix'; + color = '003eaa'; + iconText = 'H' + branchNumber; + break; + case 'sprint': + buildVariant = 'sprint' + branchNumber; + color = 'c94900' + iconText = 'S' + branchNumber; + break; + case 'task': + buildVariant = 'task' + branchNumber; + color = 'a0001f' + iconText = branchNumber; + break; + default: + // Treat as release +} + +var annotateCommandLine = './annotate_icon.sh ' + buildVariant + ' ' + iconText + ' ' + color; +console.log('Annotate command line: "' + annotateCommandLine + '"'); +var annotateExec = shell.exec(annotateCommandLine); + +if (annotateExec.code !== 0) { + console.log('Failed to annotate the icon, exit code: ' + annotateExec.code); + return; +} + +console.log('Annotating icon complete.'); \ No newline at end of file diff --git a/app-template/resources/ios/icon/icon-1024.png b/app-template/resources/ios/icon/icon-1024.png new file mode 100644 index 000000000..2950ff8de Binary files /dev/null and b/app-template/resources/ios/icon/icon-1024.png differ