Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a64623e
Start examples
lindboe Jan 18, 2024
041341e
Pods setup
lindboe Jan 18, 2024
0bbfa47
Add react-native-share-menu from project, and whoops, use yarn
lindboe Jan 18, 2024
0287cb0
Android configuration
lindboe Jan 18, 2024
c40a1e7
Add demo code to app
lindboe Jan 18, 2024
db2199d
Symlink project correctly for modern metro
lindboe Jan 23, 2024
662f168
Add a basic TS config
lindboe Jan 24, 2024
c3fc5bb
Start setting up share extension
lindboe Jan 24, 2024
8c69a45
Use RNSM view controller
lindboe Jan 24, 2024
4e85e2e
Most of iOS setup
lindboe Jan 24, 2024
6ac38fe
iOS fix for now
lindboe Jan 29, 2024
ea3a8be
exhaustive-deps fixes
lindboe Jan 29, 2024
54ec6e2
Add instructions on how to use the XCode debugger with the share exte…
lindboe Jan 29, 2024
779ac09
Code fix, swift crashes with empty NSError
lindboe Jan 29, 2024
307cab1
Clean up code to match other code that does this, debugger was crashi…
lindboe Jan 29, 2024
5f51367
Android and iOS have different data formats. This will account for bo…
lindboe Jan 29, 2024
e2e2698
WIP updated iOS instructions
lindboe Jan 30, 2024
40f40eb
Configure iOS deployment target
lindboe Jan 30, 2024
4030a72
Fix basic example not being able to read user-provided message content
lindboe Jan 30, 2024
77790da
Add troubleshooting steps to iOS instructions
lindboe Jan 30, 2024
901b097
Set up expected symlinks for custom example project
lindboe Jan 30, 2024
366602a
Rename things and set up share extension
lindboe Jan 30, 2024
2476936
Update for APPLICATON_EXTENSION
lindboe Jan 30, 2024
ec4ea1c
Update custom JS app to match basic
lindboe Jan 30, 2024
47e6d47
Documentation updates
lindboe Jan 30, 2024
2c01c04
Bridging header and view controllers
lindboe Jan 31, 2024
c16b41f
Info.plist updates
lindboe Jan 31, 2024
5b0c0ab
Add ShareMenuManager
lindboe Jan 31, 2024
1c2a1fa
Update custom example with previous share extension UI
lindboe Feb 2, 2024
c43d032
Delete old example app
lindboe Feb 2, 2024
1982bd4
Update README
lindboe Feb 2, 2024
861d239
Update debugger instructions with images
lindboe Feb 8, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ project.xcworkspace
node_modules/
npm-debug.log

# yarn
yarn.lock

# Logs
logs
*.log
Expand Down
37 changes: 37 additions & 0 deletions IOS_DEBUGGING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Debugging the iOS share extension

If you're seeing unexpected behavior on iOS, you'll want to debug the native share extension code.

## Set breakpoints in Xcode

1. Open your app's iOS project in Xcode (using the `.xcworkspace` file).
2. Navigate to your app's share extension folder (in the basic example project, `rnsmBasicShare`) and click on the `ShareViewController` file. Click line numbers in this file to add debugger breakpoints.

### Adding breakpoints to other files

If you want to add breakpoints in other files, not just the view controller, here are a few ways to find them so you can open them:

1. Follow your code path by right-clicking on code and using `Jump to definition` to add specific breakpoints within that implementation
2. If you know what file you want, you can filter the project for it by focusing the project filter with `CMD+Alt+J` and search for it (try "ShareMenu").
3. To search for text in the whole project, use `CMD+Shift+F` to bring up the search menu. If you want your search to include Pods, including all the files in this library, make sure the "Search Scope" beneath the search field says "In Workspace".

## Attach to the share extension process before it starts

The easiest way to debug the share extension is to build and run your main app like you normally would, and then tell the Xcode debugger to attach to the share extension when it starts.

1. Build and run your main app.
2. In Xcode, navigate to "Debug" > "Attach to process by PID or name...".
3. In the "PID or Process Name" field, input the name of your share extension target (in the basic example project, this is `rnsmBasicShare`). In the bar at the top of the Xcode window, you should see "Waiting to attach to *shareExtensionProcessName*...".
![Waiting to attach screenshot](screenshots/debuggerWaiting.png)
4. On your iOS simulator or device, launch your share extension by sharing something to it. You should see "Running *shareExtensionProcessName*..." in th e top bar now.
5. Use your share extension until you hit your first breakpoint. You should now be able to use the debugger in Xcode.
![Debugger usage screenshot](screenshots/debuggerExample.png)
6. Once you finish using the share extension, the debugger will detach and the top bar will say "Finished...". If you need to debug again, follow these steps again, starting from "Debug" > "Attach to process by PID or name...".

### Tips

1. Attaching by name, instead of picking from the list of existing processes, is useful in case you might have an existing `rnsmBasicShare` process that did not exit correctly.
2. If you see "Running *shareExtensionProcessName*..." instead of "Waiting", that means the debugger attached to an already-running process instead. Try closing all apps in use on your device and try again.
3. If you need to attach the debugger to the share extension repeatedly, you can add a custom keybinding for "Attach to process by PID or name..." under "Xcode" > "Settings" > "Key bindings".

