From 964fd0f109382de243a925575161da9c20137e96 Mon Sep 17 00:00:00 2001 From: Oliver Ochs Date: Mon, 10 Jul 2017 14:26:38 +0200 Subject: [PATCH] Upgraded path to NS 3.1.2: https://github.com/Essent/nativescript-custom-entitlements/issues/6 --- README.md | 7 ++++--- demo/package.json | 5 +++-- lib/after-prepare.js | 28 +++++++++++++------------- lib/before-prepare.js | 46 +++++++++++++++++++++---------------------- package.json | 7 +++++-- 5 files changed, 49 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 34f7408..0a57c80 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,12 @@ npm run demo.ios ## Check entitlements ```bash +# change package.json to create a bundle identifier that can be signed by your organization npm run setup npm run resetdemo cd demo tns build ios --for-device -cp demo/platforms/ios/build/device/demo.ipa build/demo/platforms/ios/build/device/demo.zip -unzip demo/platforms/ios/build/device/demo.zip -d demo/platforms/ios/build/device/ -codesign -d --entitlements :- "demo/platforms/ios/build/device/Payload/demo.app" +cp ./platforms/ios/build/device/demo.ipa ./platforms/ios/build/device/demo.zip +unzip ./platforms/ios/build/device/demo.ipa -d ./platforms/ios/build/device/ +codesign -d --entitlements :- "./platforms/ios/build/device/Payload/demo.app" ``` diff --git a/demo/package.json b/demo/package.json index f8baa6a..347b65b 100755 --- a/demo/package.json +++ b/demo/package.json @@ -6,13 +6,14 @@ "nativescript": { "id": "org.nativescript.demo", "tns-android": { - "version": "2.4.1" + "version": "3.1.1" }, "tns-ios": { - "version": "2.4.0" + "version": "3.1.0" } }, "dependencies": { + "nativescript-custom-entitlements": "file:///Users/simonox/igefa/nativescript-custom-entitlements", "tns-core-modules": "2.3.0" }, "devDependencies": { diff --git a/lib/after-prepare.js b/lib/after-prepare.js index 0c9e32f..a32df7e 100644 --- a/lib/after-prepare.js +++ b/lib/after-prepare.js @@ -2,21 +2,21 @@ var fs = require('fs-promise'); var path = require('path'); module.exports = function (logger, platformsData, projectData, hookArgs) { - var platform = hookArgs.platform.toLowerCase(); + var platform = hookArgs.platform.toLowerCase(); - if (platform == 'ios') { - var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; - var entitlementsFile = path.join(appResourcesDirectoryPath, 'iOS', 'app.entitlements'); - var projectRoot = path.join(projectData.platformsDir, 'ios'); - var project = path.join(projectRoot, projectData.projectName); - var dest = path.join(project, projectData.projectName + '.entitlements'); + if (platform == 'ios') { + var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; + var entitlementsFile = path.join(appResourcesDirectoryPath, 'iOS', 'app.entitlements'); + var projectRoot = path.join(projectData.platformsDir, 'ios'); + var project = path.join(projectRoot, projectData.projectName); + var dest = path.join(project, projectData.projectName + '.entitlements'); - return fs.copy(entitlementsFile, dest) - .then(function () { - logger.out('Copied `' + entitlementsFile + '` to `' + dest + '`'); - }); - } + return fs.copy(entitlementsFile, dest) + .then(function () { + logger.out('Copied `' + entitlementsFile + '` to `' + dest + '`'); + }); + } - logger.info('Only iOS'); - return Promise.resolve(); + logger.info('Only iOS'); + return Promise.resolve(); }; diff --git a/lib/before-prepare.js b/lib/before-prepare.js index 8e39575..334ca67 100644 --- a/lib/before-prepare.js +++ b/lib/before-prepare.js @@ -2,29 +2,29 @@ var fs = require('fs-promise'); var path = require('path'); module.exports = function (logger, platformsData, projectData, hookArgs) { - var platform = hookArgs.platform.toLowerCase(); + var platform = hookArgs.platform.toLowerCase(); - if (platform == 'ios') { - var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; - var platformResourcesDirectory = path.join(appResourcesDirectoryPath, 'iOS'); - var target = path.join(platformResourcesDirectory, 'build.xcconfig'); + if (platform == 'ios') { + var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; + var platformResourcesDirectory = path.join(appResourcesDirectoryPath, 'iOS'); + var target = path.join(platformResourcesDirectory, 'build.xcconfig'); - return fs.readFile(target) - .then(function (data) { - return data.toString(); - }) - .then(function (buildData) { - if (!buildData.toString().match(/^\s*CODE_SIGN_ENTITLEMENTS/mg)) { - var entitlementsFile = projectData.projectName + '.entitlements'; - var entitlementsPath = path.join(projectData.projectName, entitlementsFile); - var codeSignProp = '\nCODE_SIGN_ENTITLEMENTS = ' + entitlementsPath; - logger.info('Add code sign prop: ' + codeSignProp); - return fs.appendFile(target, codeSignProp); - } - logger.warn('CODE_SIGN_ENTITLEMENTS already added'); - }); - } - logger.info('Only iOS'); - // skip android - return Promise.resolve(); + return fs.readFile(target) + .then(function (data) { + return data.toString(); + }) + .then(function (buildData) { + if (!buildData.toString().match(/^\s*CODE_SIGN_ENTITLEMENTS/mg)) { + var entitlementsFile = projectData.projectName + '.entitlements'; + var entitlementsPath = path.join(projectData.projectName, entitlementsFile); + var codeSignProp = '\nCODE_SIGN_ENTITLEMENTS = ' + entitlementsPath; + logger.info('Add code sign prop: ' + codeSignProp); + return fs.appendFile(target, codeSignProp); + } + logger.warn('CODE_SIGN_ENTITLEMENTS already added'); + }); + } + logger.info('Only iOS'); + // skip android + return Promise.resolve(); }; diff --git a/package.json b/package.json index 603913c..2772837 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-custom-entitlements", - "version": "0.2.0", + "version": "0.3.0", "description": "Nativescript hook for supporting custom Xcode 8 entitlements", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", @@ -40,7 +40,10 @@ "script": "lib/after-prepare.js", "inject": true } - ] + ], + "tns-ios": { + "version": "3.1.0" + } }, "dependencies": { "fs-promise": "^2.0.0",