Skip to content
Open
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
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ or in Objective-C:

# Test on Device without dev-server

Because a share extension in ios is treated as a separate container, they do not have access to main app folder. A resolution for this is that you have to build the script twice and package it inside the share extension container. The easiest way of doing this is create a `New Script Phase` in `Build Phases` of your share extension and copy the following line
Because a share extension in ios is treated as a separate container, they do not have access to main app folder. A resolution for this is that you have to build the script twice and package it inside the share extension container. The easiest way of doing this is create a `New Script Phase` in `Build Phases` of your share extension. Double click on '__Run Script__' and name it '__Bundle React Native code and images__'. Then, copy the following line:

```bash
export NODE_BINARY=node
Expand All @@ -461,6 +461,10 @@ export NODE_BINARY=node
<img src ="https://raw.githubusercontent.com/alinz/react-native-share-extension/master/assets/ios_step_17.png" />
</p>

<p align="center">
<img src ="https://raw.githubusercontent.com/alinz/react-native-share-extension/master/assets/ios_step_18.png" />
</p>


# App and app extension bundles

Expand Down Expand Up @@ -501,10 +505,8 @@ export NODE_BINARY=node
`BundleForced` = true

#### appShareExtension target's "Bundle React Native code and images" phase

```
cd ../
npm run cp-native-assets
cd ios/
export NODE_BINARY=node
../bin/react-native-xcode.sh
```
Expand Down Expand Up @@ -536,13 +538,16 @@ export NODE_BINARY=node

#### appShareExtension target's "Bundle React Native code and images" phase
```
cd ../
npm run cp-native-assets
cd ios/
export NODE_BINARY=node
../bin/react-native-xcode.sh
```

### Sharing Data

You may need to share authorization or other types of data from the main app with the app extension. For security purposes, Apple enforces app data containers isolation. In order to share data, you will need to create an App Group with your Apple Developer account, for the app and app extension. See "[Adding an App to an App Group](https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW19)". Then, both app and app extension can use a shared container. See "[Sharing Data with Your Containing App](https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW6)".

react-native's AsyncStorage won't work for shared containers, as it's local to the app's container. You can use something like [react-native-fs](https://github.com/itinance/react-native-fs#ios-only-pathforgroupgroupidentifier-string-promisestring) to replace AsyncStorage.

# Troubleshooting on iOS devices

Using the iOS Simulator and remote react-native debugger to develop the extension can hide issues that won't occur until testing on device. If you're experiencing issues running the extension on iOS devices, examine the Xcode console or device log for any obvious errors. If the Xcode console isn't receiving console output, ensure that the OS_ACTIVITY_MODE=disable environment var isn't enabled for the active scheme (see https://github.com/facebook/react-native/issues/10027). OS_ACTIVITY_MODE will hide device logging in the Xcode console, so its use is only advisable for iOS Simulator. For release mode, in order to view console output and see all output in the syslog, uncomment the `RCTSetLogThreshold(RCTLogLevelInfo - 1);` statement in your MyShareEx class.
Expand Down
Binary file modified assets/ios_step_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ios_step_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.