Closed jaimepater closed 3 years ago
@jaimepater instead of ejecting your app, create an app for expo with the bare workflow.
We've seen a lot of issues of user ejecting from Expo managed workflow.
@JonatanSalas Thanks for your answer
I made a test with the bare workflow, but I am getting the following error
error: definition of 'RCTBridge' must be imported from module 'UMReactNativeAdapter.UMReactNativeEventEmitter' before it is required
The next files are with bare workflow
this is my AppDelegate.m
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
@interface AppDelegate ()
@property (nonatomic, strong) NSDictionary *launchOptions;
@end
@implementation AppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
self.launchOptions = launchOptions;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
#ifdef DEBUG
[self initializeReactNativeApp];
#else
EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance];
controller.delegate = self;
[controller startAndShowLaunchScreen:self.window];
#endif
[super application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (RCTBridge *)initializeReactNativeApp
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return bridge;
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// You can inject any extra modules that you would like here, more information at:
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[EXUpdatesAppController sharedInstance] launchAssetUrl];
#endif
}
- (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success
{
appController.bridge = [self initializeReactNativeApp];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *) options {
return [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url];
}
@end
Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
install! 'cocoapods', :disable_input_output_paths => true
target 'cmAppointmentsFed' do
use_unimodules!
config = use_native_modules!
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec', :modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
use_modular_headers!
use_react_native!(:path => config["reactNativePath"])
# Uncomment the code below to enable Flipper.
#
# You should not install Flipper in CI environments when creating release
# builds, this will lead to significantly slower build times.
#
# Note that if you have use_frameworks! enabled, Flipper will not work.
#
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
end
@JonatanSalas Thanks for your answer
I made a test with the bare workflow, but I am getting the following error
error: definition of 'RCTBridge' must be imported from module 'UMReactNativeAdapter.UMReactNativeEventEmitter' before it is required
The next files are with bare workflow
this is my
AppDelegate.m
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "AppDelegate.h" #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h> #import <UMCore/UMModuleRegistry.h> #import <UMReactNativeAdapter/UMNativeModulesProxy.h> #import <UMReactNativeAdapter/UMModuleRegistryAdapter.h> @interface AppDelegate () @property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation AppDelegate @synthesize window = _window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]]; self.launchOptions = launchOptions; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; #ifdef DEBUG [self initializeReactNativeApp]; #else EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance]; controller.delegate = self; [controller startAndShowLaunchScreen:self.window]; #endif [super application:application didFinishLaunchingWithOptions:launchOptions]; return YES; } - (RCTBridge *)initializeReactNativeApp { RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return bridge; } - (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge { NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge]; // You can inject any extra modules that you would like here, more information at: // https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection return extraModules; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #ifdef DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[EXUpdatesAppController sharedInstance] launchAssetUrl]; #endif } - (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success { appController.bridge = [self initializeReactNativeApp]; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *) options { return [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]; } @end
Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/react-native-unimodules/cocoapods.rb' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '10.0' install! 'cocoapods', :disable_input_output_paths => true target 'cmAppointmentsFed' do use_unimodules! config = use_native_modules! pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec', :modular_headers => false pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false use_modular_headers! use_react_native!(:path => config["reactNativePath"]) # Uncomment the code below to enable Flipper. # # You should not install Flipper in CI environments when creating release # builds, this will lead to significantly slower build times. # # Note that if you have use_frameworks! enabled, Flipper will not work. # # use_flipper! # post_install do |installer| # flipper_post_install(installer) # end end
I had the same problem. My solution was to import the library <UMReactNativeAdapter/UMReactNativeEventEmitter.h> in the AppDelegate.m file on my ios proyect.
Thanks @ltorua , that resolves my Issue :)
but I have a new one :(
ld: warning: Could not find or use auto-linked library 'swiftWebKit'
Undefined symbols for architecture x86_64:
"__swift_FORCE_LOAD_$_swiftWebKit", referenced from:
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(DefaultCardUIHandler.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormBaseViewController.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormBuilder.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardForm.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormESCConfig.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormField.o)
__swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormIssuersViewController.o)
...
(maybe you meant: __swift_FORCE_LOAD_$_swiftWebKit_$_blackbox_vision_react_native_mercadopago_px, __swift_FORCE_LOAD_$_swiftWebKit_$_MercadoPagoSDK , __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I appreciate if you can help me @JonatanSalas @ltorua
Thanks @ltorua , that resolves my Issue :)
but I have a new one :(
ld: warning: Could not find or use auto-linked library 'swiftWebKit' Undefined symbols for architecture x86_64: "__swift_FORCE_LOAD_$_swiftWebKit", referenced from: __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(DefaultCardUIHandler.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormBaseViewController.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormBuilder.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardForm.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormESCConfig.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormField.o) __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm in libMLCardForm.a(MLCardFormIssuersViewController.o) ... (maybe you meant: __swift_FORCE_LOAD_$_swiftWebKit_$_blackbox_vision_react_native_mercadopago_px, __swift_FORCE_LOAD_$_swiftWebKit_$_MercadoPagoSDK , __swift_FORCE_LOAD_$_swiftWebKit_$_MLCardForm ) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I appreciate if you can help me @JonatanSalas @ltorua
I forgot to mention that in my ios project I added a Swift file (for other different reasons). That may help you, just add and empty Swift file and then confirm "Create Bridging Header".
Btw i'm using Expo sdk 40 (Ejected) and Xcode 12.4
My AppDelegate.m
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#import <Firebase.h>
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#import <UMReactNativeAdapter/UMReactNativeEventEmitter.h>
#import <EXSplashScreen/EXSplashScreenService.h>
#import <UMCore/UMModuleRegistryProvider.h>
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@interface AppDelegate () <RCTBridgeDelegate>
@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@property (nonatomic, strong) NSDictionary *launchOptions;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if defined(FB_SONARKIT_ENABLED) && __has_include(<FlipperKit/FlipperClient.h>)
InitializeFlipper(application);
#endif
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
self.launchOptions = launchOptions;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
#ifdef DEBUG
[self initializeReactNativeApp];
#else
EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance];
controller.delegate = self;
[controller startAndShowLaunchScreen:self.window];
#endif
[super application:application didFinishLaunchingWithOptions:launchOptions];
// Define UNUserNotificationCenter
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
return YES;
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}
- (RCTBridge *)initializeReactNativeApp
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
// self.window.rootViewController = rootViewController;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[navController setToolbarHidden:YES animated:YES];
[navController setNavigationBarHidden:YES];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return bridge;
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here!
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[EXUpdatesAppController sharedInstance] launchAssetUrl];
#endif
}
- (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success {
appController.bridge = [self initializeReactNativeApp];
EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]];
[splashScreenService showSplashScreenFor:self.window.rootViewController];
}
// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [RCTLinkingManager application:application openURL:url options:options];
}
// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
}
@end
My Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
install! 'cocoapods', :disable_input_output_paths => true
target 'RNProyecto' do
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec', :modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
use_modular_headers!
use_unimodules!
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
# Uncomment the code below to enable Flipper.
#
# You should not install Flipper in CI environments when creating release
# builds, this will lead to significantly slower build times.
#
# Note that if you have use_frameworks! enabled, Flipper will not work.
#
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
end
Note: My AppDelegate.m file is different since i'm algo using an external firebase dependence , it does not affect anything on this, it just add some other libraries.
I'll close this issue since it was related to missing Bridging Header which is now well documented.
Describe the bug When I trying to do the IOS build on a ejected Expo ejected App, I am getting this error
To Reproduce Steps to reproduce the behavior:
Smartphone (please complete the following information):
Additional context this is my
AppDelegate.m
and my
Podfile