cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shazron <...@git.apache.org>
Subject [GitHub] cordova-ios pull request #234: CB-9825 cocoapod integration for plugins
Date Tue, 05 Jul 2016 03:56:13 GMT
Github user shazron commented on a diff in the pull request:

    https://github.com/apache/cordova-ios/pull/234#discussion_r69504555
  
    --- Diff: bin/templates/scripts/cordova/Api.js ---
    @@ -217,6 +214,90 @@ Api.prototype.addPlugin = function (plugin, installOptions) {
     
         return PluginManager.get(this.platform, this.locations, xcodeproj)
             .addPlugin(plugin, installOptions)
    +        .then(function() {
    +            var project_dir = this.locations.root;
    +            var project_path = this.locations.xcodeProjDir;
    +            var project_name = this.locations.xcodeCordovaProj.split('/').pop();
    +            var array_of_pod_objects = [];
    +            
    +            if (plugin.getFrameworks(this.platform).length === 0) return;
    +            events.emit('verbose', 'Looking into adding pods since the plugin contained
<framework>');
    +                    
    +            var pods_file = path.join(project_dir, 'pods.json');
    +            var pods = {};
    +            
    +            try {
    +                delete require.cache[require.resolve(pods_file)];
    +                pods = require(pods_file);
    +            } catch (e) { 
    +                /* no pods.json exists */ 
    +                // create an empty pods.json file 
    +                fs.writeFileSync(pods_file, JSON.stringify({}));
    +                delete require.cache[require.resolve(pods_file)];
    +                pods = require(pods_file);
    +            }  
    +
    +            var podMod = require('./lib/podMod');
    +            var frameworkTags = plugin.getFrameworks(this.platform);
    +
    +            // check if any of the framework tags are of type "podspec" 
    +            frameworkTags.forEach(function (obj) { 
    +                if (obj.type == 'podspec') {
    +                    array_of_pod_objects.push(obj);
    +                }
    +            });
    +
    +            var podIsAlreadyInPodfile;
    +            
    +            array_of_pod_objects.forEach(function (obj) {
    +                //check if pod already exists, if so if spec has changed 
    +                //if pods.json does not exist yet, create it
    +                // if it does not exist, only overwrite the type and spec, NOT the count
    +                var nameOfPod = obj.src;
    +
    +                if(!pods[nameOfPod]) {
    +                    pods[nameOfPod] = {'type': obj.type, 'spec': obj.spec};
    +                    podIsAlreadyInPodfile = false;
    +                } else {
    +                    pods[nameOfPod].type = obj.type;
    +                    pods[nameOfPod].spec = obj.spec;
    +                    podIsAlreadyInPodfile = true;
    +                }
    +
    +                // add a count incase multiple plugins depend on it.
    +                if (pods[nameOfPod].count) {
    +                    pods[nameOfPod].count = pods[nameOfPod].count + 1;
    +                } else {
    +                    pods[nameOfPod].count = 1;
    +                } 
    +            
    +                function addToPodfile (callback) {
    --- End diff --
    
    see corresponding note below. Function does not need a callback since the contents are
synchronous.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message