react-native-acoustic-connect-beta
Version:
BETA: React native plugin for Acoustic Connect
135 lines • 6.93 kB
TypeScript
import { withXcodeProject, type ConfigPlugin } from '@expo/config-plugins';
import type { ExpoConfig } from '@expo/config-types';
type XcodeProject = Parameters<Parameters<typeof withXcodeProject>[1]>[0]['modResults'];
export interface ConnectPluginProps {
/** Explicit App Group override. Wins over ConnectConfig.json when set. */
iosAppGroupIdentifier?: string;
/**
* Apple Team ID (10-char) used to sign the host app and the push extensions.
* Wins over `Connect.iOSDevelopmentTeam` in ConnectConfig.json when set.
* Required for push: without a team, a CLI build drops the `aps-environment`
* entitlement to ad-hoc signing and the OS issues no APNs token.
*/
iosDevelopmentTeam?: string;
}
/**
* Validates an App Group identifier against Apple's format and returns it.
* Throws an actionable error otherwise.
*/
export declare function assertValidAppGroup(value: string, source: string): string;
/**
* Resolves the iOS App Group identifier used by ConnectNSE.
*
* Priority:
* 1. `iosAppGroupIdentifier` plugin prop in app.json (explicit override)
* 2. `Connect.iOSAppGroupIdentifier` in `<projectRoot>/ConnectConfig.json`
*
* The resolved value is validated against Apple's App Group format. Throws a
* clear, actionable error if neither source provides the value, or if the
* provided value is malformed.
*/
export declare function resolveAppGroupIdentifier(projectRoot: string, props: ConnectPluginProps): string;
/**
* Returns the content of `plugin/swift/NotificationService.swift` with the
* placeholder replaced by the resolved App Group identifier and a generated
* header prepended.
*/
export declare function substituteSwiftTemplate(templatePath: string, appGroupIdentifier: string): string;
/**
* Generates the Info.plist content for the ConnectNSE target.
*
* RCTNewArchEnabled is intentionally omitted: the NSE links the Connect SDK
* only — no React Native runtime is present in the extension process.
*/
export declare function buildNSEInfoPlist(): string;
/** Generates the entitlements plist content for the ConnectNSE target. */
export declare function buildNSEEntitlements(appGroupIdentifier: string): string;
/**
* Builds the Ruby Podfile snippet shared by the NSE and NCE mods: a helper
* that resolves the AcousticConnect pod (name + version requirements) from
* ConnectConfig.json, plus an extension `target` that links it. Centralised
* here so the NSE and NCE blocks have a single source of truth for the
* resolution logic — they differ only in marker, helper name, and target name.
*
* Tolerates a missing ConnectConfig.json or a missing `Connect` key: when
* the file or key is absent the block defaults to AcousticConnectDebug with
* floor '>= 2.1.12' and no version pin, so prop-only setups (no
* ConnectConfig.json) keep working. If the file exists but contains invalid
* JSON, `pod install` will print a warning and use the same defaults rather
* than crashing.
*/
export declare function buildConnectPodTargetBlock(marker: string, helperName: string, targetName: string): string;
/**
* Returns the Ruby snippet to inject into the Expo-generated Podfile for the
* ConnectNSE target. Thin wrapper over {@link buildConnectPodTargetBlock}.
*/
export declare function buildPodfileBlock(): string;
/**
* Injects the ConnectNSE Podfile block into `podfileContent` if not already
* present (idempotent, guarded by PODFILE_MARKER).
*/
export declare function injectPodfileBlock(podfileContent: string): string;
/**
* Adds the HOST app's push entitlements. Merges idempotently:
* - `aps-environment` — the APNs (Push Notifications) capability. Required for
* the SDK's automatic `registerForRemoteNotifications()` to receive a device
* token; without it iOS fails registration with "no valid aps-environment
* entitlement string found", so no token is ever sent to the collector.
* Mirrors the bare-workflow host entitlements. `development` targets the
* sandbox APNs used by dev/`expo run:ios`/EAS `development` builds;
* production/TestFlight builds need `production`.
* - `com.apple.security.application-groups` — shared App Group for the host app
* and the NSE/NCE extensions. Never clobbers an existing array.
*/
export declare function withNSEEntitlements(config: ExpoConfig, appGroupIdentifier: string): ExpoConfig;
/**
* Extracts a build setting value scoped to the host native target's
* configuration list for the given `configName` (e.g. "Debug" or "Release").
* Falls back to the other host config if the named one is absent, then to the
* hardcoded `fallback`.
*
* Scoped to host configs only: configs whose CODE_SIGN_ENTITLEMENTS references
* one of `skipTargetNames` (the extension targets this plugin generates) are
* skipped, so values are never mirrored from a previously generated extension
* target. Defaults to `[NSE_TARGET_NAME]`; the NCE mod (withConnectNCE) passes
* both ConnectNSE and ConnectNCE so a re-run that already wrote the NSE target
* never mirrors the sibling extension's settings.
*/
export declare function getHostBuildSettingForConfig(xcodeProject: XcodeProject, setting: string, configName: string, fallback: string, skipTargetNames?: string[]): string;
/**
* Adds the ConnectNSE Xcode target (app_extension) to the project.
*
* Follows the OneSignal plugin pattern (withOneSignalNSE.ts) using the
* `xcode` API exposed via `config.modResults`.
*
* Idempotent: if a target named ConnectNSE already exists, skips target
* creation but still (re)writes the source files.
*/
export declare function withNSEXcodeProject(config: ExpoConfig, appGroupIdentifier: string, swiftContent: string): ExpoConfig;
/**
* Injects the ConnectNSE Podfile target block via withDangerousMod.
* Guarded by a marker comment — re-runs are no-ops.
*
* M5: throws a clear, actionable error when the Podfile does not exist at
* mod-execution time, instead of silently returning — a silent skip would
* ship an NSE whose `import Connect` cannot resolve.
*/
export declare function withNSEPodfile(config: ExpoConfig): ExpoConfig;
/**
* Expo Config Plugin mod that provisions a Notification Service Extension
* (NSE) Xcode target named `ConnectNSE`.
*
* Applies three mutations — all idempotent:
* 1. Host app entitlements: merges App Group into
* `com.apple.security.application-groups`.
* 2. Xcode project: adds ConnectNSE target + files (skips if already present).
* 3. Podfile: injects `target 'ConnectNSE'` block (guarded by marker comment).
*
* M4: `config._internal.projectRoot` is required. If absent (i.e. invoked
* outside Expo CLI), an actionable error is thrown rather than silently
* falling back to `process.cwd()`, which would misresolve ConnectConfig.json
* in monorepo setups.
*/
export declare const withConnectNSE: ConfigPlugin<ConnectPluginProps>;
export {};
//# sourceMappingURL=withConnectNSE.d.ts.map