Skip to content

Commit 5fb8517

Browse files
expo simplification doc update (#473)
* removed registeration of sdks * Update expo.md with expo to support CNG with static frameworks configuration * addressed review comments and made relevant changes in read me * Added a note for Expo support in Installation Guide. --------- Co-authored-by: akhiljain1907 <[email protected]>
1 parent 55ef82d commit 5fb8517

File tree

2 files changed

+52
-132
lines changed

2 files changed

+52
-132
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ yarn install
103103

104104
##### ios development
105105

106+
> [!NOTE]
107+
> Skip this step if you are developing with Expo.
108+
106109
For iOS development, after installing the plugins from npm, download the pod dependencies by running the following command:
107110

108111
```bash

docs/expo.md

Lines changed: 49 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,76 @@
11
# Integrating the SDK with Expo projects
2-
32
The Adobe Experience Platform Mobile SDK for React Native is compatible with the latest stable version of Expo. Using the most recent version of Expo is recommended to avoid any issues.
4-
53
- [Guide for Expo apps](#guide-for-expo-apps)
64
- [Guide for bare React Native apps using Expo modules](#guide-for-bare-react-native-apps-using-expo-modules)
75

86
# Guide for Expo apps
97

10-
> [!NOTE]
11-
> A simplified solution for SDK integrated with Expo is currently in development and expected to be available in the next couple of months. You may proceed with the current steps or choose to wait for the updated version if you prefer a more streamlined setup.
12-
138
## Overview
14-
Expo projects can use both third-party React Native libraries with native code and custom native code. Creating a development build with Expo CLI allows inclusion of specific native dependencies and customizations.
15-
16-
Initializing the Adobe Mobile SDK requires native code implementation. In Expo projects, Continuous Native Generation (CNG) is enabled by default, meaning the `Android` and `iOS` directories for native code and configuration are not included. To integrate the Mobile SDK, CNG must be disabled, and the `Android` and `iOS` directories must be generated and managed manually.
9+
With the release of the simplification SDK support, Expo projects now support Continuous Native Generation (CNG) without requiring native code modifications. The SDK extensions are now registered through Mobile Core's initialize API, eliminating the need to disable CNG or manually manage native directories.
1710

1811
## Installation
1912

20-
To generate these directories, run
21-
```bash
22-
npx expo prebuild
23-
```
24-
Alternatively, compile the app locally:
25-
```bash
26-
# Build your native Android project
27-
npx expo run:android
28-
# Build your native iOS project
29-
npx expo run:ios
30-
```
31-
32-
## Install Adobe Mobile SDKs
33-
34-
Refer to the [Installation Guide](../README.md#Installation) to install Adobe SDKs after the android and ios directories are generated.
35-
36-
## Initialize Adobe Mobile SDKs
37-
Initializing the Mobile SDK involves implementing native code. The following code snippets show how to install and register the Mobile Core and Edge Network extensions. Documentation on how to initialize each extension can be found in _./packages/{extension}/README.md_.
13+
### Prerequisites
14+
To prevent C++ module import errors during the iOS build process, we need to configure useFrameworks: "static" using the expo-build-properties package. This is a required step for proper Adobe SDK integration with Expo.
3815

39-
##### **iOS**
40-
41-
Create a separate header and Objective-C file to handle the Adobe SDK setup, then import this file into the `AppDelegate` to initialize the SDK when the app launches.
42-
43-
AdobeBridge.h
44-
```objective-c
45-
#import <UIKit/UIKit.h>
46-
#import <Foundation/Foundation.h>
47-
@interface AdobeBridge : NSObject
48-
+ (void)configure: (UIApplicationState)state;
49-
+ (void)lifecycleStart;
50-
+ (void)lifecyclePause;
51-
@end
16+
#### Install the required package:
17+
```bash
18+
npx expo install expo-build-properties
5219
```
5320

54-
AdobeBridge.m
55-
```objective-c
56-
#import "AdobeBridge.h"
57-
#import <UIKit/UIKit.h>
58-
59-
@import AEPCore;
60-
@import AEPLifecycle;
61-
@import AEPEdge;
62-
@import AEPEdgeIdentity;
63-
@import AEPEdgeConsent;
64-
@import AEPServices;
65-
66-
@implementation AdobeBridge
67-
68-
+ (void)configure: (UIApplicationState)appState
21+
#### Configuration
22+
Add the following plugin configuration to your `app.json` or `app.config.json`:
23+
```json
6924
{
70-
[AEPMobileCore setLogLevel:AEPLogLevelTrace];
71-
NSArray *extensionsToRegister = @[
72-
AEPMobileLifecycle.class,
73-
AEPMobileEdge.class,
74-
AEPMobileEdgeIdentity.class,
75-
AEPMobileEdgeConsent.class
76-
];
77-
[AEPMobileCore registerExtensions:extensionsToRegister completion:^{
78-
[AEPMobileCore configureWithAppId: @"YOUR-APP-ID" ];
79-
if (appState != UIApplicationStateBackground) {
80-
[AEPMobileCore lifecycleStart:nil];
25+
"plugins": [
26+
[
27+
"expo-build-properties",
28+
{
29+
"ios": {
30+
"useFrameworks": "static"
8131
}
82-
}];
83-
}
84-
85-
+ (void)lifecycleStart
86-
{
87-
[AEPMobileCore lifecycleStart:nil];
32+
}
33+
]
34+
]
8835
}
89-
90-
+ (void)lifecyclePause
91-
{
92-
[AEPMobileCore lifecyclePause];
93-
}
94-
@end
9536
```
9637

97-
AppDelegate.mm
98-
```objective-c
99-
#import "AdobeBridge.h" // add this import
100-
101-
@implementation AppDelegate
102-
103-
UIApplicationState appState = [UIApplication sharedApplication].applicationState;
104-
105-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
106-
{
107-
self.moduleName = @"main";
38+
**Important**: The `useFrameworks: "static"` setting is required for iOS to prevent C++ module import errors during the build process.
10839

109-
// You can add your custom initial props in the dictionary below.
110-
// They will be passed down to the ViewController used by React Native.
111-
self.initialProps = @{};
40+
### Install Adobe Mobile SDKs
11241

113-
[AdobeBridge configure: application.applicationState];
42+
> [!NOTE]
43+
> To support Expo CNG and use Mobile Core's initialize API (simplification SDK support), All aep sdks should have 7.x versions except places should have 7.0.1 version or higher.
11444
115-
return [super application:application didFinishLaunchingWithOptions:launchOptions];
116-
}
45+
After configuring the build properties, refer to the [Installation Guide](../README.md#Installation) to install Adobe SDKs.
11746

118-
// Setup for Lifecycle Start when entering foreground
119-
- (void)applicationWillEnterForeground:(UIApplication *)application{
120-
appState = application.applicationState;
121-
[AdobeBridge lifecycleStart];
122-
}
47+
### Initialize Adobe Mobile SDKs
48+
Extensions are now registered through Mobile Core's initialize API (no native code required). Refer to the [Initialization Guide](../README.md#initializing) to initialize Adobe SDKs.
12349

124-
// Setup for Lifecycle Start when entering background
125-
- (void)applicationDidEnterBackground:(UIApplication *)application{
126-
appState = application.applicationState;
127-
[AdobeBridge lifecyclePause];
128-
}
50+
### Generate and Run Native Projects
12951

130-
@end
52+
To apply these build properties and include the installed SDKs in your native projects, run:
53+
```bash
54+
npx expo prebuild
13155
```
13256

133-
> For further details on Lifecycle implementation, please refer to the [Lifecycle API documentation](https://github.com/adobe/aepsdk-react-native/tree/main/packages/core#lifecycle).
57+
This will generate the native iOS and Android projects with the configured build properties and SDKs.
13458

135-
> [!TIP]
136-
> If the following build error occurs when running the iOS application after Mobile SDK installation:
137-
>
138-
> ```
139-
> ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
140-
> ```
141-
>
142-
> This is because the Mobile SDK now requires the app to use Swift interfaces. Adding a placeholder `.swift` file to the project embeds the Swift standard libraries. See the SampleApp in this repository for an example.
59+
After generating the native projects, you can build and run the app:
14360

144-
##### **Android:** _(Kotlin)_
145-
146-
Please refer to the [Android section](../README.md#kotlin) for initialization code.
61+
```bash
62+
# Build and run on Android
63+
npx expo run:android
64+
# Build and run on iOS
65+
npx expo run:ios
66+
```
14767

14868
# Guide for bare React Native apps using Expo modules
149-
15069
## Overview
15170
Bare React Native workflows can be integrated with Expo SDKs by using the `install-expo-modules` command. This allows you to use Expo modules in your app.
15271

15372
To use Expo modules in an app, installation and configuration of the `expo` package is required. The `expo` package has a small footprint; it includes only a minimal set of packages needed in nearly every app and the module and autolinking infrastructure that other Expo SDK packages are built with. After the `expo` package is installed and configured in the project, `npx expo install` can be used to add any other Expo module from the SDK.
15473

155-
15674
## Installation
15775
- To install and use Expo modules, the easiest way to get up and running is with the `install-expo-modules` command.
15876
```bash
@@ -161,33 +79,32 @@ npx install-expo-modules@latest
16179
- If the command fails, please follow the manual installation [instructions](https://docs.expo.dev/bare/installing-expo-modules/#manual-installation).
16280

16381
## Install Adobe Mobile SDKs
164-
16582
Refer to the [Installation Guide](../README.md#Installation) to install Adobe SDKs.
16683

16784
## Initialize Adobe Mobile SDKs
168-
169-
Refer to the [Initialization Guide](../README.md#initializing) to initialize Adobe SDKs.
85+
Extensions are now registered through Mobile Core's initialize API (no native code required). Refer to the [Initialization Guide](../README.md#initializing) to initialize Adobe SDKs.
17086

17187
# Troubleshooting and Known Issues
172-
1. `Import of C++ module` error when building on iOS
88+
## iOS Build Issues (Legacy)
89+
The following issues are automatically resolved when using the `expo-build-properties` plugin with `useFrameworks: "static"` as described in the [Prerequisites](../README.md#prerequisites) section:
17390

174-
When facing the following error:
91+
### 1. `Import of C++ module` error when building on iOS
92+
**Note**: This error is automatically resolved with the static frameworks configuration.
93+
94+
For legacy projects not using the recommended configuration, the error appears as:
17595
```xcode
17696
error: import of C++ module 'Foundation' appears within extern "C" language linkage specification [-Wmodule-import-in-extern-c]
17797
```
178-
**Fix**: In XCode, select your app target, go to **Build Settings** and under `Apple CLang - Custom Compiler Flags`, locate `Other C++ Flags`, and add:
98+
**Legacy Fix**: In XCode, select your app target, go to **Build Settings** and under `Apple CLang - Custom Compiler Flags`, locate `Other C++ Flags`, and add:
17999
```bash
180100
-Wno-module-import-in-extern-c
181101
```
182102
<img width="936" alt="Xcode Screenshot" src="./resources/xcode c++ flag screenshot.png">
183103

184-
2. `Use of undeclared identifier 'AEPMobileCore'` error when building on iOS
104+
### 2. `Use of undeclared identifier 'AEPMobileCore'` error when building on iOS
105+
**Note**: This error is automatically resolved with the static frameworks configuration.
185106

186-
When facing the following error:
187-
```xcode
188-
error: Use of undeclared identifier 'AEPMobileCore'
189-
```
190-
Refer to the solution [here](https://github.com/adobe/aepsdk-react-native/issues/346#issuecomment-2109949661).
107+
For legacy projects, refer to the solution [here](https://github.com/adobe/aepsdk-react-native/issues/346#issuecomment-2109949661).
191108

192109
## Other known issues with React Native
193-
Refer to [Troubleshooting and Known Issues](../README.md#troubleshooting-and-known-issues) for other known issues with React Native integration.
110+
Refer to [Troubleshooting and Known Issues](../README.md#troubleshooting-and-known-issues) for other known issues with React Native integration.

0 commit comments

Comments
 (0)