http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/ios/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/ios/upgrade.md b/www/docs/en/6.0.0/guide/platforms/ios/upgrade.md deleted file mode 100644 index 26026e0..0000000 --- a/www/docs/en/6.0.0/guide/platforms/ios/upgrade.md +++ /dev/null @@ -1,806 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: Upgrading iOS ---- - -# Upgrading iOS - -This guide shows how to modify iOS projects to upgrade from older -versions of Cordova. Most of these instructions apply to projects -created with an older set of command-line tools that precede the -`cordova` CLI utility. See [The Command-Line Interface](../../cli/index.html) for information -how to update the version of the CLI. - -__NOTE__: Xcode 6 is required. Currently, to submit to the -Apple App Store, you should use the latest shipped version of the iOS SDK, which is iOS 8 and this is included only with Xcode 6. - -## Upgrading 3.6.0 Projects to 4.0.0 - -For non-CLI projects, run: - - bin/update path/to/project - -For CLI projects: - -1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). - -2. Run `cordova platform update ios` in your existing projects. - - -## Upgrading 3.3.0 Projects to 3.4.0 - -For non-CLI projects, run: - - bin/update path/to/project - -For CLI projects: - -1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). - -2. Run `cordova platform update ios` - -## Upgrading 3.2.0 Projects to 3.3.0 - -For non-CLI projects, run: - - bin/update path/to/project - -For CLI projects: - -1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). - -2. Run `cordova platform update ios` - -## Upgrading 3.1.0 Projects to 3.2.0 - -For non-CLI projects, run: - - bin/update path/to/project - -For CLI projects: - -1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). - -2. Run `cordova platform update ios` - - -## Upgrading 3.0.0 Projects to 3.1.0 - -For non-CLI projects, run: - - bin/update path/to/project - -For CLI projects: - -1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). - -2. Run `cordova platform update ios` - -iOS 7 Issues: - -1. Remove `width=device-width, height=device-height` from the - `index.html` file's `viewport` `meta` tag. (See [the relevant - bug](https://issues.apache.org/jira/browse/CB-4323).) - -2. Update your media, media-capture and splashscreen core plugins for - iOS 7 support. - -Xcode 5 Issues: - -1. Update your Project Settings if Xcode 5 prompts you to do so (in the Issues Navigator). - -2. Update your __Compiler for C/C++/Objective-C__ setting, under the - __Build Settings__ tab, __Build Options__ section. Choose __Default - compiler (Apple LLVM 5.0)__. - -## Upgrade to the CLI (3.0.0) from 2.9.0 - -1. Create a new Apache Cordova 3.0.0 project using the cordova CLI, as - described in [The Command-Line Interface](../../cli/index.html). - -2. Add your platforms to the cordova project, for example: `cordova - platform add ios`. - -3. Copy the contents of the project's `www` directory to the `www` directory - at the root of the cordova project you just created. - -4. Copy or overwrite any native assets from your original project - (`Resources`, etc.), making sure to add any - new files to the `.xcodeproj` project. The iOS project builds - inside the `platforms\ios` directory. - -5. Copy the `config.xml` into the `www` directory, and remove any plugin - definitions. Modify settings here instead of the platform directory. - -6. Use the cordova CLI tool to install any plugins you need. Note that - the CLI handles all core APIs as plugins, so they may need to be - added. Only 3.0.0 plugins are compatible with the CLI. - -7. Build and test. - -## Upgrading 2.9.0 Projects to 3.0.0 - -1. Download and extract the Cordova 3.0.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-3.0.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova.js` (note that it does not have a version suffix anymore, the version is in the file itself in the header) file from the new project into the `www` directory, and delete the `www/cordova.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova.js` file. - -7. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -__NOTE__: Starting with Cordova 3.0.0, plugins are not pre-installed, -and you need to use the `plugman` command-line utility to install them -yourself. See [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html). - -## Upgrading 2.8.0 Projects to 2.9.0 - -1. Download and extract the Cordova 2.9.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.9.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova.js` (note that it does not have a version suffix anymore, the version is in the file itself in the header) file from the new project into the `www` directory, and delete the `www/cordova.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova.js` file. - -7. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -## Upgrading 2.7.0 Projects to 2.8.0 - -1. Download and extract the Cordova 2.8.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.8.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova.js` (note that it does not have a version suffix anymore, the version is in the file itself in the header) file from the new project into the `www` directory, and delete the `www/cordova-2.7.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova.js` file. - -7. Update any `<plugin>` tags in the `config.xml` file to `<feature>` - tags. Note that existing `<plugin>` tags still work, but are - deprecated. You can copy this information in the `config.xml` file - for a new project. For example: - - <plugins> - <plugin name="LocalStorage" value="CDVLocalStorage" /> - <!-- other plugins --> - </plugins> - - <!-- change to: (note that a <feature> tag is on the same level as <plugins> --> - <feature name="LocalStorage"> - <param name="ios-package" value="CDVLocalStorage" /> - </feature> - <!-- other <feature> tags --> - -8. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -9. Add these two frameworks to your project: - - OpenAL - ImageIO - -10. Update your project's target __Build Settings__. Under __Linking → Other Linker Flags__, edit __"-Obj-C"__ to be __"-ObjC"__. - -11. Update your project's target __Build Settings__. Under __Linking → Other Linker Flags__, change __"-all\_load"__ to be `-force\_load ${BUILT\_PRODUCTS\_DIR}/libCordova.a`. You would only need to do this if you have the problem defined in [this issue.](https://issues.apache.org/jira/browse/CB-3458). - -## Upgrading 2.6.0 Projects to 2.7.0 - -1. Download and extract the Cordova 2.7.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.7.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). you need the assets from this new project. - -5. Copy the `www/cordova-2.7.0.js` file from the new project into the `www` directory, and delete the `www/cordova-2.6.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.7.0.js` file. - -7. Update (or replace, if you never changed the file) the `AppDelegate.m` file according to the one from the new project (see [this diff](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/Classes/AppDelegate.m;h=5c05ac80e056753c0e8736f887ba9f28d5b0774c;hp=623ad8ec3c46f656ea18c6c3a190d650dd64e479;hb=c6e71147386d4ad94b07428952d1aae0a9cbf3f5;hpb=c017fda8af00375a453cf27cfc488647972e9a23)). - -8. In the `config.xml` file, [remove this line](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=537705d76a5ef6bc5e57a8ebfcab78c02bb4110b;hp=8889726d9a8f8c530fe1371c56d858c34552992a;hb=064239b7b5fa9a867144cf1ee8b2fb798ce1f988;hpb=c9f233250d4b800f3412eeded811daaafb17b2cc). - -9. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -## Upgrading 2.5.0 Projects to 2.6.0 - -1. Download and extract the Cordova 2.6.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.6.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the project's `www/cordova-2.6.0.js` file into the `www` directory, and delete the `www/cordova-2.5.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (along with any other files that reference the script) to refer to the new `cordova-2.6.0.js` file. - -7. Update (or replace, if you never changed the file) the `AppDelegate.m` file according to the one from the new project (see [this diff](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/Classes/AppDelegate.m;h=124a56bb4f361e95616f44d6d6f5a96ffa439b60;hp=318f79326176be8f16ebc93bad85dd745f4205b6;hb=a28c7712810a63396e9f32fa4eb94fe3f8b93985;hpb=36acdf55e4cab52802d73764c8a4b5b42cf18ef9)). - -8. In the `config.xml` file, [add this new line](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=1555b5e81de326a07efe0bccaa5f5e2326b07a9a;hp=0652d60f8d35ac13c825c572dca6ed01fea4a540;hb=95f16a6dc252db0299b8e2bb53797995b1e39aa1;hpb=a2de90b8f5f5f68bd9520bcbbb9afa3ac409b96d). - -9. In the `config.xml` file, [add this new line](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=d307827b7e67301171a913417fb10003d43ce39d;hp=04260aa9786d6d74ab20a07c86d7e8b34e31968c;hb=97b89edfae3527828c0ca6bb2f6d58d9ded95188;hpb=942d33c8e7174a5766029ea1232ba2e0df745c3f). - -10. In the `config.xml` file, [UIWebViewBounce has been changed to DisallowOverscroll, and default values are different](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=8889726d9a8f8c530fe1371c56d858c34552992a;hp=d307827b7e67301171a913417fb10003d43ce39d;hb=57982de638a4dce6ae130a26662591741b065f00;hpb=ec411f18309d577b4debefd9a2f085ba719701d5). - -10. In the `config.xml` file, the `EnableLocation` preference has been deprecated. - -11. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -## Upgrading 2.4.0 Projects to 2.5.0 - -1. Download and extract the Cordova 2.5.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.5.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova-2.5.0.js` file from the new project into the `www` directory and delete the `www/cordova-2.4.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.5.0.js` file. - -7. Update (or replace, if you never changed the file) the `AppDelegate.m` file according to the one from the new project (see [this diff](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/Classes/AppDelegate.m;h=318f79326176be8f16ebc93bad85dd745f4205b6;hp=6dc7bfc84f0ecede4cc43d2a3256ef7c5383b9fe;hb=4001ae13fcb1fcbe73168327630fbc0ce44703d0;hpb=299a324e8c30065fc4511c1fe59c6515d4842f09)). - -8. In the `config.xml` file, [add these new lines](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=903944c4b1e58575295c820e154be2f5f09e6314;hp=721c734120b13004a4a543ee25f4287e541f34be;hb=ae467249b4a256bd31ee89aea7a06f4f2316b8ac;hpb=9e39f7ef8096fb15b38121ab0e245a3a958d9cbb). - -9. In the `config.xml` file, [edit the root element, change it from cordova to widget](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=64e71636f5dd79fa0978a97b9ff5aa3860a493f5;hp=d8579352dfb21c14e5748e09b2cf3f4396450163;hb=0e711f8d09377a7ac10ff6be4ec17d22cdbee88d;hpb=57c3c082ed9be41c0588d0d63a1d2bfcd2ed878c). - -10. In the `config.xml` file, [remove the OpenAllWhitelistURLsInWebView preference](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=721c734120b13004a4a543ee25f4287e541f34be;hp=7d67508b70914aa921a16e79f79c00512502a8b6;hb=187bf21b308551bfb4b98b1a5e11edf04f699791;hpb=03b8854bdf039bcefbe0212db937abd81ac675e4). - -11. Delete the `cordova` directory, and copy the `cordova` directory from the new project into your project's root directory. In 2.5.0, this has updated scripts. - -12. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -## Upgrading 2.3.0 Projects to 2.4.0 - -1. Download and extract the Cordova 2.4.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.4.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova-2.4.0.js` file from the new project into the `www` directory, and delete the `www/cordova-2.3.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.4.0.js` file. - -7. Update (or replace, if you never changed the files) the `MainViewController.m` file according to the one from the new project (see [this diff](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/Classes/MainViewController.m;h=5f9eeac15c2437cd02a6eb5835b48374e9b94100;hp=89da1082d06ba5e5d0dffc5b2e75a3a06d5c2aa6;hb=b4a2e4ae0445ba7aec788090dce9b822d67edfd8;hpb=a484850f4610e73c7b20cd429a7794ba829ec997)). - -8. Update (or replace, if you never changed the file) the `AppDelegate.m` file according to the one from the new project (see [this diff](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/Classes/AppDelegate.m;h=6dc7bfc84f0ecede4cc43d2a3256ef7c5383b9fe;hp=1ca3dafeb354c4442b7e149da4f281675aa6b740;hb=6749c17640c5fed8a7d3a0b9cca204b89a855baa;hpb=deabeeb6fcb35bac9360b053c8bf902b45e6de4d)). - -9. In the `config.xml` file, [add this new line](https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=blobdiff;f=bin/templates/project/__TESTING__/config.xml;h=7d67508b70914aa921a16e79f79c00512502a8b6;hp=337d38da6f40c7432b0bce05aa3281d797eec40a;hb=6749c17640c5fed8a7d3a0b9cca204b89a855baa;hpb=deabeeb6fcb35bac9360b053c8bf902b45e6de4d). - -10. Delete the `cordova` directory, and copy the `cordova` directory from the new project into your project's root directory. In 2.4.0, this has fixed scripts. - -11. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -12. Add AssetsLibrary.framework as a resource to your project. (See [Apple's documentation](https://developer.apple.com/library/ios/#recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html) for instructions on how to do so.). - -## Upgrading 2.2.0 Projects to 2.3.0 - -1. Download and extract the Cordova 2.3.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.3.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova-2.3.0.js` file from the new project into the `www` directory, and delete the `www/cordova-2.2.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.3.0.js` file. - -7. Update (or replace, if you never changed the file) the `MainViewController.m` according to the one from the new project. - -8. Delete the `cordova` directory, and copy the `cordova` directory from the new project into your project's root directory. In 2.3.0, this has new scripts. - -9. Delete the `CordovaLib` directory, and copy the `CordovaLib` directory from the new project into your project's root directory. - -10. Convert the `Cordova.plist` file to `config.xml`, by running the script `bin/cordova\_plist\_to\_config\_xml` on your project file. - -11. Add the InAppBrowser plugin to the `config.xml`, by adding this tag under `<cordova><plugins>`: - - <plugin name="InAppBrowser" value="CDVInAppBrowser" /> - -12. Note that Objective-C plugins are _not_ whitelisted anymore. To whitelist your connections with the app whitelist, you need to set the `User-Agent` header of the connection to the same user-agent as the main Cordova WebView. -You can get this by accessing the `userAgent` property off the main view-controller. The main view-controller (`CDVViewController`) also has a `URLisAllowed` method for you to check whether a URL passes the whitelist. - -13. Device API changes: - - For iOS, device.platform used to return `iPhone`, `iPad` or `iPod Touch`; now it returns (correctly) `iOS`. - - For iOS, device.name (now deprecated for all platforms) used to return the name of the userâs device (e.g. âShazronâs iPhone 5â²); now it returns what device.platform used to return: `iPhone`, `iPad` or `iPod Touch`. - - For all platforms, there is a new property called device.model; this returns the specific device model, e.g. `iPad2,5` (for other platforms, this returns what device.name used to return). - -## Upgrading 2.1.0 Projects to 2.2.0 - -1. Download and extract the Cordova 2.2.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.2.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -4. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -5. Copy the `www/cordova-2.2.0.js` file from the new project into the `www` directory, and delete the `www/cordova-2.1.0.js` file. - -6. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.2.0.js` file. - -7. Update (or replace, if you never changed the file) the `MainViewController.m` according to the one from the new project: - - Updated → viewWillAppear - -8. Copy the `cordova` directory from the new project into your project's root directory. In 2.2.0, this has an updated 'emulate' script. - -9. Next, update the `CordovaLib` sub-project reference. Beginning with Cordova 2.1.0, we are not using the CORDOVALIB Xcode variable anymore when referencing where `CordovaLib` resides, the reference is an absolute file reference now. - 1. Launch Terminal.app - 2. Go to the location where you installed Cordova (see Step 1), in the `bin` subdirectory - 3. Run the script below where the first parameter is the path to your project's `.xcodeproj` file: - - `update_cordova_subproject path/to/your/project/xcodeproj` - -__NOTE__: In 2.2.0, the `bin/create` script copy in the `CordovaLib` sub-project into your project. To have the same kind of setup, just copy in the right `CordovaLib` into your project directory, and update the `CordovaLib` sub-project location (relative to the project) in the Xcode File Inspector. - -## Upgrading 2.0.0 Projects to 2.1.0 - -With Cordova 2.1.0, `CordovaLib` has been upgraded to use __Automatic Reference Counting (ARC)__. You don't need to upgrade to __ARC__ to use CordovaLib, but if you want to upgrade your project to use __ARC__, please use the Xcode migration wizard from the menu: __Edit → Refactor → Convert to Objective-C ARC...__, de-select libCordova.a, then run the wizard to completion. - -1. Download and extract the Cordova 2.1.0 source to a permanent directory location on your hard drive, for example to `~/Documents/Cordova-2.1.0`. - -2. Quit Xcode if it is running. - -3. Using Terminal.app, navigate to the directory where you put the downloaded source above. - -5. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -6. Copy the `www/cordova-2.1.0.js` file from the new project into the `www` directory, and delete the `www/cordova-2.0.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.1.0.js` file. - -8. Update (or replace, if you never changed the file) the `AppDelegate.m` according to the one from the new project: - - Edited → application:didFinishLaunchingWithOptions: - - Added → application:supportedInterfaceOrientationsForWindow: - -9. Update (or replace, if you never changed the file) the `MainViewController.m` according to the one from the new project: - - Added → viewWillAppear - -10. Copy the `cordova` directory from the new project into your project's root directory. In 2.1.0, this has the updated scripts to support paths with spaces. - -11. Remove the `VERSION` file reference from your project (_not_ the one in `CordovaLib`). - -12. Next, update the `CordovaLib` sub-project reference. Beginning with Cordova 2.1.0, we are not using the CORDOVALIB Xcode variable anymore when referencing where `CordovaLib` resides, the reference is an absolute file reference now. - 1. Launch Terminal.app - 2. Go to the location where you installed Cordova (see Step 1), in the `bin` subdirectory - 3. Run the script below where the first parameter is the path to your project's `.xcodeproj` file: - - `update_cordova_subproject path/to/your/project/xcodeproj` - -## Upgrading 1.9.0 Projects to 2.0.0 - -1. Install Cordova 2.0.0. - -2. Create a new project, as described in [iOS Shell Tool Guide](tools.html). You need the assets from this new project. - -3. Copy the `www/cordova-2.0.0.js` file from the new project into the `www` directory, and delete the `www/cordova-1.9.0.js` file. - -4. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-2.0.0.js` file. - -5. Copy the `cordova` directory from the new project into your project's root directory (if you want the project command-line tools). - -6. Add a new entry under `Plugins` in the `Cordova.plist` file, under - the __Supporting Files__ group. The key is `Device` and the value - is `CDVDevice`. - -7. Remove `Cordova.framework`. - -8. Remove `verify.sh` from the __Supporting Files__ group. - -9. Select the project icon in the Project Navigator, select your project __Target__, then select the __Build Settings__ tab. - -10. Search for __Preprocessor Macros__, then remove all __CORDOVA_FRAMEWORK=1__ values. - -11. Locate the `CordovaLib` directory that was installed in your hard-drive under your home folder's `Documents` subdirectory. - -12. Locate the `CordovaLib.xcodeproj` file in the `CordovaLib` directory, then drag and drop the file into your project. It should appear as a sub-project. - -13. Build your project, you should get some errors relating to `#import` directives. - -14. For the `#import` errors, change any quote-based imports in this style: - - #import "CDV.h" - - to this brackets-based style: - - #import <Cordova/CDV.h> - - and remove any `#ifdef` wrappers around any Cordova imports, they are not needed anymore (the imports are now unified) - -15. Build your project again, and it should not have any `#import` errors. - -16. Select the __project icon__ in the Project Navigator, select your project __Target__, then select the __Build Phases__ tab. - -17. Expand the __Target Dependencies__ phase, then select the __+__ button. - -18. Select the `CordovaLib` target, then select the __Add__ button. - -19. Expand the first __Link Binary with Libraries__ phase (it should already contain a bunch of frameworks), then select the __+__ button. - -20. Select the `libCordova.a` static library, then select the __Add__ button. - -21. Delete the __Run Script__ phase. - -22. Select the __project icon__ in the Project Navigator, select your project __Target__, then select the __Build Settings__ tab. - -23. Search for __Other Linker Flags__, and add the values __-force_load__ and __-Obj-C__. - -24. Expand the `CordovaLib` sub-project. - -25. Locate the `VERSION` file, drag it into your main project (we want to create a link to it, not a copy). - -26. Select the __Create groups for any added folders__ radio button, then select the __Finish__ button. - -27. Select the `VERSION` file that you just dragged in a previous step. - -28. Type the __Option-Command-1__ key combination to show the __File Inspector__ (or menuitem __View → Utilities → Show File Inspector__). - -29. Choose __Relative to CORDOVALIB__ in the __File Inspector__ for the drop-down menu for __Location__. - -30. Set the Xcode preference __Xcode Preferences → Locations → Derived Data → Advanced...__ to __Unique__, so that the unified headers can be found. - -31. Select the __project icon__ in the Project Navigator, select your __Target__, then select the __Build Settings__ tab. - -32. Search for __Header Search Paths__. For that setting, append these three values, including quotes: - - "$(TARGET_BUILD_DIR)/usr/local/lib/include" - - "$(OBJROOT)/UninstalledProducts/include" - - "$(BUILT_PRODUCTS_DIR)" - -33. Search for __Other Linker Flags__. For that setting, append this value: - - -weak_framework CoreFoundation - -34. Build your project, it should compile and link with __no issues__. - -35. Select your project from the __Scheme__ drop-down, and then select __iPhone 5.1 Simulator__. - -36. Select the __Run__ button. - -__NOTE__: If your project is not working as expected in the Simulator, please take a note of any errors in the console log in Xcode for clues. - -## Upgrading 1.8.x Projects to 1.9.0 - -1. Install Cordova 1.9.0. - -2. Create a new project. You will need some of the assets from this new project. - -3. Copy the `www/cordova-1.9.0.js` file from the new project into the `www` directory, and delete the `www/cordova-1.8.x.js` file. - -4. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-1.9.0.js` file. - -__NOTE__: 1.9.0 supports the new `BackupWebStorage` boolean `Cordova.plist` setting. It's enabled by default, so set it to -`false` to disable it, especially on iOS 6. See [Release Notes: Safari and UIKit Section](https://developer.apple.com/library/prerelease/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html) - -## Upgrading 1.7.0 Projects to 1.8.x - -1. Install Cordova 1.8.0. - -2. Create a new project. You will need some of the assets from this new project. - -3. Copy the `www/cordova-1.8.0.js` file from the new project into the `www` directory, and delete the `www/cordova-1.7.x.js` file. - -4. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-1.8.0.js` file. - -If you intend on using the Capture API, you will need the new __iPad retina-display__ assets: - -1. Copy the `Resources/Capture.bundle` item from the new project into your project directory, over-writing your existing `Resources/Capture.bundle` item. - -2. In your project, select the `Capture.bundle` item into your Project Navigator in Xcode, type the __Delete__ key, then select __Remove Reference__ from the resulting dialog. - -3. Drag the new `Capture.bundle` from Step 1 above into your Project Navigator in Xcode, then select the __Create groups for any added folders__ radio button. - -## Upgrading 1.6.x Projects to 1.7.0 - -1. Install Cordova 1.7.0. - -2. Create a new project. You will need some of the assets from this new project. - -3. Copy the `www/cordova-1.7.0.js` file from the new project into the `www` directory, and delete the `www/cordova-1.6.0.js` file. - -4. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-1.7.0.js` file. - -## Upgrading 1.5.0 Projects to 1.6.x - -1. Install Cordova 1.6.1. - -2. Make a backup of `AppDelegate.m`, `AppDelegate.h`, `MainViewController.m`, `MainViewController.h`, and `Cordova.plist` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 1.5.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - Cordova.plist - -5. Add all the new `MainViewController` and `AppDelegate` files into your Xcode project. - -6. Copy the `www/cordova-1.6.1.js` file from the new project into the `www` directory, and delete the `www/cordova-1.5.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `cordova-1.6.1.js` file. - -8. Add the new `Cordova.plist` file into your project. This is - necessary because the core plugin service names must change to - match the ones from Android and BlackBerry, for a unified Cordova - JavaScript file (`cordova-js`). - -9. Integrate any settings, __Plugins__ and __ExternalHosts__ entries that you had in your __backed-up Cordova.plist__ into the new `Cordova.plist`. - -10. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new `AppDelegate` files. Any `UIWebViewDelegate` or `CDVCommandDelegate` code in `AppDelegate.m` needs to go into `MainViewController.m` now (see commented-out sections in that file). - -11. Integrate any project-specific code that you have in your backed-up `MainViewController.h` and `MainViewController.m` into the new MainViewController files. - -12. Click on the project icon in the Project Navigator, select your __Project__, then select the __Build Settings__ tab. - -13. Enter __Compiler for C/C++/Objective-C__ in the search field. - -14. Select the __Apple LLVM Compiler 3.1__ value. - -## Upgrading 1.4.x Projects to 1.5.0 - -1. Install Cordova 1.5.0. - -2. Create a new project and run it once. You will need some of the assets from this new project. - -3. Copy the `www/cordova-1.5.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-1.4.x.js` file. - -4. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new Cordova `cordova-1.5.0.js` file. - -5. Find `PhoneGap.framework` in your Project Navigator, select it. - -6. Type the __Delete__ key and delete the `PhoneGap.framework` reference in the Project Navigator. - -7. Type the __Option-Command-A__ key combination, which should drop down a sheet to add files to your project (the __Add Files...__ sheet). Make sure the __Created groups for any added folders__ radio button is selected. - -8. Type the __Shift-Command-G__ key combination, which should drop down another sheet for you to go to a folder (the __Go to the folder:__ sheet). - -9. Enter `/Users/Shared/Cordova/Frameworks/Cordova.framework` in the __Go to the folder:__ sheet and then press the __Go__ button. - -10. Press the __Add__ button in the __Add Files...__ sheet. - -11. Select `Cordova.framework` in the Project Navigator. - -12. Type the __Option-Command-1__ key combination to show the __File Inspector__. - -13. Choose __Absolute Path__ in the __File Inspector__ for the drop-down menu for __Location__. - -14. Type the __Option-Command-A__ key combination, which should drop down a sheet to add files to your project (the __Add Files...__ sheet). Make sure the __Created groups for any added folders__ radio button is selected. - -15. Type the __Shift-Command-G__ key combination, which should drop down another sheet for you to go to a folder (the __Go to the folder:__ sheet). - -16. Enter `~/Documents/CordovaLib/Classes/deprecated` in the __Go to the folder:__ sheet and then press the __Go__ button. - -17. Press the __Add__ button in the __Add Files...__ sheet. - -18. In the `AppDelegate.h`, `AppDelegate.m`, and `MainViewController.h` files, replace the whole `#ifdef PHONEGAP_FRAMEWORK` block with: - - #import "CDVDeprecated.h" - -19. Click on the __project icon__ in the Project Navigator, select your __Target__, then select the __Build Settings__ tab. - -20. Search for __Framework Search Paths__. - -21. Replace the existing value with `/Users/Shared/Cordova/Frameworks`. - -22. Search for __Preprocessor Macros__. - -23. For the first (combined) value, replace the value with __CORDOVA_FRAMEWORK=YES__. - -24. Select the __Build Phases__ tab. - -25. Expand __Run Script__. - -26. Replace any occurrences of __PhoneGap__ with __Cordova__. - -27. Find the `PhoneGap.plist` file in the Project Navigator, and click on the filename once to enter name edit mode. - -28. Rename `PhoneGap.plist` to `Cordova.plist`. - -29. Right-click on `Cordova.plist` and choose __Open As → Source Code__. - -30. Press __Option-Command-F__, choose __Replace__ from the drop-down on the top left of the Source window. - -31. Enter `com.phonegap` for the Find string, and `org.apache.cordova` - for the Replace string, then press the __Replace All__ button. - -32. Enter __PG__ for the Find string, and __CDV__ for the Replace - string, then press the __Replace All__ button. - -33. Press __Command-B__ to build. You still have deprecations - that you can get rid of in the future (see `CDVDeprecated.h`. For - example, replace classes in your code that use PG* to CDV*). - -## Upgrading 1.4.0 Projects to 1.4.1 - -1. Install Cordova 1.4.1. - -2. Make a backup of `MainViewController.m`. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy the `MainViewController.m` file from the new project into your 1.4.0-based project directory on disk, replacing the old file (backup your files first from step 2 above). - -5. Add the `MainViewController.m` file into your Xcode project. - -6. Integrate any project-specific code that you have in your backed-up `MainViewController.m` into the new file. - -7. Updating the `phonegap-1.4.0.js` file is optional, nothing has changed in the JavaScript between 1.4.0 and 1.4.1. - -## Upgrading 1.3.0 Projects to 1.4.0 - -1. Install Cordova 1.4.0. - -2. Make a backup of `AppDelegate.m` and `AppDelegate.h` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 1.3.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib - -5. Add all the `MainViewController` files into your Xcode project. - -6. Copy the `www/phonegap-1.4.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-1.3.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `phonegap-1.4.0.js` file. - -8. Add a new entry under `Plugins` in the `PhoneGap.plist` file. The - key is `com.phonegap.battery` and the value is `PGBattery`. - -9. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new AppDelegate files. - -## Upgrading 1.2.0 Projects to 1.3.0 - -1. Install Cordova 1.3.0. - -2. Make a backup of `AppDelegate.m` and `AppDelegate.h` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 1.2.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib - -5. Add all the `MainViewController` files into your Xcode project. - -6. Copy the `www/phonegap-1.3.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-1.2.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `phonegap-1.3.0.js` file. - -8. Add a new entry under `Plugins` in the `PhoneGap.plist` file. The - key is `com.phonegap.battery` and the value is `PGBattery`. - -9. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new AppDelegate files. - -## Upgrading 1.1.0 Projects to 1.2.0 - -1. Install Cordova 1.2.0. - -2. Make a backup of `AppDelegate.m` and `AppDelegate.h` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 1.1.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib - -5. Add all the `MainViewController` files into your Xcode project. - -6. Copy the `www/phonegap-1.2.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-1.1.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `phonegap-1.2.0.js` file. - -8. Add a new entry under `Plugins` in the `PhoneGap.plist` file. The - key is `com.phonegap.battery` and the value is `PGBattery`. - -9. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new AppDelegate files. - -## Upgrading 1.0.0 Projects to 1.1.0 - -1. Install Cordova 1.1.0. - -2. Make a backup of `AppDelegate.m` and `AppDelegate.h` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 1.0.0-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib - -5. Add all the `MainViewController` files into your Xcode project. - -6. Copy the `www/phonegap-1.1.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-1.0.0.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `phonegap-1.1.0.js` file. - -8. Add a new entry under `Plugins` in the `PhoneGap.plist` file. The - key is `com.phonegap.battery` and the value is `PGBattery`. - -9. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new AppDelegate files. - -## Upgrading 0.9.6 Projects to 1.0.0 - -1. Install Cordova 1.0.0. - -2. Make a backup of `AppDelegate.m` and `AppDelegate.h` in your project. - -3. Create a new project. You will need some of the assets from this new project. - -4. Copy these files from the new project into your 0.9.6-based project directory on disk, replacing any old files (backup your files first from step 2 above): - - AppDelegate.h - AppDelegate.m - MainViewController.h - MainViewController.m - MainViewController.xib - -5. Add all the `MainViewController` files into your Xcode project. - -6. Copy the `www/phonegap-1.0.0.js` file from the new project into the `www` directory, and delete the `www/phonegap-0.9.6.js` file. - -7. Update the Cordova script reference in the `www/index.html` file (and any other files that contain the script reference) to point to the new `phonegap-1.0.0.js` file. - -8. Add a new entry under `Plugins` in the `PhoneGap.plist` file. The - key is `com.phonegap.battery` and the value is `PGBattery`. - -9. Integrate any project-specific code that you have in your backed-up `AppDelegate.h` and `AppDelegate.m` into the new AppDelegate files.
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/ios/webview.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/ios/webview.md b/www/docs/en/6.0.0/guide/platforms/ios/webview.md deleted file mode 100644 index 9e78208..0000000 --- a/www/docs/en/6.0.0/guide/platforms/ios/webview.md +++ /dev/null @@ -1,183 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: iOS WebViews ---- - -# iOS WebViews - -This guide shows how to embed a Cordova-enabled WebView component -within a larger iOS application. For details on how these components -can communicate with each other, see Application Plugins. - -Support for WebViews for iOS started with Cordova version 1.4, using a -`Cleaver` component for which the Xcode template serves as a reference -implementation. Cordova 2.0 and later versions only support the -subproject-based Cleaver implementation. - -These instructions require at least Cordova 3.x and Xcode 6.0, along -with a `config.xml` file from a newly created iOS project. You can use -the procedure in [The Command-Line Interface](../../cli/index.html) to create a new project, -then obtain the `config.xml` file from within the named application's -subdirectory within `platforms/ios`. - -To follow these instructions, make sure you have the latest Cordova -distribution. Download it from -[cordova.apache.org](http://cordova.apache.org) and unzip its iOS -package. - -## Adding Cleaver to the Xcode Project (CordovaLib Sub-Project) - -1. Quit Xcode if it is running. - -1. Open a terminal and navigate to the source directory for Cordova - iOS. - -1. Copy the `config.xml` file described above into the project - directory. - -1. Open Xcode and use the Finder to copy the `config.xml` file into - its __Project Navigator__ window. - -1. Choose __Create groups for any added folders__ and press - __Finish__. - -1. Use the Finder to copy the `CordovaLib/CordovaLib.xcodeproj` file - into Xcode's __Project Navigator__ - -1. Select `CordovaLib.xcodeproj` within the __Project Navigator__. - -1. Type the __Option-Command-1__ key combination to show the __File - Inspector__. - -1. Choose __Relative to Group__ in the __File Inspector__ for the - drop-down menu for __Location__. - -1. Select the __project icon__ in the __Project Navigator__, select - the __Target__, then select the __Build Settings__ tab. - -1. Add `-force_load` and `-Obj-C` for the __Other Linker Flags__ value. - -1. Click on the __project icon__ in the Project Navigator, select the - __Target__, then select the __Build Phases__ tab. - -1. Expand __Link Binaries with Libraries__. - -1. Select the __+__ button, and add the following __frameworks__. - Optionally within the __Project Navigator__, move them under the - __Frameworks__ group: - - AssetsLibrary.framework - CoreLocation.framework - CoreGraphics.framework - MobileCoreServices.framework - -1. Expand __Target Dependencies__, the top box with that label if - there's more than one box. - -1. Select the __+__ button, and add the `CordovaLib` build product. - -1. Expand __Link Binaries with Libraries__, the top box with that label - if there's more than one box. - -1. Select the __+__ button, and add `libCordova.a`. - -1. Set the __Xcode Preferences → Locations → Derived Data - → Advanced...__ to __Unique__. - -1. Select the __project icon__ in the Project Navigator, select your - __Target__, then select the __Build Settings__ tab. - -1. Search for __Header Search Paths__. For that setting, add these - three values below, including the quotes: - - "$(TARGET_BUILD_DIR)/usr/local/lib/include" - "$(OBJROOT)/UninstalledProducts/include" - "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" - "$(BUILT_PRODUCTS_DIR)" - - As of Cordova 2.1.0, `CordovaLib` has been upgraded to use - __Automatic Reference Counting (ARC)__. You don't need to upgrade - to __ARC__ to use `CordovaLib`, but if you want to upgrade your - project to use __ARC__, you should use the Xcode migration wizard - from the __Edit → Refactor → Convert to Objective-C - ARC...__ menu, __de-select libCordova.a__, then run the wizard to - completion. - -## Using CDVViewController - -1. Add the following header: - - #import <Cordova/CDVViewController.h> - -1. Instantiate a new `CDVViewController` and retain it somewhere, - e.g., to a class property: - - CDVViewController* viewController = [CDVViewController new]; - -1. Optionally, set the `wwwFolderName` property, which defaults to `www`: - - viewController.wwwFolderName = @"myfolder"; - -1. Optionally, set the start page in the `config.xml` file's - `<content>` tag, either a local file: - - <content src="index.html" /> - - ...or a remote site: - - <content src="http://apache.org" /> - -1. Optionally, set the `useSplashScreen` property, which defaults to - `NO`: - - viewController.useSplashScreen = YES; - -1. Set the __view frame__. Always set this as the last property: - - viewController.view.frame = CGRectMake(0, 0, 320, 480); - -1. Add Cleaver to the view: - - [myView addSubview:viewController.view]; - -## Adding HTML, CSS and JavaScript Assets - -1. Create a new directory within the project, `www` for example. - -1. Place HTML, CSS and JavaScript assets into this directory. - -1. Use the Finder to copy the directory into Xcode's __Project - Navigator__ window. - -1. Select __Create folder references for any added folders__. - -1. Set the appropriate `wwwFolderName` and `startPage` properties for - the directory you initially created, or use the defaults (specified - in the previous section) when instantiating the - `CDVViewController`. - - /* - if you created a folder called 'myfolder' and - you want the file 'mypage.html' in it to be - the startPage - */ - viewController.wwwFolderName = @"myfolder"; - viewController.startPage = @"mypage.html" - http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/ubuntu/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/ubuntu/index.md b/www/docs/en/6.0.0/guide/platforms/ubuntu/index.md deleted file mode 100644 index daa2a79..0000000 --- a/www/docs/en/6.0.0/guide/platforms/ubuntu/index.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: Ubuntu Platform Guide ---- - -# Ubuntu Platform Guide - -## Initial Release - -Welcome to the initial release of Ubuntu platform support in -Cordova. With this release, the focus is developing on an Ubuntu -system and using the cross-platform workflow discussed in the -[Overview](../../overview/index.html). This includes adding the Ubuntu platform to your project, -adding standard Cordova plugins, and building and running apps for the -Ubuntu platform. - -### Ubuntu SDK - -You may also want to install the Ubuntu QtCreator development environment. See -[developer.ubuntu.com](http://developer.ubuntu.com) for more info. (The -QtCreator SDK is not required to add Ubuntu platform support to your Cordova -app.) - -### Ubuntu Runtime Platforms - -Ubuntu is well known for its Desktop environment (for laptops, PCs and such). -Ubuntu Touch extends the Ubuntu OS onto phones and tablets. Ubuntu runtime -platforms have varying CPU architectures (x86, armhf, etc.). App and plugin -code must be compiled appropriately. Support for this broad area is rapidly -evolving in Ubuntu. - -### Latest Information - -For the latest information on Cordova app support for Ubuntu runtime platforms, -see [wiki.ubuntu.com/Cordova](http://wiki.ubuntu.com/Cordova). - -## Development Platform Requirements - -For this initial release, the development platform should be an Ubuntu Desktop. -Ubuntu 13.10 (codename âsaucyâ) or later is required to enjoy the full set of -supported capabilities. - -You can install Cordova on non-Ubuntu systems (using npm), but important -capabilities are only provided through Ubuntu debian packages at this time. - -## Cordova Installation - -Add the Ubuntu Cordova -[Personal Package Archive](https://launchpad.net/~cordova-ubuntu/+archive/ppa) -to your Ubuntu system: - - $ sudo add-apt-repository ppa:cordova-ubuntu/ppa - $ sudo apt-get update - -Install cordova-cli package (and its dependencies): - - $ sudo apt-get install cordova-cli - -## Project Workflow - -### Create a project - -Creates an app in a `hello` directory whose display name is -`HelloWorld`: - - $ cordova create hello com.example.hello HelloWorld - -### Move into the Project Directory - - $ cd hello - -### Add the Ubuntu Platform - - $ cordova platform add ubuntu - -### Build for Ubuntu - - $ cordova build ubuntu - -### Run the App - - $ cordova run ubuntu - -### Add the Camera Plugin - - $ cordova plugin add cordova-plugin-camera - http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/win8/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/win8/index.md b/www/docs/en/6.0.0/guide/platforms/win8/index.md deleted file mode 100644 index 214869f..0000000 --- a/www/docs/en/6.0.0/guide/platforms/win8/index.md +++ /dev/null @@ -1,292 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: Windows Platform Guide ---- - -# Windows Platform Guide - -This guide shows how to set up your SDK development environment to build -and deploy Cordova apps for Windows 8, Windows 8.1, Windows Phone 8.1, and -Windows 10 Universal App Platform. It shows how to use either shell tools -to generate and build apps, or the cross-platform Cordova CLI discussed in -[The Command-Line Interface](../../cli/index.html). (See the [Overview](../../overview/index.html) for a comparison of these -development options.) This section also shows how to modify Cordova apps -within Visual Studio. Regardless of which approach you take, you need to -install the Visual Studio SDK, as described below. - -See [Upgrading Windows 8](upgrade.html) for information on how to upgrade existing -Windows 8 Cordova projects. - -Window Phone 8 (wp8) stays as a separate platform, -see [Windows Phone 8 Platform Guide](../wp8/index.html) for details. - -Cordova WebViews running on Windows rely on Internet Explorer 10 (Windows 8.0) -and Internet Explorer 11 (Windows 8.1 and Windows Phone 8.1) as -their rendering engine, so as a practical matter you can use IE's -powerful debugger to test any web content that doesn't invoke Cordova -APIs. The Windows Phone Developer Blog provides -[helpful guidance](http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/15/adapting-your-webkit-optimized-site-for-internet-explorer-10.aspx) -on how to support IE along with comparable WebKit browsers. - -## Requirements and Support - -To develop apps for Windows platform you need: - -- A Windows 8.1, 32 or 64-bit machine (_Home_, _Pro_, or _Enterprise_ editions) with minimum 4 GB of RAM. - -- Windows 8.0, 8.1 or 10, 32 or 64-bit _Home_, _Pro_, or _Enterprise_ - editions, along with - [Visual Studio 2012 Express](http://www.visualstudio.com/downloads) - or Visual Studio 2013. Visual Studio 2015 is not able to build Windows 8.0 apps. - -To develop apps for Windows 8.0 and 8.1 (including Windows Phone 8.1): - -- Windows 8.1 or Windows 10, 32 or 64-bit _Home_, _Pro_, or _Enterprise_ editions, - along with - [Visual Studio 2013 Express](http://www.visualstudio.com/downloads) - or higher. An evaluation version of Windows 8.1 Enterprise is - available from the - [Microsoft Developer Network](http://msdn.microsoft.com/en-US/evalcenter/jj554510). - -- For the Windows Phone emulators, Windows 8.1 (x64) Professional edition or higher, -and a processor that supports <a href='https://msdn.microsoft.com/en-us/library/windows/apps/ff626524(v=vs.105).aspx#hyperv'>Client Hyper-V and Second Level Address Translation (SLAT)</a>. -An evaluation version of Windows 8.1 Enterprise is available from the -[Microsoft Developer Network](http://msdn.microsoft.com/en-US/evalcenter/jj554510). - -- [Visual Studio 2013 for Windows](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-8) (Express or higher). - -To develop apps for Windows 10: - -- Windows 8.1 or Windows 10 Technical Preview 2, 32- or 64-bit, along with - [Visual Studio 2015 RC](http://www.visualstudio.com/preview) or higher. - -App compatibility is determined by the OS that the app targeted. Apps are forwardly-compatible -but not backwardly-compatible, so an app targeting Windows 8.1 cannot run on 8.0, but -an app built for 8.0 can run on 8.1. - -Follow the instructions at -[windowsstore.com](http://www.windowsstore.com/) -to submit the app to Windows Store. - -To develop Cordova apps for Windows, you may use a PC running -Windows, but you may also develop on a Mac, either by running a -virtual machine environment or by using Boot Camp to dual-boot a -Windows 8.1 partition. Consult these resources to set up the required -Windows development environment on a Mac: - -- [VMWare Fusion](http://msdn.microsoft.com/en-US/library/windows/apps/jj945426) - -- [Parallels Desktop](http://msdn.microsoft.com/en-US/library/windows/apps/jj945424) - -- [Boot Camp](http://msdn.microsoft.com/en-US/library/windows/apps/jj945423) - -## Using Cordova Shell Tools - -If you want to use Cordova's Windows-centered shell tools in -conjunction with the SDK, you have two basic options: - -- Access them locally from project code generated by the CLI. They are - available in the `platforms/windows/` directory after you add - the `windows` platform as described below. - -- Download them from a separate distribution at - [cordova.apache.org](https://www.apache.org/dist/cordova/platforms/). - The Cordova distribution contains separate archives for each platform. - Be sure to expand the appropriate archive, `cordova-windows` in - this case, within an empty directory. The relevant batch utilities - are available in `package/bin` directory. (Consult the - __README__ file if necessary for more detailed directions.) - -These shell tools allow you to create, build, and run Windows apps. -For information on the additional command-line interface that enables -plugin features across all platforms, see Using Plugman to Manage -Plugins. - -## Install the SDK - -Install any edition of -[Visual Studio](http://www.visualstudio.com/downloads) matching the version -requirements listed above. - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_installSDK.png) - -For Windows 10, the Visual Studio installer has an option to install tools to -build Universal Windows Apps. You must ensure that this option is selected -when installing to install the required SDK. - -## Create a New Project - -At this point, to create a new project you can choose between the -cross-platform CLI tool described in [The Command-Line Interface](../../cli/index.html), or -the set of Windows-specific shell tools. -The CLI approach below generates an app named _HelloWorld_ -within a new `hello` project directory: - - > cordova create hello com.example.hello HelloWorld - > cd hello - > cordova platform add windows - -Here's the corresponding lower-level shell-tool approach: - - C:\path\to\cordova-windows\package\bin\create.bat C:\path\to\new\hello com.example.hello HelloWorld - -This project targets Windows 8.1 as the default target OS. You can choose to target 8.0 or 10.0 (see "Configure target Windows version" below) for all builds, or you target specific a particular version during each build. - -## Build the Project - -If you are using the CLI in development, the project directory's -top-level `www` directory contains the source files. Run either of -these within the project directory to rebuild the app: - - > cordova build - > cordova build windows # do not rebuild other platforms - > cordova build windows --debug # generates debugging information - > cordova build windows --release # signs the apps for release - -Here's the corresponding lower-level shell-tool approach: - - C:\path\to\project\cordova\build.bat --debug - C:\path\to\project\cordova\build.bat --release - -The `clean` command helps flush out directories in preparation for the -next `build`: - - C:\path\to\project\cordova\clean.bat - -## Configure target Windows version - -By default `build` command produces two packages: Windows 8.0 and Windows Phone 8.1. -To upgrade Windows package to version 8.1 the following configuration setting must be -added to configuration file (`config.xml`). - - <preference name="windows-target-version" value="8.1" /> - -Once you add this setting `build` command will start producing Windows 8.1 -and Windows Phone 8.1 packages. - -### The --appx parameter - -You may decide that you want to build a particular version of your application targeting a particular OS (for example, you might have set that you want to target Windows 10, but you want to build for Windows Phone 8.1). To do this, you can use the `--appx` parameter: - - > cordova build windows -- --appx=8.1-phone - -The build system will ignore the preference set in config.xml for the target Windows version and strictly build a package for Windows Phone 8.1. - -Valid values for the `--appx` flag are `8.1-win`, `8.1-phone`, and `uap` (for Windows 10 Universal Apps). These options also apply to the `cordova run` command. - -### Considerations for target Windows version - -Windows 10 supports a new "Remote" mode for Cordova apps (and HTML apps in general). This mode enables -apps much more freedom with respect to use of DOM manipulation and common web patterns such as the use -of inline script, but does so by reducing the set of capabilities your app may use when -submitted to the public Windows Store. For more information about Windows 10 and Remote Mode, look at -the [Cordova for Windows 10](win10-support.md.html) documentation. - -When using Remote Mode, developers are encouraged to apply a Content Security Policy (CSP) to their application -to prevent script injection attacks. - -## Deploy the app - -To deploy Windows package: - - > cordova run windows -- --win # explicitly specify Windows as deployment target - > cordova run windows # `run` uses Windows package by default - -To deploy Windows Phone package: - - > cordova run windows -- --phone # deploy app to Windows Phone 8.1 emulator - > cordova run windows --device -- --phone # deploy app to connected device - -You can use __cordova run windows --list__ to see all available targets and -__cordova run windows --target=target_name -- --phone__ to run application on a -specific device or emulator -(for example, `cordova run windows --target="Emulator 8.1 720P 4.7 inch" -- --phone`). - -You can also use __cordova run --help__ to see additional build and run -options. - -## Open the Project in the SDK and Deploy the App - -Once you build a Cordova app as described above, you can open it with -Visual Studio. The various `build` commands generate a Visual Studio -Solution (_.sln_) file. Open the file in the File Explorer to modify -the project within Visual Studio: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_openSLN.png) - -The `CordovaApp` component displays within the solution, and its `www` -directory contains the web-based source code, including the -`index.html` home page: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk.png) - -The controls below Visual Studio's main menu allow you to test or -deploy the app: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_deploy.png) - -With __Local Machine__ selected, press the green arrow to install the -app on the same machine running Visual Studio. Once you do so, the app -appears in Windows 8's app listings: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_runApp.png) - -Each time you rebuild the app, the version available in the interface -is refreshed. - -Once available in the app listings, holding down the __CTRL__ key -while selecting the app allows you to pin it to the main screen: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_runHome.png) - -Note that if you open the app within a virtual machine environment, -you may need to click in the corners or along the sides of the windows -to switch apps or access additional functionality: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_run.png) - -Alternately, choose the __Simulator__ deployment option to view the -app as if it were running on a tablet device: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_sim.png) - -Unlike desktop deployment, this option allows you to simulate the -tablet's orientation, location, and vary its network settings. - -__NOTE__: Consult the [Overview](../../overview/index.html) for advice on how to use Cordova's -command-line tools or the SDK in your workflow. The Cordova CLI relies -on cross-platform source code that routinely overwrites the -platform-specific files used by the SDK. If you want to use the SDK to -modify the project, use the lower-level shell tools as an alternative -to the CLI. - -## Supporting Toasts - -Windows requires an app manifest capability declaration in order to support -toast notifications. When using the `cordova-plugin-local-notifications` -plugin, or any other plugin that is attempting to use toast notifications, -add the following preference to your config.xml to enable it to publish -toast notifications: - - <preference name="WindowsToastCapable" value="true" /> - -This preference sets the corresponding flag in your app manifest. Plugins -should do the work necessary to configure the appearance of the -displayed notifications. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/win8/packaging.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/win8/packaging.md b/www/docs/en/6.0.0/guide/platforms/win8/packaging.md deleted file mode 100644 index 76683c5..0000000 --- a/www/docs/en/6.0.0/guide/platforms/win8/packaging.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: Windows Packaging ---- - -# Windows Packaging - -You can learn more about signing and packaging of Windows Store Apps on [MSDN][1]. - -To be able to correctly package and sign Windows apps there are few things required: - -- A signing certificate -- Identity details matching the provided signing certificate - -In Windows project, identity details are kept in a file named package.appxmanifest. This file is automatically populated every time a Cordova app is built. Identity holds 3 important fields. - -- Name -- Publisher -- Version - -*Name* and *Version* can be set from **config.xml**. *Publisher* can be provided as a build parameter or can be set on **build.json** file. - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/packaging.png) - -A signing certificate can be provided from either CLI or through build.json file. The certificate related CLI flags are: - -- `--packageCertificateKeyFile` : Once a package signing certificate is created, this parameter can be used to associate the certificate with the app. This flag takes a file path as an argument. Eg. `> cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx"` -- `--packageThumbprint` : Package thumbprint is used to validate the authenticity of package certificate key file. When creating a certificate key file, this value will be provided to the end user. Eg. `> cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx" --packageThumbprint="ABCABCABCABC123123123123"` - -Alternatively, these values could be specified using a build configuration file (build.json) using CLI (--buildConfig). A sample build configuration file: - - { - "windows": { - "debug": { - "packageCertificateKeyFile": "platforms\\windows\\CordovaApp_TemporaryKey.pfx" - }, - "release": { - "packageCertificateKeyFile": "c:\\path-to-key\\keycert.pfx", - "packageThumbprint": "ABCABCABCABC123123123123", - "publisherId": "CN=FakeCorp.com, L=Redmond, S=Washington, C=US" - } - } - } - -There is also support to mix and match command line arguments and parameters in build.json file. Values from the command line arguments will get precedence. - -# How to create a certificate key and sign Cordova windows Apps -Signing is required for distributing and installing Windows Store apps. This process is normally handled by Visual Studio when you deploy a package for release. To do tmhis without Visual Studio we need to create our own certificates. - -For creating certificates we need to use [makecert.exe][2] util. This tool ships with Windows SDK and can be found under `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x64` or `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x86`. - -The first thing we need to do is to create a root key for signing our app. - -`makecert.exe -n "CN=FakeCorp.com" -r -eku "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" -e "01/01/2020" âh 0 -sv FakeCorp.com.pvk FakeCorp.com.cer` - -To understand what makecert does, here's a brief explanation of what parameters do: - -- -n "CN=FakeCorp.com" : This is the certificate subject [X.509](http://en.wikipedia.org/wiki/X.509) name. In this example it's **C**ommon**N**ame=FakeCorp.com. -- -r : Creates a [self signed certificate](http://en.wikipedia.org/wiki/Self-signed_certificate). -- -eku #EKU_VAL# : Comma separated enhanced key usage OIDs. - - 1.3.6.1.5.5.7.3.3 indicates that the certificate is valid for code signing. Always specify this value to limit the intended use for the certificate. - - 1.3.6.1.4.1.311.10.3.13 indicates that the certificate respects lifetime signing. Typically, if a signature is time stamped, as long as the certificate was valid at the point when it was time stamped, the signature remains valid even if the certificate expires. This EKU forces the signature to expire regardless of whether the signature is time stamped. -- -e "01/01/2020" : Sets the expiration date of the certificate. -- -h 0 : Sets max height of the tree below this cert to 0 to prevent the certificate from being used as a Certification Authority (CA) that can issue other certificates. -- -sv FakeCorp.com.pvk : Output PVK file. Windows uses PVK files to store private keys for code signing. -- FakeCorp.com.cer : Output certificate file. CER file is used to store X.509 certificate. - -After running makecert for the first time, enter the private password on the screen that pops up: - -![]({{ site.baseurl }}/static/img/guide/platforms/win8/createprivatekeywindow.png) - -Once pvk and cer file is created, we need to create a pfx file from these certificates. A pfx (Personal Exchange Format) file contains a variety of cryptographic information, such as certificates, root authority certificates, certificate chains and private keys. To package the certs, we will use the a tool called [pvk2pfx][3]. This tool ships with Windows SDK and can be found under `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x64` or `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x86`. - -`pvk2pfx -pvk FakeCorp.com.pvk -pi pvkPassword -spc FakeCorp.com.cer -pfx FakeCorp.com.pfx -po pfxPassword` - -Where: - -- pvk : Input pvk file name -- pi : pvk password -- spc : Input cert file name -- pfx : Output pfx file name -- po : pfx password; same as pvk password if not provided - -If we provide this pfx file to build.json file, we will have the following error: "The key file may be password protected. To correct this, try to import the certificate manually into the current user's personal certificate store.". In order to import it we have to use [certutil][4] from an admin prompt: - -`certutil -user -p PASSWORD -importPFX FakeCorp.com.pfx` - -Where: - -- user : Specifies "current user" personal store -- p : Password for pfx file -- importPfx : Name of pfx file - -Once installed, next step is to add packageThumbprint and packageCertificateKeyFile to build.json. In order to find the packageThumbprint, search for the CommonName we've associated with the certificate: - -`powershell -Command " & {dir -path cert:\LocalMachine\My | where { $_.Subject -like \"*FakeCorp.com*\" }}"` - -Once these final values are provided. Cordova should successfully package and sign the app. - -[1]: https://msdn.microsoft.com/en-us/library/hh446593(v=vs.85).aspx -[2]: https://msdn.microsoft.com/en-us/library/ff548309(v=vs.85).aspx -[3]: https://msdn.microsoft.com/en-us/library/ff550672(v=vs.85).aspx -[4]: https://technet.microsoft.com/en-us/library/ee624045(v=ws.10).aspx http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.0.0/guide/platforms/win8/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.0.0/guide/platforms/win8/plugin.md b/www/docs/en/6.0.0/guide/platforms/win8/plugin.md deleted file mode 100644 index 6a49de6..0000000 --- a/www/docs/en/6.0.0/guide/platforms/win8/plugin.md +++ /dev/null @@ -1,221 +0,0 @@ ---- -license: > - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -title: Windows Plugins ---- - -# Windows Plugins - -This section provides details for how to implement a plugin for use in -a Windows Store app. Before reading this, see Application Plugins for -an overview of the plugin's structure and its common JavaScript interface. -This section continues to demonstrate the sample _echo_ plugin that -communicates from the Cordova webview to the native platform and back. - -It is important to note that Windows supports developing directly in Javascript, which means developing the 'native' portions in only required in special cases. - -Creating a Windows Plugin in JavaScript ---- - -These instructions are to create a pure JavaScript plugin. Understanding this is crucial to understanding how to add the native/managed bits. - -Windows Cordova plugins are essentially a thin wrapper around existing WinJS provided functions, but assuming you will want to define your JS common interface for multiple devices, you will typically have 1 JS file that provides the API. - - // inside file echoplugin.js - var EchoPlugin = { - // the echo function calls successCallback with the provided text in strInput - // if strInput is empty, it will call the errorCallback - echo:function(successCallback, errorCallback, strInput) { - cordova.exec(successCallback,errorCallback,"EchoPlugin","echo",[strInput]); - } - } - -Inside Cordova exec on Windows ---- - -The cordova.exec function is defined differently on every platform, this is because each platform has it's own way of communicating between the application js code, and the native wrapper code. But in the case of Windows, there is no native wrapper, so the exec call is there for consistency. You could do your js only plugin work directly in EchoPlugin.echo, something like : - - // inside file echoplugin.js ( this is what NOT to do if you want to reuse the JS API cross platform ) - var EchoPlugin = { - echo:function(successCallback,errorCallback,strInput) { - if(!strInput || !strInput.length) { - errorCallback("Error, something was wrong with the input string. =>" + strInput); - } - else { - successCallback(strInput + "echo"); - } - } - } - -This would/could work fine, however it means that you will need different versions of echoPlugin.js for different platforms, and possibly you could have issues with inconsistencies in your implementations. As a best practice, we decided to mimic a native API inside cordova.exec on Windows, so we could run the same JS code, and not have to rewrite it for the platform, and also take advantage of any parameter checking, or other common code provided by developers who were working on other platforms. - -The Cordova exec proxy ---- - -On Windows, cordova provides a proxy that you can use to register an object that will handle all cordova.exec calls to an API. - -For example if you wanted to provide the implementation for the Accelerometer API, you would do this : - -cordova.commandProxy.add("Accelerometer",{ - start:function(){ - // your code here ... - } - // , - // ... and the rest of the API here -}); - -So in our case, we will assume that the code in echoplugin.js is handling cross platform relevant JavaScript, and we can simply write a proxy for Windows - - // in file echopluginProxy.js - cordova.commandProxy.add("EchoPlugin",{ - echo:function(successCallback,errorCallback,strInput) { - if(!strInput || !strInput.length) { - errorCallback("Error, something was wrong with the input string. =>" + strInput); - } - else { - successCallback(strInput + "echo"); - } - } - }); - -The plugin definition - -If we want users of our plugin to be able to easily install our plugin, we will need to define it according to how PlugMan defines plugins. More on this in the [Plugin Spec](plugin_ref_spec.md.html#Plugin%20Specification) - - <?xml version="1.0" encoding="UTF-8"?> - <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" - id="com.risingj.echoplugin" - version="0.1.0"> - - <js-module src="www/echoplugin.js" name="echoplugin"> - <clobbers target="window.echoplugin" /> - </js-module> - - <!-- windows --> - <platform name="windows"> - <js-module src="src/windows/echopluginProxy.js" name="EchoProxy"> - <merges target="" /> - </js-module> - </platform> - - <!-- other platforms --> - - </plugin> - -This gives us a working Windows JavaScript plugin that uses a common file ( echoplugin.js ) and uses a proxy to provide the Windows only portion of implementation ( echopluginProxy.js ). So how do we add native/managed code to this? Well we are going to start the same, the only difference will be what we do inside in echopluginProxy methods. - -How WinJS accesses native/managed code -=== - - -In Windows, WinJS authored apps are able to interact with native code, this inter-op is available for Windows Runtime Components. The details are numerous, and this guide will only cover the basics. Microsoft provides much more info [here](http://msdn.microsoft.com/en-us/library/windows/apps/hh441569.aspx). - -When you create your Windows Runtime Component, any class that is defined as 'public ref class sealed' is considered an 'activatable class' and will be callable from JavaScript. - - // in your header file .h - namespace EchoRuntimeComponent - { - public ref class EchoPluginRT sealed - { - public: - static Platform::String^ Echo(Platform::String^ input); - } - } - - // in the implementation file .cpp - using namespace EchoRuntimeComponent; - using namespace Platform; - - Platform::String^ EchoPluginRT::Echo(Platform::String^ input) - { - if(input->IsEmpty()) - { - return "Error: input string is empty."; - } - else - { - return input->ToString() + "echo"; - } - } - -Now in order for us to call the native code, we use the namespace, classname, and lowerCamelCase the method we are calling. - -var res = EchoRuntimeComponent.EchoPluginRT.echo("boom"); -Moving this to our echopluginProxy.js file, we get this : - - // in file echopluginProxy.js - cordova.commandProxy.add("EchoPlugin",{ - echo:function(successCallback,errorCallback,strInput) { - var res = EchoRuntimeComponent.EchoPluginRT.echo(strInput); - if(res.indexOf("Error") == 0) { - errorCallback(res); - } - else { - successCallback(res); - } - } - }); - -And that's it, we have an end to end C++ backed js callable plugin for use in Apache Cordova Windows! - -Some technical notes: -=== - -- the callback is typically async, so calling the callback right away is probably not expected by the caller. In practice, if the call is not async, you should at least use a javascript timeout to force the callback to be called async. -- Activatable classes can do all kinds of awesome, like event dispatching, async callbacks, passing your own object types, arrays, collections, overloaded methods and much more. I recommend you do your homework. -- If you stick to common Windows Phone 8.0 and Windows SDK API calls, you will be able to use the same runtime component ( native or managed bits ) in a Windows Phone 8.0 Apache Cordova plugin. ~stay tuned for that post. - -Defining your plugin -=== - -Now that we have a working plugin, we need to revisit the plugin definition from earlier so we can publish it. We can now add the runtime component as a framework. -Note that the output type of a WindowsRuntimeComponent can be either .winmd or .dll - - <?xml version="1.0" encoding="UTF-8"?> - <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" - id="com.risingj.echoplugin" - version="0.2.0"> - - <js-module src="www/echoplugin.js" name="echoplugin"> - <clobbers target="window.echoplugin" /> - </js-module> - - <!-- windows --> - <platform name="windows"> - <js-module src="src/windows/echopluginProxy.js" name="EchoProxy"> - <merges target="" /> - </js-module> - <framework src="src/windows/EchoRuntimeComponent.winmd" custom="true"/> - </platform> - - <!-- other platforms --> - - </plugin> - -That's it, you now have a distributable plugin that you can share with the world! -One thing to note, support for adding frameworks to Windows Cordova project was only recently added so you will need to make sure your cordova tooling current. The cordova-cli and cordova-plugman both support adding removing native backed plugins. - -\> cordova plugin add com.risingj.echoplugin - -or - -\> plugman install --platform windows --plugin com.risingj.echoplugin --project . - -https://github.com/purplecabbage/cordova-runtimecomp-echoplug - --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org