O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending your Cordova iOS application with a native plugin

How to do it...

In this recipe, we will create a native iOS plugin for our Cordova application using command-line tools, as suggested by Cordova. We will implement the plugin for Android that we created in the previous recipe to work with iOS:

  1. Change the working project to helloplugin, open plugin.xml, and add information about the new iOS platform:
      <platform name="ios">
    
        <config-file target="config.xml" parent="/widget">
          <feature name="Hello">
            <param name="ios-package" value="HWPHello" />
          </feature>
        </config-file>
    
        <header-file src="src/ios/HWPHello.h" target-dir="HelloPlugin"/>
        <source-file src="src/ios/HWPHello.m" target-dir="HelloPlugin"/>
      </platform>
    
    </plugin>
  2. Then create two blank files, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required