NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 196 forks source link

Invalid `Podfile` file: syntax error, unexpected keyword_end #4760

Open NgxDev opened 5 years ago

NgxDev commented 5 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

target 'MyTarget' do pod 'TwilioChatClient', '~> 2.4.2' end

- replace `MyTarget` with `demo`
- in 2 terminal windows, both in `_plugins/nativescript-version-number/src`, run:
- `npm run plugin.tscwatch`
- `npm run demo.ios`

Result: `[!] Invalid 'Podfile' file: syntax error, unexpected keyword_end, expecting end-of-input.`
The generated Podfile (`_plugins/nativescript-version-number/demo/platforms/ios/Podfile`) looks like this:

use_frameworks!

target "demo" do end

end

Begin Podfile - /www/plugin-test/_plugins/nativescript-version-number/demo/node_modules/nativescript-twilio-chat/platforms/ios/Podfile

source 'https://github.com/CocoaPods/Specs'

target 'demo' do pod 'TwilioChatClient', '~> 2.4.2' end

End Podfile

end

Removing the `end` in my Podfile, I still get the same error (and just one less `end` in the resulting Podfile).
At one point I even got a `Duplicate target "demo"` error, so I even tried removing the line `target 'demo' do` line from my Podfile, but still no luck, still got the `[!] Invalid 'Podfile' file: syntax error, unexpected keyword_end, expecting end-of-input.` error.
Even if I delete all content from my Podfile, to have it empty, I still get a bad resulting Podfile:

use_frameworks!

target "demo" do end

end

Begin Podfile - /www/plugin-testt/_plugins/nativescript-version-number/demo/node_modules/nativescript-twilio-chat/platforms/ios/Podfile

End Podfile

end

VladimirAmiorkov commented 5 years ago

Hi @MrCroft ,

I have moved this issue to the nativescript-cli repository as it is related to its functionality rather than the plugin seed itself.

rosen-vladimirov commented 5 years ago

Hey @MrCroft , Thanks for reporting this unexpected behavior. We've investigated it on our side and we've successfully reproduced it with your steps. The problem is that CLI does not expect to find target with project's name in any of the Podfiles

target 'MyTarget' do
  ...
end

CLI automatically creates this target and when it is already in one of the Podfiles, it fails to create correct Podfile. To workaround the issue, you can just remove the target line, i.e. replace:

target 'MyTarget' do
  pod 'TwilioChatClient', '~> 2.4.2'
end

with

pod 'TwilioChatClient', '~> 2.4.2'

After that remove your platforms dir and try building application again.

NgxDev commented 5 years ago

@rosen-vladimirov indeed, it works. I think I did also try with just having the pod declaration line in the Podfile, but the one thing I didn't do was to remove the platforms dir before anything else, after changing the plugin Podfile. Or maybe I still had the source '...' line in there, that came from the TwilioChatClient docs. Anyway, it does work with just having the pod declaration line. Thanks! And sorry for the trouble!