Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ In a plugin's plugin.xml
<dependency id="cordova-plugin-cocoapod-support"/>

<platform name="ios">
<!-- optionally set minimum ios version and enable use_frameworks! -->
<pods-config ios-min-version="9.0" uses-frameworks="true"/>
<!-- optionally set minimum ios version, enable use_frameworks! and enable legacy swift (2.3)-->
<pods-config ios-min-version="9.0" use-frameworks="true" use-legacy="true"/>
<pod id="LatestPod" />
<pod id="VersionedPod" version="1.0.0" />
<pod id="GitPod1" git="https://github.com/blakgeek/something" tag="v1.0.1" configuration="debug" />
Expand Down Expand Up @@ -94,6 +94,8 @@ or have a look at [the demo plugin](https://github.com/blakgeek/cordova-plugin-w
* Enabling the pods_use_frameworks preference disables the bridged headers property added by
[CB-10072](https://issues.apache.org/jira/browse/CB-10072). This might cause odd behavior in some projects.

* If legacy is not used for swift the default version will be 3.0


##TODO:
* Update with examples of all of the supported pod attributes (git, podspec, path, subspec, configuration(s) )
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<plugin id="cordova-plugin-cocoapod-support" version="1.2.10" xmlns="http://apache.org/cordova/ns/plugins/1.0">
<plugin id="cordova-plugin-cocoapod-support" version="1.2.11" xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>Cordova CocoaPods Dependency Support</name>
<author>Carlos "blakgeek" Lawton</author>
<description>A Cordova/PhoneGap plugin to add support for CocoaPods dependencies.</description>
Expand Down
32 changes: 32 additions & 0 deletions scripts/podify.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = function (context) {
var schemesSrcDir = path.join(pluginDir, 'schemes');
var schemesTargetDir = path.join(sharedDataDir, 'xcschemes');
var bundlePathsToFix = [];
var useLegacy;
var newPods = {
pods: {}
};
Expand All @@ -43,6 +44,7 @@ module.exports = function (context) {
.then(createFiles)
.then(installPods)
.then(fixBundlePaths)
.then(fixSwiftLegacy)
.then(updateBuild);

function parseConfigXml() {
Expand All @@ -63,6 +65,12 @@ module.exports = function (context) {
});
}

function getDirectories(srcpath) {
return fs.readdirSync(srcpath).filter(function(file) {
return fs.statSync(path.join(srcpath, file)).isDirectory();
});
}

function parsePluginXmls() {

var promises = [];
Expand All @@ -85,6 +93,7 @@ module.exports = function (context) {
if(podsConfig) {
iosMinVersion = maxVer(iosMinVersion, podsConfig.$['ios-min-version']);
useFrameworks = podsConfig.$['use-frameworks'] === 'true' ? 'true' : useFrameworks;
useLegacy = podsConfig.$['use-legacy'] === 'true' ? '2.3' : '3.0';
}
(platform.pod || []).forEach(function (pod) {
newPods.pods[pod.$.id] = pod.$;
Expand Down Expand Up @@ -238,6 +247,29 @@ module.exports = function (context) {
return shouldRun;
}


function fixSwiftLegacy(shouldRun){
var directories = getDirectories(path.join(__dirname + '/../../../platforms/ios/Pods/Target Support Files')),
podXcContents,
SWIFT_VERSION_REGX = /SWIFT_VERSION=(?:\d*\.)\d/g;
if(useLegacy){
for(var i = 0; i < directories.length; i++){
if(directories[i].indexOf(appName) === -1){
podXcContents = fs.readFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', 'utf8');
if(podXcContents.indexOf('SWIFT_VERSION') === -1){
fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents + '\n' + 'SWIFT_VERSION=' + useLegacy)
} else {
fs.writeFileSync('platforms/ios/Pods/Target Support Files/' + directories[i] + '/' + directories[i] + '.xcconfig', podXcContents.replace(SWIFT_VERSION_REGX, 'SWIFT_VERSION=' + useLegacy))
}
}
}

console.log('Using Swift Version ' + useLegacy);
}

return shouldRun;
}

function updateBuild(shouldRun) {

if(shouldRun) {
Expand Down