# Migrating to 2.0.0

2.0.0 makes the module backward-compatible with the React Native New Architecture
and removes the iOS `use_frameworks!` requirement. **No JavaScript API changes.**

- New Architecture enabled &rarr; the module is a **TurboModule**.
- New Architecture disabled &rarr; it falls back to the classic bridge module
  (`NativeModules`) transparently. The runtime module name is unchanged
  (`FreshdeskReactNative`).

## Requirements

- React Native **>= 0.75** (`peerDependencies.react-native` is `>=0.75.0`).
- On RN < 0.75, stay on `@freshworks/react-native-freshdesk-sdk@~1.4.3` — that
  is where 1.4.x already sat in practice (it was built at RN 0.75.4 and its SPM
  iOS path required RN >= 0.75).

`sample_app` and the codegen verification pin RN 0.75.4; the CI build matrix's
arch × platform legs are the supported gate.

## JavaScript

No changes. Public API, exported names, signatures, TypeScript types, and event
names are identical to 1.4.x.

`runDiagnostics()` additionally returns two optional fields:

- `architecture` — `'old'` or `'new'`
- `turboModule` — `boolean`

## Android

Rebuild only:

```
cd android && ./gradlew clean && cd ..
```

Old Architecture apps behave exactly as before. New Architecture apps now build
(1.4.x failed with a `cmake … default-app-setup` error caused by a `codegenConfig`
that had no backing generated spec).

## iOS

The native SDK is now consumed **only** as a vendored `FreshdeskSDK.xcframework`.
The 1.4.x Swift Package Manager path (`cocoapods-spm` / `spm_dependency` / forced
dynamic frameworks) is gone. Remove the lines that existed only for that path,
then reinstall pods:

| Remove from Podfile / Gemfile | Why |
|---|---|
| `use_frameworks! :linkage => :dynamic` | no longer required by Freshdesk |
| `gem "cocoapods-spm"` and the `plugin 'cocoapods-spm'` line | SDK no longer uses `spm_dependency` |
| `spm_dependency` / SPM lines added for Freshdesk | same |
| `ENV['FRESHDESK_IOS_USE_VENDORED'] = '1'` | vendored is now the only path (the env gate was removed) |
| `post_install` overrides added to cope with mixed static/dynamic linkage | the cause is removed |

```
cd ios && rm -rf Pods Podfile.lock && pod install
```

Keep `use_frameworks!` only if your *other* dependencies need it — prefer
`:linkage => :static`. The podspec now sets `s.static_framework = true` and calls
`install_modules_dependencies(s)` (guarded for older RN), so a static build is the
expected configuration.

## Expo (previously hit `no such module 'Expo'`)

The `no such module 'Expo'` failure was caused by the forced dynamic-framework
linkage. Remove `use_frameworks!` and the Freshdesk SPM lines from the Podfile /
config plugin, then:

```
npx expo prebuild --clean && cd ios && pod install
```

Expo returns to its default static linkage and the error is gone.

## Metro

```
npx react-native start --reset-cache
```

once, after upgrading.

## Cannot upgrade React Native yet?

If you are still blocked on 1.4.x (for example, RN < 0.75, or you cannot take the
iOS Podfile changes right now), pin `@freshworks/react-native-freshdesk-sdk@~1.4.3`
and strip the stray `codegenConfig` from it with `patch-package`:

1. Delete the `codegenConfig` key from
   `node_modules/@freshworks/react-native-freshdesk-sdk/package.json`.
2. Run `npx patch-package @freshworks/react-native-freshdesk-sdk`.
3. Add `"postinstall": "patch-package"` to your app's `scripts`.

This removes the `cmake … default-app-setup` New Architecture build failure on
1.4.x without upgrading to 2.0.0.
