Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Expo config plugin #842

Closed

Conversation

EvanBacon
Copy link

Why

With Expo SDK 41 we've rolled out an interface called config plugins which lets users add native modules that aren't in the Expo Go app to their native cloud builds and locally when prebuilding.

This is a highly requested package so I've created the plugin personally.

We’re still working on improving the development experience for config plugins and custom managed workflow, feel free to add any feedback. People won’t be able to use this in an Expo-Go-like-app until we release “Expo Development Client” (more info).

How

  • Added a /plugin folder and an app.plugin.js as the main entry point to the plugin. Plugins must run in at node LTS environments (currently that means 12 and greater), so a custom tsconfig.json is used for transpilation.
  • The plugin is like a different package that's vendored for versioning purposes. Building is done with tsc --build plugin (yarn build:plugin).

Test Plan

I'm not certain how to test this package in the repo, so I did it externally.

  • Run npm pack in the package
  • Install the package in a managed Expo project yarn add react-native-ble-plx@../react-native-ble-plx/react-native-ble-plx-2.0.2.tgz
  • Then add react-native-ble-plx to the plugins array and build the native app locally with expo prebuild and yarn ios, yarn android. We plan to further automate these steps with expo install and expo run commands.

Modified some values and in the config plugin and updated with expo prebuild and yarn ios, yarn android.

@CLAassistant
Copy link

CLAassistant commented Apr 28, 2021

CLA assistant check
All committers have signed the CLA.

@EvanBacon EvanBacon marked this pull request as ready for review May 12, 2021 16:36
@EvanBacon EvanBacon force-pushed the @evanbacon/config-plugin/create branch from 64a1ccc to fdf3fc6 Compare May 26, 2021 21:51
@dashcraft
Copy link

Bump?

@sadilekivan
Copy link

I would really like to try out this way of adding a native package to expo, I cloned the repo, build tsc, and supplied the app.json with a path to the package. Almost thought I got it working, but when running expo prebuild I receive Unexpected token 'export'. Excuse me if it's intrusive/unfit to ask for advice here, just unsure how to continue now.

@amsimon
Copy link

amsimon commented Jun 8, 2021

Do you need help approving this? We all would love to start using this feature. Thanks.

@EvanBacon
Copy link
Author

EvanBacon commented Jun 9, 2021

@sadilekivan follow the steps mentioned in the test plan, run npm pack and install the tar in your project. I imagine the issue you experienced was that the tsc for the plugin wasn't run. Also try installing vscode-expo for more insight into plugin errors.

If you open the app.json, add react-native-ble-plx to plugins, then open the prebuild preview (⌘-⇧-p -> "Expo: Preview modifier" -> "ios.infoPlist") you should see the following modifications are made to your Info.plist:

Screen Shot 2021-06-09 at 1 38 32 PM

You should see similar results in your AndroidManifest.xml preview.

@sadilekivan
Copy link

@EvanBacon

Thanks for the advice, I'm having a problem packing the repo. When I want to get an http link from the green button at git I clone some other repo without the plugin folder (This one to be exact https://github.com/EvanBacon/react-native-ble-plx.git).

I did try to just copy the link from an urlbar (https://github.com/EvanBacon/react-native-ble-plx/tree/%40evanbacon/config-plugin/create) which seems to be the correct one, but it doesnt pack nor install with npm, im guessing the @ and / symbols?

npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json:
https://github.com/EvanBacon/react-native-ble-plx/tree/%40evanbacon/config-plugin/create.

I manually downloaded the folder but still cant pack it. I installed yarn but Im still missing expo-modules.

$ npm pack react-native-ble-plx--evanbacon-config-plugin-create/

> react-native-ble-plx@2.0.2 prepare C:\Users\Ivan\.workspace\Expo\PoultryScale\react-native-ble-plx--evanbacon-config-plugin-create   
> npm run clean:plugin && npm run build:plugin

> react-native-ble-plx@2.0.2 clean:plugin C:\Users\Ivan\.workspace\Expo\PoultryScale\react-native-ble-plx--evanbacon-config-plugin-create
> expo-module clean plugin

'expo-module' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1

I looked it up but found expo-module-scripts which isnt what it wants I think.

Any clue to what I'm missing? I can run the expo command fine, env vars should be okay too. Thanks in advance, I value your feedback.

@dashcraft
Copy link

@piotrdubiel @dariuszseweryn @Cierpliwy is there anything the community can do to get some eyes on this PR?

@dariuszseweryn dariuszseweryn added the pending Issues that are planned to be worked on at some point in the future label Jun 12, 2021
@EvanBacon
Copy link
Author

@sadilekivan download this file, change the filename to react-native-ble-plx-2.0.2.tgz (removing .zip), and install the package in your project.
react-native-ble-plx-2.0.2.tgz.zip

@dariuszseweryn
Copy link
Collaborator

I ask you for a little bit more patience. I do not have capacity at the moment to test it out and this repository will most probably start to be maintained by someone else in the following days. 👍

@luka2i
Copy link

luka2i commented Jun 18, 2021

😢😢😢 when? 😢😢😢

@dashcraft
Copy link

@EvanBacon could you write a blog post on how to fork this repo and build this plugin for expo?
I've tried several times to get it working but I think there's a step in here I'm missing. It just says
not a valid plugin or no plugin found, etc.

@EvanBacon
Copy link
Author

EvanBacon commented Jun 29, 2021

@dashcraft you can use this out-of-tree solution in the meantime @config-plugins/react-native-ble-plx. It's not versioned with the code so YMMV over time, but for now it works great!

@Spoutnik97
Copy link

@EvanBacon thanks for your great work! It works fine for me !!!
Maybe a fix to the CI could help the repository owner to merge your PR?

@outinspace
Copy link

Is this PR still needed to use this library with Expo development clients?

@EvanBacon
Copy link
Author

@outinspace you can use the out-of-tree plugin in the meantime (mentioned just two comments before yours #842 (comment)).

@givebk-bot
Copy link

Hey! Looks like someone invited me to this issue.

@antl3x
Copy link

antl3x commented May 14, 2022

@givebk-bot !donate @EvanBacon $1

thanks for the out-of-tree solution!

@givebk-bot
Copy link

givebk-bot commented May 14, 2022 via email

@Wolfleader101
Copy link

Wolfleader101 commented Jan 18, 2023

Just wondering when/if this will ever be merged?
Would be nice if it just worked, so we didn't need to install the config-plugin.

@fabiendem
Copy link

@Wolfleader101 see #908 (comment)

@dashcraft
Copy link

@Wolfleader101 see #908 (comment)

The issue is that ble-manager doesn't support expo configs at all, so all the work would have to be done again.

The idea that a react native package that can be ported, wouldn't have the configs necessary for the expo is problematic.

@fabiendem
Copy link

@dashcraft I don't know what to say
https://github.com/dotintent/react-native-ble-plx/ doesn't seem to be maintained anymore, this expo config may never merge, and even if it merges, we will have a Bluetooth library for expo which is not maintained.
https://github.com/innoveit/react-native-ble-manager is maintained for now, so maybe one can do the expo wrapper for it.

@dominik-czupryna-withintent
Copy link
Collaborator

The library had a support gap but we are currently working on expo prebuild feature support. This PR has become outdated over time so we will make the necessary changes for the latest versions.

@dominik-czupryna-withintent
Copy link
Collaborator

Updated in #1105 and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending Issues that are planned to be worked on at some point in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.