Skip to content

Conversation

lindboe
Copy link

@lindboe lindboe commented Feb 2, 2024

Why this PR?

This PR replaces the old example app with two new example apps: one to show "basic" share, with both Android and the default, non-customizable iOS share, and "custom", which demos creating a custom react-native UI in the share extension.

These example projects have been created using latest react-native so that it's easier to test changes to the library.

Note:

Additional changes

  1. I copied the existing example where I could, but ran into some bugs with data being undefined (expectedly) causing crashes, so I did alter the code where I needed to in order to avoid crashes.
  2. I updated documentation where I could to reflect current Xcode behavior
  3. I added a new file, IOS_DEBUGGING.md, that should help empower developers to track down any issues they encountering in the share extension
  4. I used metro's new symlinking support instead of the previous modification in use, and also added dev dependencies to the library (and symlinked those in the app) for better editor support when modifying the library
    a. react-native must be symlinked so that the app's copy and the library's copy are the same, or events won't work
  5. I added a few Swift fixes while debugging an issue with the basic app:
    a. fixed an issue with NSError that caused Xcode to complain
    b. Made the code to store data on UserDefaults more consistent across code paths (updated to match here).
    c. Fixed the issue that text sent in the share extension UI in the "basic" case was not sent, and so the demo code couldn't show extraData

Additional notes:

  1. When previewing the docs with new screenshots files added, they won't render correctly on the PR. This is a long-standing issue with GitHub markdown and PRs.
  2. The custom share extension example does have a bug that has existed for a while: every second share attempt can crash. This should be fixed by Fix detach view delegate #271.

Copied from previous example app
Non-link installs were taking too long to iterate with. This approach
makes installs faster.

Need to also run react-native as linked with the library's specific copy
-- otherwise library events do not work properly. yikes.

Also had to reinstall pods after symlink fix
...to reduce errors in example projects. (VS Code will only use a
tsconfig at project root, not nested within example projects, consider
if we want to keep this)
TODO:
- ios deployment target setting matching app
- document disabling user sandboxing?
Clean up code while fixing issue with mimetype being undefined on iOS
when app is first started with no share
Update share extension's iOS deployment target to match react-native's
Url schemes, RN-specific data for share extension
Added an additional fix for "startsWith" which may error if mimeType is
undefined

This may not be fully functional yet, based on experience with copying
the prior example app UI for the basic app. Would still need to test it
out more. But sharing a photo to the main app worked.
@lindboe lindboe marked this pull request as draft February 2, 2024 23:36
@lindboe lindboe marked this pull request as ready for review February 8, 2024 01:05
@lindboe lindboe closed this Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant