| #
feef0cca |
| 04-May-2022 |
Łukasz Kosmaty <[email protected]> |
[autolinking][ios] Add support for debug only modules (#17331)
# Why
Needed to close https://github.com/expo/expo/issues/17246.
# How
Adds support for debug only modules. Those modules will
[autolinking][ios] Add support for debug only modules (#17331)
# Why
Needed to close https://github.com/expo/expo/issues/17246.
# How
Adds support for debug only modules. Those modules will only be added to the debug configuration.
- Added a `debugOnly` field in the `iOS` section in the `expo-modules-config.json`
- Ensured that debug modules are wrapped using the `#if DEBUG` directive inside of the ExpoModulesProvider
# Test Plan
- bare-expo ✅
ExpoModulesProvider without `debugOnly` modules:
```swift
/**
* Automatically generated by expo-modules-autolinking.
*
* This autogenerated class provides a list of classes of native Expo modules,
* but only these that are written in Swift and use the new API for creating Expo modules.
*/
import ExpoModulesCore
import ExpoCellular
import ExpoClipboard
import ExpoCrypto
import EXDevLauncher
import EXDevMenu
import EASClient
import ExpoHaptics
import ExpoImageManipulator
import ExpoImagePicker
import ExpoKeepAwake
import ExpoLinearGradient
import ExpoLocalization
import ExpoRandom
import EXScreenOrientation
import ExpoSystemUI
import EXTrackingTransparency
import ExpoWebBrowser
@objc(ExpoModulesProvider)
public class ExpoModulesProvider: ModulesProvider {
public override func getModuleClasses() -> [AnyModule.Type] {
return [
CellularModule.self,
ClipboardModule.self,
CryptoModule.self,
EASClientModule.self,
HapticsModule.self,
ImageManipulatorModule.self,
ImagePickerModule.self,
KeepAwakeModule.self,
LinearGradientModule.self,
LocalizationModule.self,
RandomModule.self,
ExpoSystemUIModule.self,
TrackingTransparencyModule.self,
WebBrowserModule.self
]
}
public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
return [
ExpoDevLauncherAppDelegateSubscriber.self,
ScreenOrientationAppDelegate.self
]
}
public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
return [
(packageName: "expo-dev-launcher", handler: ExpoDevLauncherReactDelegateHandler.self),
(packageName: "expo-dev-menu", handler: ExpoDevMenuReactDelegateHandler.self),
(packageName: "expo-screen-orientation", handler: ScreenOrientationReactDelegateHandler.self)
]
}
}
```
ExpoModulesProvider with two `debugOnly` modules:
```swift
/**
* Automatically generated by expo-modules-autolinking.
*
* This autogenerated class provides a list of classes of native Expo modules,
* but only these that are written in Swift and use the new API for creating Expo modules.
*/
import ExpoModulesCore
import ExpoCellular
import ExpoClipboard
import ExpoCrypto
import EASClient
import ExpoHaptics
import ExpoImageManipulator
import ExpoImagePicker
import ExpoKeepAwake
import ExpoLinearGradient
import ExpoLocalization
import ExpoRandom
import EXScreenOrientation
import ExpoSystemUI
import EXTrackingTransparency
import ExpoWebBrowser
#if DEBUG
import EXDevLauncher
import EXDevMenu
#endif
@objc(ExpoModulesProvider)
public class ExpoModulesProvider: ModulesProvider {
public override func getModuleClasses() -> [AnyModule.Type] {
return [
CellularModule.self,
ClipboardModule.self,
CryptoModule.self,
EASClientModule.self,
HapticsModule.self,
ImageManipulatorModule.self,
ImagePickerModule.self,
KeepAwakeModule.self,
LinearGradientModule.self,
LocalizationModule.self,
RandomModule.self,
ExpoSystemUIModule.self,
TrackingTransparencyModule.self,
WebBrowserModule.self
]
}
public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
#if DEBUG
return [
ScreenOrientationAppDelegate.self,
ExpoDevLauncherAppDelegateSubscriber.self
]
#else
return [
ScreenOrientationAppDelegate.self
]
#endif
}
public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
#if DEBUG
return [
(packageName: "expo-screen-orientation", handler: ScreenOrientationReactDelegateHandler.self),
(packageName: "expo-dev-launcher", handler: ExpoDevLauncherReactDelegateHandler.self),
(packageName: "expo-dev-menu", handler: ExpoDevMenuReactDelegateHandler.self)
]
#else
return [
(packageName: "expo-screen-orientation", handler: ScreenOrientationReactDelegateHandler.self)
]
#endif
}
}
```
show more ...
|
| #
7aeb2b0c |
| 14-Mar-2022 |
Kudo Chien <[email protected]> |
[autolinking] Support multiple podspecs and gradle projects in a package (#16511)
# Why
- support the case where a package has multiple podspecs, e.g. [react-native-maps](https://github.com/reac
[autolinking] Support multiple podspecs and gradle projects in a package (#16511)
# Why
- support the case where a package has multiple podspecs, e.g. [react-native-maps](https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md#enabling-google-maps)
- being less intrusive to 3rd party libraries when we proposing expo integration. for example, current integration to [reanimated add one line to existing code](https://github.com/software-mansion/react-native-reanimated/blob/a870aa28092322b627695f8cf2ea0dce4db34a53/android-npm/build.gradle#L111) and [turn reanimated gradle project to a different form](https://github.com/software-mansion/react-native-reanimated/blob/a870aa28092322b627695f8cf2ea0dce4db34a53/android-npm/expo/linking.gradle#L15-L45).
- expo reanimated integration had introduced some issues as following. based on this, i think we should have a dedicated gradle project.
- https://github.com/software-mansion/react-native-reanimated/issues/2711
- https://github.com/software-mansion/react-native-reanimated/pull/2713#issuecomment-1024341773
# How
- support multiple podspec linking - `*/*.podspec`
- support multiple build.gradle linking - `*/build.gradle`
- ~introduce special expo adapter integration where we can put all stuffs including `expo-module.config.json` in `expo/` folder
in this case, rn-cli's autolinking will link `RNThirdParty.podspec` and `android/build.gradle`. expo autolinking will link `RNThirdPartyExpoAdapter.podspec` and `expo/android/build.gradle`~
- add expo-module.config.js `android.gradlePath` support to specify custom gradle file paths.
# Test Plan
## Unit Tests
```
PASS src/platforms/__tests__/android-test.ts
resolveModuleAsync
✓ should resolve android/build.gradle (2 ms)
✓ should resolve multiple gradle files (1 ms)
convertPackageNameToProjectName
✓ should strip invalid characters (1 ms)
✓ should convert scoped package name to dash
✓ should have differentiated name for multiple projects
✓ should support expo adapter name
PASS src/autolinking/__tests__/findModules-test.ts
findModulesAsync
✓ should link top level package (2 ms)
✓ should link scoped level package (1 ms)
PASS src/platforms/__tests__/ios-test.ts
resolveModuleAsync
✓ should resolve podspec in ios/ folder
✓ should resolve multiple podspecs (1 ms)
```
## Integration Tests
- create extra `ios2/EXApplication2.podspec` in expo-application
- create extra `android2/build.gradle` in expo-application
- check rn-cli autolinking and expo autolinking co-existence compatibility
- move `use_native_modules!` before `use_expo_modules!` in Podfile
- create extra `ios2/RNReanimated2.podspec` in reanimated and check whether it's linked.
Co-authored-by: Tomasz Sapeta <[email protected]>
show more ...
|
| #
0f5f192f |
| 01-Dec-2021 |
Kudo Chien <[email protected]> |
[core] Introduce iOS ReactDelegate for React related instances creation (#15138)
# Why
original modularized AppDelegateWrapper isn't ideal for expo-updates. we had some bad side effect, e.g. doub
[core] Introduce iOS ReactDelegate for React related instances creation (#15138)
# Why
original modularized AppDelegateWrapper isn't ideal for expo-updates. we had some bad side effect, e.g. double bridge creation on startup.
close ENG-2299
# How
## For module authors
introduce `EXReactDelegate` dedicated for react related instances creation. so far we covered:
- RCTBridge
- RCTRootView
- RootViewController (for expo-screen-orientation)
if a module wants to handle these creation, there's 2 steps:
1. add `reactDelegateHandlers` in `expo-module.config.json`, e.g.
```
"ios": {
"reactDelegateHandlers": ["ScreenOrientationReactDelegateHandler"]
}
```
2. create `EXReactDelegateHandler` derived swift class, e.g.
```swift
// ScreenOrientationReactDelegateHandler.swift
public class ScreenOrientationReactDelegateHandler: ExpoReactDelegateHandler {
public override func createRootViewController(reactDelegate: ExpoReactDelegate) -> UIViewController? {
return EXScreenOrientationViewController()
}
}
```
since the order of whom to create the instance did matter, we also introduce `ModulePriorities.swift` similar to what we did on android.
## For app developers
the change to template is minimal, so codemod by `npx install-expo-modules` is also feasible.
```diff
- RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
- RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
+ RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
+ RCTRootView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"main" initialProperties:nil];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
- UIViewController *rootViewController = [UIViewController new];
+ UIViewController *rootViewController = [self.reactDelegate createRootViewController];
```
show more ...
|