react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Adding Expo plugin for expo support without the bare workflow

Open RichardLindhout opened this issue 2 years ago β€’ 9 comments

πŸš€ Feature

Since Expo now supports plugins we could add support for react-native-navigation with ejecting expo. https://docs.expo.dev/guides/config-plugins/

Motivation

Easier building of apps with Expo EAS build Access to Expo ecosystem Less configuration of react-native-navigation

Pitch

A lot of users will come to react-native-navigation ecosystem because expo is the 'standard' now. Existing users will benefit with a lot less native configuration and easier building of app with EAS build.

Are you willing to resolve this issue by submitting a Pull Request?

Maybe, but I'm really short in time at the moment.

RichardLindhout avatar May 27 '22 18:05 RichardLindhout

We could probably use the same functions as in https://github.com/wix/react-native-navigation/tree/616ceac1350e78c0b54dc55cc509efca9178736e/autolink/postlink

RichardLindhout avatar May 27 '22 18:05 RichardLindhout

For example see mapbox example here: https://github.com/rnmapbox/maps/blob/main/plugin/build/withMapbox.js

RichardLindhout avatar May 27 '22 18:05 RichardLindhout

I'm experimenting here: https://github.com/web-ridge/expo-expirement/blob/main/patches/react-native-navigation%2B7.28.0.patch

RichardLindhout avatar May 27 '22 20:05 RichardLindhout

import {
  withProjectBuildGradle,
  ConfigPlugin,
  createRunOncePlugin,
  withInfoPlist,
  withMainActivity,
  withAppDelegate,
  withMainApplication,
  withPodfileProperties,
} from "@expo/config-plugins";
import ActivityLinker from "../../autolink/postlink/activityLinker";
import AppDelegateLinker from "../../autolink/postlink/appDelegateLinker";
import ApplicationLinker from "../../autolink/postlink/applicationLinker";
import GradleLinker from "../../autolink/postlink/gradleLinker";
import PlistLinker from "../../autolink/postlink/plistLinker";
import PodFileLinker from "../../autolink/postlink/podfileLinker";

export const withActivityLinker: ConfigPlugin = (config) => {
  return withMainActivity(config, (config) => {
    const l = new ActivityLinker();
    return l.linkContent(config.modResults.contents);
  });
};

export const withAppDelegateLinker: ConfigPlugin = (config) => {
  return withAppDelegate(config, (config) => {
    const l = new AppDelegateLinker();
    return l.linkContent(config.modResults.contents);
  });
};

export const withApplicationLinker: ConfigPlugin = (config) => {
  return withMainApplication(config, (config) => {
    const l = new ApplicationLinker();
    return l.linkContent(config.modResults.contents);
  });
};

export const withGradleLinker: ConfigPlugin = (config) => {
  return withProjectBuildGradle(config, (config) => {
    const l = new GradleLinker();
    return l.linkContent(config.modResults.contents);
  });
};

export const withPlistLinker: ConfigPlugin = (config) => {
  return withInfoPlist(config, (config) => {
    const l = new PlistLinker();
    return l.linkContent(config.modResults.contents);
  });
};

export const withPodfileLinker: ConfigPlugin = (config) => {
  return withPodfileProperties(config, (config) => {
    const l = new PodFileLinker();
    return l.linkContent(config.modResults.contents);
  });
};

const pkg = require("react-native-navigation/package.json");

const withRNN: ConfigPlugin<{
  exampleConfigProp?: boolean;
}> = (config, { exampleConfigProp } = {}) => {
  // android
  config = withApplicationLinker(config);
  config = withActivityLinker(config);
  config = withGradleLinker(config);

  // ios
  config = withAppDelegateLinker(config);
  config = withPodfileLinker(config);
  config = withPlistLinker(config);

  return config;
};

export default createRunOncePlugin(withRNN, pkg.name, pkg.version);

RichardLindhout avatar May 27 '22 20:05 RichardLindhout

Schermafbeelding 2022-05-27 om 23 15 07

RichardLindhout avatar May 27 '22 21:05 RichardLindhout

oreFoundation] *** Terminating app due to
uncaught exception
'NSInvalidArgumentException', reason:
'Application tried to present modally a view
controller <UIViewController: 0x7f7c226119b0>
that is already being presented by
<UIViewController: 0x7f7c22008da0>.'
*** First throw call stack:
(
0   CoreFoundation
0x00007fff203feba4 __exceptionPreprocess + 242
1   libobjc.A.dylib
0x00007fff201a1be7 objc_exception_throw + 48
2   UIKitCore
0x00007fff248b0982 -[UIViewController
_presentViewController:withAnimationController:completion:]
+ 5854
3   UIKitCore
0x00007fff248b1450 __63-[UIViewController
_presentViewController:animated:completion:]_block_invoke
+ 98
4   UIKitCore
0x00007fff248cc98e
-[_UIViewControllerTransitionCoordinator
_applyBlocks:releaseBlocks:] + 294
5   UIKitCore
0x00007fff248c8cc0
-[_UIViewControllerTransitionContext
_runAlongsideCompletions] + 126
6   UI<…>

RichardLindhout avatar May 27 '22 22:05 RichardLindhout

The expo application file differs much from the react native files so will need custom config changers. I'll stop the expirement now but it could work!

RichardLindhout avatar May 27 '22 22:05 RichardLindhout

ζˆ‘εœ¨θΏ™ι‡Œθ―•ιͺŒοΌšhttps ://github.com/web-ridge/expo-expirement/blob/main/patches/react-native-navigation%2B7.28.0.patch

I researched this repo, and I didn't find that the registration method of expo is executed. This seems to be an implementation suitable for the web version, not a native implementation.

fencer-yd avatar Jun 18 '22 09:06 fencer-yd

Is Wix interested in working with expo?

JimTeva avatar Nov 24 '23 00:11 JimTeva