react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

Added Expo config plugin

Open EvanBacon opened this issue 3 years ago • 18 comments

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.

EvanBacon avatar Apr 28 '21 06:04 EvanBacon

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 28 '21 06:04 CLAassistant

Bump?

dashcraft avatar Jun 01 '21 00:06 dashcraft

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.

sadilekivan avatar Jun 08 '21 17:06 sadilekivan

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

amsimon avatar Jun 08 '21 17:06 amsimon

@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.

EvanBacon avatar Jun 09 '21 18:06 EvanBacon

@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/

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

> [email protected] 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.

sadilekivan avatar Jun 10 '21 19:06 sadilekivan

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

dashcraft avatar Jun 11 '21 01:06 dashcraft

@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

EvanBacon avatar Jun 13 '21 03:06 EvanBacon

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. 👍

dariuszseweryn avatar Jun 13 '21 12:06 dariuszseweryn

😢😢😢 when? 😢😢😢

luka2i avatar Jun 18 '21 18:06 luka2i

@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.

dashcraft avatar Jun 26 '21 15:06 dashcraft

@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!

EvanBacon avatar Jun 29 '21 05:06 EvanBacon

@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?

Spoutnik97 avatar Nov 12 '21 09:11 Spoutnik97

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

outinspace avatar Dec 09 '21 19:12 outinspace

@outinspace you can use the out-of-tree plugin in the meantime (mentioned just two comments before yours https://github.com/dotintent/react-native-ble-plx/pull/842#issuecomment-870244083).

EvanBacon avatar Dec 10 '21 18:12 EvanBacon

Hey! Looks like someone invited me to this issue.

givebk-bot avatar May 14 '22 12:05 givebk-bot

@givebk-bot !donate @EvanBacon $1

thanks for the out-of-tree solution!

antl3x avatar May 14 '22 12:05 antl3x

🎁 Hey @EvanBacon, you have just received U$ 1 from @nthypes!

@nthypes thanks for your support! ❤️

@EvanBacon, you can check your balance at https://givebk.io.

═══

(powered by https://givebk.io) ID: 360c595b-560d-4097-a682-b75c3fb69422

givebk-bot avatar May 14 '22 12:05 givebk-bot

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.

Wolfleader101 avatar Jan 18 '23 10:01 Wolfleader101

@Wolfleader101 see https://github.com/dotintent/react-native-ble-plx/issues/908#issuecomment-1280663005

fabiendem avatar Jan 23 '23 17:01 fabiendem

@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.

dashcraft avatar Jan 24 '23 20:01 dashcraft

@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.

fabiendem avatar Jan 26 '23 16:01 fabiendem

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.

Updated in https://github.com/dotintent/react-native-ble-plx/pull/1105 and merged