Skip to content

Commit

Permalink
Upgraded path to NS 3.1.2: Essent#6
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Ochs committed Jul 10, 2017
1 parent f9abfc5 commit 964fd0f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 44 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
5 changes: 3 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
28 changes: 14 additions & 14 deletions lib/after-prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
46 changes: 23 additions & 23 deletions lib/before-prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -40,7 +40,10 @@
"script": "lib/after-prepare.js",
"inject": true
}
]
],
"tns-ios": {
"version": "3.1.0"
}
},
"dependencies": {
"fs-promise": "^2.0.0",
Expand Down

0 comments on commit 964fd0f

Please sign in to comment.