Search code examples
cordovacordova-pluginsplugman

Why prefer Plugman over Cordova CLI for embedded projects?


I'm working on a iOS-only project with an embedded Cordova Web view. The Cordova docs say I should use Plugman instead of the Cordova CLI. But why? When I add my platform, Cordova automatically detects and adds plugins. To use Plugman, I would have to remove each plugin and re-add it. And the only difference - that I found - is that Plugman copies the plugins to platforms/ios/cordova/plugins, whereas Cordova keeps them in the plugins directory. And Plugman still copies sources for other platforms! Why use it? The app can load plugins either way, so why prefer Plugman?


Solution

  • It's not preferred, it's the only available tool when using a single-platform workflow. You don't use cordova (and its platform, plugin CLI) at all, only cordova-ios.

    To create an iOS project, run node_modules/cordova-ios/bin/create myproj.

    Then use plugman install --platform ios --project myproj --plugin cordova-plugin-device. This will copy the plugin's JS interface to the myproj/platform_www. Since you're using your own Xcode project, you won't be using the generated "myproj" project at all - it's just a staging area for the Crodova runtime files. So you need to add the plugins' source files to your project manually, and then copy its platform_www files to your own www directory, where your embedded Web view can load them.

    This should have been covered in more detail in the Cordova guides.