Skip to content

migrate native docs to use capacitor #2684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 0 additions & 200 deletions docs/native-community.md

This file was deleted.

82 changes: 11 additions & 71 deletions docs/native-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,23 @@ sidebar_label: FAQ
slug: /native/faq
---

# Ionic Native FAQ
# Frequently Asked Question

## Cordova Management Tips
## What is Capacitor?

**1) Use the [Ionic CLI](cli.md) to add/update/delete plugins.**
Capacitor a native runtime built by the Ionic team that offers web developers the ability to deploy their web apps to a native device. Capacitor also exposing native device capabilities through JavaScript so developers could access features like native location services, filesystem access, or notifications as if they are interacting with any other JavaScript library.

Instead of directly editing `config.xml` and `package.json`. Use `ionic` in front of Cordova commands for a better experience and additional functionality (`ionic cordova build ios` instead of `cordova build ios`).
## Permission Issues

**2) Upgrade plugins by removing, then re-adding them.**
If you're using a plugin, it may require adding additional permissions to your native project after you install the plugin. For instance, the Capacitor Camera plugin requires the following permission for iOS:

```shell
$ ionic cordova plugin remove cordova-plugin-camera
$ ionic cordova plugin add cordova-plugin-camera
```
- `NSCameraUsageDescription` (`Privacy - Camera Usage Description`)
- `NSPhotoLibraryAddUsageDescription` (`Privacy - Photo Library Additions Usage Description`)
- `NSPhotoLibraryUsageDescription` (`Privacy - Photo Library Usage Description`)

**3) Install explicit versions.**
You need to manually add those permissions to the `info.plist` in your native project. Otherwise, calls to the native camera API will fail.

To ensure that the same version of a plugin is always installed via `npm install`, specify the version number:

```shell
ionic cordova plugin add [email protected]
```
## Unexpected behaviour

**4) Restore Cordova in an existing Ionic project**

Useful when adding new developers to a project. `ionic cordova prepare` restores platforms and plugins from `package.json` and `config.xml`. The version to be installed is taken from `package.json` or `config.xml`, if found in those files. In case of conflicts, `package.json` is given precedence over `config.xml`.

**5) Troubleshoot Cordova issues with Ionic CLI commands**

- `ionic doctor list`: Detects [common issues](cli/commands/doctor-list.md) and suggests steps to fix them
- `ionic repair`: Remove, then [regenerate](cli/commands/repair.md) all dependencies

## Understanding Version Numbers

For any given Ionic Native plugin, the Ionic Native (TypeScript code) and Cordova (native code) version numbers will not match. The Ionic Native version number is found in `package.json`:

```json
"@awesome-cordova-plugins/camera": "^5.3.0",
```

The Cordova plugin version number is found in both `package.json` and `config.xml`:

```json
"cordova-plugin-camera": "4.0.3",
```

```xml
<plugin name="cordova-plugin-camera" spec="4.0.3" />
```

When checking for new native functionality or bug fixes, look for new versions on the Cordova plugin GitHub page itself (here's the [Camera one](https://github.com/apache/cordova-plugin-camera), for example).

To check for new Ionic Native releases (may include exposing methods recently added by the Cordova plugin, etc.), see [here](https://github.com/ionic-team/ionic-native/releases).

## Troubleshooting Failed Builds

Research the build error(s) by checking out these resources:

- Google & [StackOverflow](https://stackoverflow.com): Many issues are documented online
- Ask the [Ionic Community Ionic Forum](https://forum.ionicframework.com) (see the Ionic Native category)
- See the Ionic Customer Success [Knowledge Base](https://ionic.zendesk.com)

### Cordova Plugin Conflicts

Plugins can conflict with each other when they share the same underlying native dependencies or when more than one plugin tries to access the same native code at once. For example, common libraries like the Google Play Services version (Google Maps is using GPS v24.2 but Firebase wants GPS v27.1). Keeping these plugins updated regularly can help with this.

Another tip is to ensure that your app uses only one plugin per specific feature/functionality (example: Push Notifications).

## Recommended Upgrade Strategy

The most Ionic stable apps are routinely updated, especially at the native layer. Keeping native plugins up to date ensures your project has the latest security fixes, new features, and improved performance.

Update your project's plugins one at a time, ideally in separate code branches. This reduces the surface area that issues can arise from - if you update everything in your project at once, it's sometimes hard to tell where the problem stems from.

### When should I update?

- When a new feature/bug is released: Run `npm outdated` to see a list of available updates.
- When new major versions are released: Official blogs, such as the [Cordova blog](https://cordova.apache.org/blog/) and [Ionic blog](https://ionicframework.com/blog/), will publish announcements and news.
- Evaluate the nature of the update: is it a shiny new feature or critical security fix?
- Timing: Where does it fit in against your team's project goals?
If for some reason the plugin does not behave in a way that is unexpected, please [open an issue on our github repo](https://github.com/ionic-team/capacitor-plugins)! Providing a clear issue report along with a reproduction can help get your issue resolved.
Loading