1

I am trying to add the camera plugin to my cordova project through terminal, but I keep getting the same error no matter where I run cordova plugin add org.apache.cordova.camera. The error is

'Current working directory is not a Cordova based project'

I am using Cordova version 3.4.1-0.1.0. The documentation is terrible and is giving me no help so far. I have done a similar thing with an android project and that all works fine, this is only happening in iOS.

Is there a way I can manually add the plugins without going through the command line? I found this link that allowed me to download the files for the plugin but I have no idea where they are supposed to go.

The files included in the zip are as follows:

doc (folder)
plugin.xml
src (folder containing the ios folder)
    ios (folder)
        CDVCamera.h
        CDVCamera.m
        CDVExif.h
        CDVJpegHeaderWriter.h
        CDVJpegHeaderWriter.m
www (folder containing js files)

I've been sitting here for a few hours trying to go through lots of terrible documentation and nothing seems to work. Any help would be much appreciated, cheers!

Pooshonk
  • 1,284
  • 2
  • 22
  • 49

1 Answers1

0

You are supposed to run

 cordova plugin add org.apache.cordova.camera

From the project root folder, not the iOS or android folders. When you run it, it installs the plugin for all installed platforms that the plugin supports.

I am running 3.5.0-0.2.4. I pulled this function out of util.js in /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova (on a Mac)

function isRootDir(dir) {
    if (fs.existsSync(path.join(dir, 'www'))) {
        if (fs.existsSync(path.join(dir, 'config.xml'))) {
            // For sure is.
            if (fs.existsSync(path.join(dir, 'platforms'))) {
                return 2;
            } else {
                return 1;
            }
        }
        // Might be (or may be under platforms/).
        if (fs.existsSync(path.join(dir, 'www', 'config.xml'))) {
            return 1;
        }
    }
    return 0;
}

This is how it determines that it has a cordova root dir

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • That is what I have done, still no luck. I have even tried running it from other folders and I still get the same error. – Pooshonk Jul 30 '14 at 14:03
  • Have you created the project with cordova cli? – Vlad Stirbu Jul 30 '14 at 14:07
  • [edited] I just read the cordova source. It looks for www, config.xml, and platforms in the root project dir. Is config.xml there? – Lou Franco Jul 30 '14 at 14:09
  • Yes i did. And yes the config.xml file is there – Pooshonk Jul 30 '14 at 14:11
  • I can't find that file, I can for my android project however! – Pooshonk Jul 30 '14 at 15:07
  • Which file? There is only one project root folder for android and iOS. Do you have two separate projects? – Lou Franco Jul 30 '14 at 15:11
  • I have a windows machine which I am running my android project on, and my Mac for the iOS project – Pooshonk Jul 30 '14 at 15:17
  • On the Mac, did you create the project with `cordova create`? If you copied files over, did you get everything (including the .cordova folder)? – Lou Franco Jul 30 '14 at 15:25
  • I don't think I did, I was having problems when trying to create the program through terminal so I may have did it manually. Regardless I want to know where the files from the plugin need to go..NOT using the CLI. – Pooshonk Jul 30 '14 at 15:27
  • It is a bad idea to do it that way. You should fix your project so that cli works. There are a lot of manual steps and it will break plugin updating. The way to do it manually is to read the plugman source and do all of its steps. It is NOT just copying files to a directory -- config files need to be updated as well. – Lou Franco Jul 30 '14 at 15:28
  • I have created another question with the error I was getting while trying to add the iOS platform http://stackoverflow.com/questions/25056398/cordova-platform-add-ios-error-command-failed-with-exit-code-2 – Pooshonk Jul 31 '14 at 10:29