# Cordova development environment setup

[Apache Cordova](https://cordova.apache.org/#getstarted)

**Supported Android Version:**

API 21+ & CompileSDK version 31.

**Supported iOS Version**

iOS 13+

# Plugin installation

Install the Incode Cordova plugin in your app using the following command:

```bash
cordova plugin add https://github.com/Incode-Technologies-Example-Repos/incode-cordova-plugin.git
```

To enable the camera to capture ID and face, use the following command:

```bash
cordova plugin add cordova-plugin-camera
```

To enable the use of GeoLocation if it is required, use the following command:

```bash
cordova plugin add cordova-plugin-geolocation
```

# Additional Setup for iOS

1. Open your .xcworkspace project on XCODE
2. Set your Team Develop in _Targets > Sign & Capabilities._ (if you don't have it)
3. Ensure that you have set up at least swift version 5: _Targets > Build Settings > Swift Compiler - Language_
4. Change your Podfile so it requires deployment target 13 or higher.

Podfile

```text
   platform :ios, '13.0'
   ```

5. Run 'pod install'

```bash
   Run "pod install" under ios folder
   ```

# Troubleshooting

**iOS**: `The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation`

**Solution**

Run the commands below:

```bash
cordova platform remove ios
cordova platform add ios
cd platforms/ios && pod install --repo-update
pod repo update
```

**iOS**: `Error: Failed to fetch platform cordova-ios` using `cordova platform add ios`

**Solution**

Run the command:

```bash
npm update -g
```

**Android**: `Attribute uses-permission#android.permission.WRITE_EXTERNAL_STORAGE@maxSdkVersion value=(32) from AndroidManifest.xml`

**Solution**

add 'tools:replace="android:maxSdkVersion"' to `<uses-permission>` element at AndroidManifest. Example:

```html
<uses-permission android:maxSdkVersion="32" android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:replace="android:maxSdkVersion" />
```