For more information on how to use the Xcode debugger, or other debugging tools, see [Apple's documentation](https://developer.apple.com/documentation/xcode/diagnosing-and-resolving-bugs-in-your-running-app).
36 changes: 27 additions & 9 deletions IOS_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ And choosing Share Extension

![Share Extension](screenshots/Xcode-03.png)

Name your extension and make sure you've selected Swift as the language to use
Name your extension and make sure you've selected Swift as the language to use.

Select your new target, go to `Build Settings`, search for `iOS Deployment Target` and make sure it matches your app's target (iOS 10.0 in RN 0.63)

When your extension has been created, delete the `ShareViewController.swift` file generated by Xcode in the extension folder, right click on the folder, and choose `Add Files to "ProjectName"`

On the pop-up, select `node_modules/react-native-share-menu/ios/ShareViewController.swift`. Make sure `Copy items if needed` is NOT selected and that the selected target is your newly created Share Extension
On the pop-up, select `node_modules/react-native-share-menu/ios/ShareViewController.swift`. Make sure `Copy items if needed` is NOT selected and that the selected target is your newly created Share Extension.

![Add View Controller](screenshots/Xcode-04.png)

When prompted, choose to add the bridging header.

## Edit Podfile

Make these changes to your Podfile:
Expand Down Expand Up @@ -54,15 +56,12 @@ target '<PROJECT_NAME>' do
end
end

+target '<SHARE_EXTENSION_NAME>' do
+ use_react_native!
+
+ pod 'RNShareMenu', :path => '../node_modules/react-native-share-menu'
+ # Manually link packages here to keep your extension bundle size minimal
+end
+ target '<SHARE_EXTENSION_NAME>' do
+ inherit! :complete
+ end
```

Run `pod install` in your `ios/` directory.
Run `bundle exec pod install` in your `ios/` directory.

<details>
<summary>If you're using React Native < 0.62</summary>
Expand Down Expand Up @@ -154,3 +153,22 @@ Finally, in your `AppDelegate.m` add the following:
}
@end
```

## Troubleshooting

### Main app does not open when expected

This is likely an issue with your **url scheme configuration**. Double-check that your configuration matches the instructions, and use the example projects as a reference.

### Main app opens after sharing, but the shared data is empty

This is likely an issue with either your **bundle ID configuration or your app group ID configuration**. Double-check that your configuration matches the instructions, and use the example projects as a reference. If you still can't figure out what's wrong, follow the [IOS_DEBUGGING.md](./IOS_DEBUGGING.md) instructions to inspect the native code and the values it's receiving.

### Build error `Sandbox: bash(5466) deny(1) .../ios/Pods/resources-to-copy-rnsmBasicShare.txt`

Disable user script sandboxing (which defaults to on in Xcode 15).

1. In the left hand pane of Xcode, click on your project.
2. On the left side of the center pane, under the "Targets" list, select your share extension.
3. At the top of the center pane, click "Build Settings" and search for "sandboxing".
3. Set "User Script Sandboxing" to "NO" for your share extension.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ react-native link

## [API Docs](API_DOCS.md)

## [Example Project](example/)
## [Example Projects](examples/)

### Example Usage

Expand Down
24 changes: 10 additions & 14 deletions SHARE_EXTENSION_VIEW.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Custom iOS Share View

### If you want a custom sharing view, do these steps
If you want a custom sharing view, follow the steps in [IOS_DEBUGGING.md](./IOS_DEBUGGING.md), and then proceed with the steps below.

## Create Bridging Header
## Add React View Controller

Right click on your Share Extension folder, and choose `New File...`
Right click on your Share Extension folder, and choose `Add Files to "ProjectName"`

Select Objective-C, make sure the target is your Share Extension
On the pop-up, select `node_modules/react-native-share-menu/ios/ReactShareViewController.swift`. Make sure `Copy items if needed` is NOT selected and that the selected target is your newly created Share Extension.

Create the file and say yes when prompted to create a Bridging Header
If prompted, choose to add the bridging header.

Delete the created `.m` file
![React View Controller Instructions](screenshots/Xcode-06.png)

Add the following to the new `Bridging-Header.h` file:
### Edit the bridging header

Add the following to the new `Bridging-Header.h` file in your share extension:

```Objective-c
#import <React/RCTBridge.h>
Expand All @@ -21,13 +23,7 @@ Add the following to the new `Bridging-Header.h` file:
#import <React/RCTRootView.h>
```

## Add React View Controller

Right click on your Share Extension folder, and choose `Add Files to "ProjectName"`

On the pop-up, select `node_modules/react-native-share-menu/ios/ReactShareViewController.swift`. Make sure `Copy items if needed` is NOT selected and that the selected target is your newly created Share Extension

![React View Controller Instructions](screenshots/Xcode-06.png)
### Edit the storyboard

Now go to your `MainInterface.storyboard` and:

Expand Down
6 changes: 0 additions & 6 deletions example/.buckconfig

This file was deleted.

4 changes: 0 additions & 4 deletions example/.eslintrc.js

This file was deleted.

73 changes: 0 additions & 73 deletions example/.flowconfig

This file was deleted.

1 change: 0 additions & 1 deletion example/.gitattributes

This file was deleted.

1 change: 0 additions & 1 deletion example/.watchmanconfig

This file was deleted.

15 changes: 0 additions & 15 deletions example/README.md

This file was deleted.

55 changes: 0 additions & 55 deletions example/android/app/_BUCK

This file was deleted.

Loading