Skip to content

Instantly share code, notes, and snippets.

@ephemer
Last active August 29, 2015 14:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ephemer/b65d379d5a96237d186d to your computer and use it in GitHub Desktop.
Save ephemer/b65d379d5a96237d186d to your computer and use it in GitHub Desktop.
Add swift build options
// This file to be added to the <platform name="ios"> tag of your plugin.xml like this:
// <hook type="after_plugin_install" src="hooks/addSwiftOptions.js" />
var fs = require("fs");
module.exports = function (context) {
var projectRoot = context.opts.projectRoot;
var xcconfigPath = projectRoot + "/platforms/ios/cordova/build.xcconfig";
var pluginDir = context.opts.plugin.dir;
var srcDir = pluginDir + "/src/ios/";
var swiftOptions = [""]; // <-- begin to file appending AFTER initial newline
swiftOptions.push("IPHONEOS_DEPLOYMENT_TARGET = 7.0");
swiftOptions.push("SWIFT_OBJC_BRIDGING_HEADER = " + srcDir + "Bridging-Header.h");
fs.appendFileSync(xcconfigPath, swiftOptions.join('\n'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment