schlusslicht opened a new issue #1108:
URL: https://github.com/apache/cordova-ios/issues/1108


   First of all, let me thank You for all Your awesome work on this project! 
Furthermore, I would have issued a pull request, if I were sure, I had the 
appropriate fix for this issue. But as it regards regex-matching, I think my 
(local) quickfix would not be up to Your standards.
   
   ### Issue Type
   - [x] Bug Report
   - [ ] Feature Request
   - [ ] Support Question
   
   ## Description
   The `cordova-ios` Podfile generation fails, when multiple Pods are required 
for installation and the `PROJECT_NAME` includes apostrophes, due to the 
[`declarationsPostRE`](https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/Podfile.js#L81)
 not matching against the [escaped 
`PROJECT_NAME`](https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/Podfile.js#L169-L171).
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   ### Command or Code
   1. in the `config.xml` of Your project declare `<name>Rock'n'Roll</name>` 
(any name with one or more apostrophes)
   2. run `cordova platform add ios` on the respective project, that contains 
one or more apostrophes in its name
   3. the 
[`declarationsPostRE`](https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/Podfile.js#L81)
 regex [does not match](https://regexr.com/5t36o) (the line gets escaped to 
`target 'Rock\'n\'Roll' do`)
   4. the resulting Podfile contains multiple `target 'Rock\'n\'Roll' do` 
declarations which triggers
   5. the spawned command [`pod install 
--verbose`](https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/Podfile.js#L400)
 to fail with `The target is declared multiple times`
   
   ### Quickfix
   Edit the 
[`declarationsPostRE`](https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/lib/Podfile.js#L81):
   ```patch
   diff --git a/Podfile.js b/Podfile.js
   index f167297..5daf8bc 100644
   --- a/Podfile.js
   +++ b/Podfile.js
   @@ -78,7 +78,7 @@ Podfile.prototype.__parseForDeclarations = function (text) 
{
    
        // getting lines between "platform :ios, '11.0'"" and "target 
'HelloCordova'" do
        const declarationsPreRE = new RegExp('platform :ios,\\s+\'[^\']+\'');
   -    const declarationsPostRE = new RegExp('target\\s+\'[^\']+\'\\s+do');
   +    const declarationsPostRE = new RegExp('target\\s+\'.+?\'\\s+do');
        const declarationRE = new RegExp('^\\s*[^#]');
    
        return arr.reduce((acc, line) => {
   ```
   
   ### Environment, Platform, Device
   I think this issue is not tied to any specific environment/device. For my 
stack, see below.
   
   ### Version information
   **Operating System**
   > MacOS X Catalina 10.15.7 (Darwin Kernel 19.6.0)
   
   **IDE**
   > Xcode 12.1 (12A7403)
   
   **node/npm**
   > node 14.16.0
   > npm 6.14.11
   
   **package.json** (relevant entries)
   > "cordova": "10.0.0"
   > "cordova-ios": "6.2.0"
   > "cordova-plugin-firebase-analytics": "5.0.0"
   > "cordova-plugin-firebase-messaging": "5.0.1"
   
   *(Both plugins require a pod to be installed.)*
   
   ## Checklist
   - [x] I searched for already existing GitHub issues about this
   - [x] I updated all Cordova tooling to their most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to