[
https://issues.apache.org/jira/browse/CB-9825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15373433#comment-15373433
]
ASF GitHub Bot commented on CB-9825:
------------------------------------
Github user juliascript commented on a diff in the pull request:
https://github.com/apache/cordova-ios/pull/234#discussion_r70496395
--- 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) {
+ podMod.installPodSync(project_name, project_path,
nameOfPod, obj.spec, pods_file);
+ events.emit('verbose', 'About to add ' + nameOfPod + '
to pods json');
+ callback();
+ }
+
+ //write out updated pods.json,
+ // keep track of the order of the pods
+ function addToPodsJSON () {
+ try {
+ fs.writeFileSync(pods_file, JSON.stringify(pods,
null, 4));
+ } catch (e) {
+ throw new CordovaError('\nPod was not able to be
added to pods.json in Api.js\n\n' + e);
+ }
+ }
+
+ if (podIsAlreadyInPodfile) {
+ addToPodsJSON();
+ } else if (!podIsAlreadyInPodfile) {
+ //add the pods to the Podfile, then add to pods.json
+ addToPodfile(addToPodsJSON);
--- End diff --
👍 Thanks!
> Support third-party package managers like Cocoapods and Nuget
> -------------------------------------------------------------
>
> Key: CB-9825
> URL: https://issues.apache.org/jira/browse/CB-9825
> Project: Apache Cordova
> Issue Type: New Feature
> Components: CordovaLib
> Reporter: Shazron Abdullah
> Assignee: Julia Geist
> Labels: cordova-ios-5.0.x
>
> ML discussion:
> http://markmail.org/message/5qvg6rwr4nz4q7mc
> cordova-discuss proposal (to be brought back to the list when finalized):
> https://github.com/cordova/cordova-discuss/blob/master/proposals/ThirdPartyPackageManagers.md
> From Steve Gill in the ML:
> At the Cordova F2F, everyone seemed to agree that we should bring CocoaPods
> support to plugins as dependencies for iOS.
> Cordova-android currently uses Gradle as a way to enable external
> dependency resolution for plugins using the framework tag.
> A suggestion about using the engine tag to fetch cocoapods-cli (mac) &
> NuGet (windows) followed by using the framework tag was discussed.
> The minutes[1] show Carlos, Shaz and Raghav as looking into the design.
> Someone should write up a proposal on cordova-discuss[2] and create the
> issues. Post them in this thread.
> This shouldn't take priority over cordova-ios 4 issues.
> [1]
> https://docs.google.com/document/d/1MArKRmnLS052LBbhPxJF57_4ZivghOj8znWo5sTCkbU/edit?usp=sharing
> [2] https://github.com/cordova/cordova-discuss
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]