phonegap / phonegap-cli

PhoneGap and PhoneGap/Build command-line interface
Apache License 2.0
489 stars 157 forks source link

Plugin install fails with pbxproj.js syntax error #188

Closed salamanders closed 10 years ago

salamanders commented 10 years ago

Trying to install a plugin fails after updating phonegap to the latest CLI.

$ phonegap -V local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
[phonegap] adding the plugin: https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
[phonegap] Calling plugman.fetch on plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git"
[phonegap] Calling plugman.install on plugin "/app/plugins/org.apache.cordova.device" for platform "android" with options "{"www_dir":"/app/platforms/android/.staging/www","cli_variables":{}}"
[phonegap] Calling plugman.install on plugin "/app/plugins/org.apache.cordova.device" for platform "ios" with options "{"www_dir":"/app/platforms/ios/.staging/www","cli_variables":{}}"

/usr/local/share/npm/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/node_modules/xcode/lib/parser/pbxproj.js:2654
        throw new this.SyntaxError(
              ^
SyntaxError: Expected "/*", "=" or [A-Za-z0-9_] but "." found.
 $ phonegap -v
3.1.0-0.15.0

PS: I've tried the following, same result: sudo npm cache clear sudo npm update -g sudo npm update -g phonegap

salamanders commented 10 years ago

I did a complete un-install of npm and node and phonegap, and re-installed. Problem went away. Still strange to get a syntax error there, but c'est la vie.

salamanders commented 10 years ago

Drat, spoke too soon.

$ phonegap local plugin remove org.apache.cordova.device
[phonegap] removing the plugin: org.apache.cordova.device

/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/node_modules/xcode/lib/parser/pbxproj.js:2654
        throw new this.SyntaxError(
              ^
SyntaxError: Expected "/*", "=" or [A-Za-z0-9_] but "." found.
fsiddi commented 10 years ago

Having the same issue trying to get https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git installed.

abdulrauf commented 10 years ago

It was working fine for me for last 2 weeks. Suddenly i cannot build it for ios (its failing on splashscreen and dialogs)

its still fine for android.

I checked code history nothing is changed.

Phonegap : 3.1.0-0.15.0

phonegap build ios -V [phonegap] detecting iOS SDK environment... [phonegap] Checking iOS requirements... [phonegap] Running "xcodebuild -version" (output to follow) [phonegap] Xcode 5.0.1 Build version 5A2053

[phonegap] using the local environment [phonegap] compiling iOS... [phonegap] cordova library for "ios" already exists. No need to download. Continuing. [phonegap] Wrote out iOS Bundle Identifier to "com.freerangefuture...." [phonegap] Wrote out iOS Bundle Version to "1.0.0" [phonegap] iOS Product Name has not changed (still "StreetEats") [phonegap] Calling plugman.prepare for platform "ios" [phonegap] Ensuring plugin "com.freerangefuture.plugins.sharekitplugin" is installed correctly... [phonegap] Plugin "com.freerangefuture.plugins.sharekitplugin" is good to go. [phonegap] Ensuring plugin "org.apache.cordova.core.console" is installed correctly... [phonegap] Plugin "org.apache.cordova.core.console" is good to go. [phonegap] Ensuring plugin "org.apache.cordova.core.device" is installed correctly... [phonegap] Plugin "org.apache.cordova.core.device" is good to go. [phonegap] Ensuring plugin "org.apache.cordova.core.geolocation" is installed correctly... [phonegap] Plugin "org.apache.cordova.core.geolocation" is good to go. [phonegap] Ensuring plugin "org.apache.cordova.device-motion" is installed correctly... [phonegap] Plugin "org.apache.cordova.device-motion" is good to go. [phonegap] Ensuring plugin "org.apache.cordova.dialogs" is installed correctly...

/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/nodemodules/xcode/lib/parser/pbxproj.js:2654 throw new this.SyntaxError( ^ SyntaxError: Expected "/*", "=" or [A-Za-z0-9] but "." found.

prenaudin commented 10 years ago

Same issue here, did you find a solution ?

abdulrauf commented 10 years ago

phonegap build ios -V and see where it is failing. in my case it was failing on splashscreen and dialogs.

i removed related code (splashscreen and dialogs) from plugins/ios.json. file and after that i removed its related code from plugins folder.

and used alternate code for hiding splashscreen and alerts.

prenaudin commented 10 years ago

I did this and it failed on camera, and I cannot use alternate codefor this part. I hope a solution will be found soon.

cemerson commented 10 years ago

+1 to being stuck here too :(

salamanders commented 10 years ago

Far-fetched theory: could it have something to do with running the CLI while Xcode 5 was running?

-Benjamin

On Nov 8, 2013, at 7:13 AM, Chris Emerson notifications@github.com wrote:

+1 to being stuck here too :(

— Reply to this email directly or view it on GitHub.

cemerson commented 10 years ago

My initials tests point to probably not (good idea though)

From: salamanders [mailto:notifications@github.com] Sent: Friday, November 08, 2013 10:51 AM To: phonegap/phonegap-cli Cc: Chris Emerson Subject: Re: [phonegap-cli] Plugin install fails with pbxproj.js syntax error (#188)

Far-fetched theory: could it have something to do with running the CLI while Xcode 5 was running?

-Benjamin

On Nov 8, 2013, at 7:13 AM, Chris Emerson notifications@github.com<mailto:notifications@github.com> wrote:

+1 to being stuck here too :(

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/phonegap/phonegap-cli/issues/188#issuecomment-28072691.

nsamteladze commented 10 years ago

Having the same problem. Project builds, but can't add any plugin.

UPDATE: Works with a new empty project.

ninjatronic commented 10 years ago

Same problem, came totally out of nowhere - phonegap build ios -V output:

[phonegap] detecting iOS SDK environment...
[phonegap] Checking iOS requirements...
[phonegap] Running "xcodebuild -version" (output to follow)
[phonegap] Xcode 5.0.2
Build version 5A3005

[phonegap] using the local environment
[phonegap] compiling iOS...
[phonegap] cordova library for "ios" already exists. No need to download. Continuing.
[phonegap] Wrote out iOS Bundle Identifier to "com.ninjatronic.tranquilify"
[phonegap] Wrote out iOS Bundle Version to "1.0.0"
[phonegap] iOS Product Name has not changed (still "Tranquilify")
[phonegap] Calling plugman.prepare for platform "ios"
[phonegap] Ensuring plugin "com.phonegap.LowLatencyAudio" is installed correctly...
[phonegap] Plugin "com.phonegap.LowLatencyAudio" is good to go.
[phonegap] Ensuring plugin "org.apache.cordova.device" is installed correctly...
[phonegap] Plugin "org.apache.cordova.device" is good to go.
[phonegap] Ensuring plugin "org.apache.cordova.media" is installed correctly...
[phonegap] Plugin "org.apache.cordova.media" is good to go.
[phonegap] Ensuring plugin "org.apache.cordova.splashscreen" is installed correctly...

/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/node_modules/xcode/lib/parser/pbxproj.js:2654
        throw new this.SyntaxError(
              ^
SyntaxError: Expected "/*", "=" or [A-Za-z0-9_] but "." found.
DesignByOnyx commented 10 years ago

I had the following error which just popped out of nowhere some time yesterday, and I found a solution:

$ phonegap local build ios
[phonegap] compiling iOS...
/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/node_modules/xcode/lib/parser/pbxproj.js:2654
        throw new this.SyntaxError(
              ^
SyntaxError: Expected "/*", "=" or [A-Za-z0-9_] but "." found.

So the .xcodproj file is not a file but a special folder with other files and folders within. One of the files inside there is project.pbxproj - which for all intensive purposes the "main" project file. Somewhere along the lines this file got modified in a way which the cordova parser cannot handle. This most likely happens because the XCode IDE was used to change a setting.

I set up a new project and got the CLI build working again with all my plugins installed and [almost] everything back to normal. Then I ran a diff against my old project and noticed this:

image

One of the things I did yesterday was set my application to run in the background, and then turned it back off. Even though I turned it off, the pbxproj file contained new content. This new content included some periods (.) in a way which did not seem consistent with the rest of the file and consequently is not handled by the cordova parser. Once I removed these lines from my file, everything started working again.

Synopsis: The Cordova parser needs to be updated to handle object keys with dot notation. Solution:

  1. (recommended) Rename/backup your platforms/ios folder and run your build command phonegap local build ios - this may require you to reinstall every plugin manually. You will also need to reapply any other configuration changes made directly through XCode. I recommend running the build command after every change you make in XCode as this will give you an idea of what's breaking the Cordova CLI.
  2. (error prone) Use a diff tool to sift through hundreds of discrepancies to see if you can find the one which is giving you problems.
DesignByOnyx commented 10 years ago

I updated my cordova parser (pbxproj.js) to allow for dots inside of an identifier, and now my problems are gone. Find the parse_Identifier function near line 1500 and update all regexs to allow for period: /^[A-Za-z0-9_\.]/.

/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/plugman/node_modules/xcode/lib/parser/pbxproj.js

UPDATE: there are 2 regexs inside of parse_Identifier - the first checks the first character of an identifier... which should NOT contain a period. You only need to update the SECOND regex which checks the remainder of the identifier.

UPDATE 2: Upon going to submit a pull request I can see that the xcode parser was updated 2 months ago to account for periods: view the commit here - just update your local phonegap and everything should start working again: sudo npm install -g phonegap

lorinbeer commented 10 years ago

as noted by @DesignByOnyx, this issue has been resolved.