Skip to content

Commit

Permalink
fixing travis
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Oct 23, 2016
1 parent 68ca59c commit 6821323
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode7.1
osx_image: xcode8
env:
- PATH=$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin
git:
Expand All @@ -13,4 +13,4 @@ install:
before_script:
- ios-sim start --devicetypeid=iPhone-6
script:
- cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR} --verbose
- FIX_PARAMEDIC=true cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR} --verbose
1 change: 0 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@

<!-- ios -->
<platform name="ios">
<hook type="after_plugin_install" src="hooks/add_swift_support.js" />
<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
<string>${EXECUTABLE_NAME} Would Like to Use Your Current Location Even In Background.</string>
</config-file>
Expand Down
69 changes: 69 additions & 0 deletions tests/hooks/fix-swift-paramedic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
var child_process = require('child_process'),
fs = require('fs'),
path = require('path');

module.exports = function(context) {
var COMMENT_KEY = /_comment$/,
CORDOVA_VERSION = process.env.CORDOVA_VERSION;

if (!process.env.FIX_PARAMEDIC) {
return;
}

run();

function run() {
var cordova_util = context.requireCordovaModule('cordova-lib/src/cordova/util'),
ConfigParser = CORDOVA_VERSION >= 6.0
? context.requireCordovaModule('cordova-common').ConfigParser
: context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'),
projectRoot = cordova_util.isCordova(),
platform_ios,
xml = cordova_util.projectConfig(projectRoot),
cfg = new ConfigParser(xml),
projectName = cfg.name(),
platform_ios = CORDOVA_VERSION < 5.0
? context.requireCordovaModule('cordova-lib/src/plugman/platforms')['ios']
: context.requireCordovaModule('cordova-lib/src/plugman/platforms/ios'),
iosPlatformPath = path.join(projectRoot, 'platforms', 'ios'),
iosProjectFilesPath = path.join(iosPlatformPath, projectName),
xcconfigPath = path.join(iosPlatformPath, 'cordova', 'build.xcconfig'),
xcconfigContent,
projectFile,
xcodeProject,
bridgingHeaderPath;

projectFile = platform_ios.parseProjectFile(iosPlatformPath);
xcodeProject = projectFile.xcode;


var configurations = nonComments(xcodeProject.pbxXCBuildConfigurationSection()),
config, buildSettings;

for (config in configurations) {
buildSettings = configurations[config].buildSettings;
buildSettings['SWIFT_VERSION'] = '2.3'
}
console.log('IOS project Swift Version changed to 2.3 ...');

projectFile.write();
}

function nonComments(obj) {
var keys = Object.keys(obj),
newObj = {},
i = 0;

for (i; i < keys.length; i++) {
if (!COMMENT_KEY.test(keys[i])) {
newObj[keys[i]] = obj[keys[i]];
}
}

return newObj;
}

function unquote(str) {
if (str) return str.replace(/^"(.*)"$/, "$1");
}
}
4 changes: 4 additions & 0 deletions tests/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@

<js-module src="tests.js" name="tests">
</js-module>

<platform name="ios">
<hook type="before_run" src="hooks/fix-swift-paramedic.js" />
</platform>
</plugin>

0 comments on commit 6821323

Please sign in to comment.