Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 08465200B58 for ; Wed, 13 Jul 2016 01:35:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 06D11160A75; Tue, 12 Jul 2016 23:35:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 50E2A160A56 for ; Wed, 13 Jul 2016 01:35:47 +0200 (CEST) Received: (qmail 49552 invoked by uid 500); 12 Jul 2016 23:35:46 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 49540 invoked by uid 99); 12 Jul 2016 23:35:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2016 23:35:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1434CDFF68; Tue, 12 Jul 2016 23:35:45 +0000 (UTC) From: juliascript To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-ios pull request #234: CB-9825 cocoapod integration for plugins Content-Type: text/plain Message-Id: <20160712233546.1434CDFF68@git1-us-west.apache.org> Date: Tue, 12 Jul 2016 23:35:45 +0000 (UTC) archived-at: Tue, 12 Jul 2016 23:35:48 -0000 Github user juliascript commented on a diff in the pull request: https://github.com/apache/cordova-ios/pull/234#discussion_r70541974 --- Diff: bin/templates/scripts/cordova/lib/podMod.js --- @@ -0,0 +1,162 @@ +var fs = require('fs'); +var util = require('util'); +var events = require('cordova-common').events; +var superspawn = require('cordova-common').superspawn; +var CordovaError = require('cordova-common').CordovaError; +var opts = {}; +/* +-- After pods are installed in a .xcworkspace, all existing ios code needs to go into the WORKSPACE file -- will need to + create a workspace file and then embed the Xcode project + + - Holly might have done some work on this, see the docs: + https://github.com/phonegap/phonegap-webview-ios not sure how applicable it can be to our case +*/ +function removeProjectFromPath (pathToProjectFile) { + var array = []; + //remove the project from the path + array = pathToProjectFile.split('/'); + array.pop(); + var path = array.join('/'); + return path; +} + +function createPodfile (projectName, pathToProjectFile) { + var path = removeProjectFromPath(pathToProjectFile); + var pathToPodfile = path + '/Podfile'; + var podfileText = util.format('platform :ios, \'8.0\'\n\ntarget \'%s\' do\n\n project \'%s\'\n\n \n\nend' , projectName, pathToProjectFile); + fs.writeFileSync(pathToPodfile, podfileText); +} + +function editPodfileSync (Podfile, pod, isRemoval) { + var podfileContents = fs.readFileSync(Podfile, 'utf8'); + //split by \n, add in the pod after the project line, shift the rest down + var podfileContentsArray = podfileContents.split('\n'); + var linesInPodfileToKeep = []; + + if (isRemoval) { + podfileContentsArray.forEach (function (lineInPodfile) { + //if the line in Podfile is the pod to rm, don't save it to new array (to be returned) + if (!lineInPodfile.includes(pod)){ + linesInPodfileToKeep.push(lineInPodfile); + } + }); + podfileContents = linesInPodfileToKeep.join('\n'); + } else { + podfileContentsArray.splice(5, 0, pod); --- End diff -- 5 is the line in the Podfile that I am injecting the new pod. Added a var to improve readability. --- 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