每次从react-native 0.61.5迁移到0.69.12后构建我的应用程序时,我都会在AppDelegate.h上收到错误“'RNAAppAuthAuthorizationFlowManager.h'文件未找到”。
AppDelegate.h:
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <React/RCTLinkingManager.h>
#import <AppAuth/AppAuth.h>
#import "RNAppAuthAuthorizationFlowManager.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, RNAppAuthAuthorizationFlowManager>
@property (nonatomic, strong) UIWindow *window;
@property(nonatomic, weak)id<RNAppAuthAuthorizationFlowManagerDelegate>authorizationFlowManagerDelegate;
@end
AppDelegate.mm:
#import <React/RCTBridge.h>
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTAppSetupUtils.h>
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
#import <Firebase.h>
#import <PushIOManager/PushIOManager.h>
#import <UserNotifications/UserNotifications.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTLinkingManager.h>
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
@interface AppDelegate () <UNUserNotificationCenterDelegate, RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
RCTTurboModuleManager *_turboModuleManager;
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTAppSetupPrepareApp(application);
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
#if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif
NSDictionary *initProps = [self prepareInitialProps];
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"stix", initProps);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[UNUserNotificationCenter currentNotificationCenter].delegate= self;
#ifdef DEBUG
[[PushIOManager sharedInstance] setLoggingEnabled:YES];
[[PushIOManager sharedInstance] setLogLevel:PIOLogLevelInfo];
#else
[[PushIOManager sharedInstance] setLoggingEnabled:NO];
#endif
[[PushIOManager sharedInstance] didFinishLaunchingWithOptions:launchOptions];
[PushIOManager sharedInstance].notificationPresentationOptions = UNNotificationPresentationOptionAlert|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionBadge;
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
return YES;
}
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL) application:(UIApplication *)application
openURL:(NSURL *)url
options: (NSDictionary<UIApplicationOpenURLOptionsKey, id> *) options
{
if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
return YES;
}
return [RCTLinkingManager application:application openURL:url options:options];
}
- (BOOL) application:(UIApplication *)application
continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
if (self.authorizationFlowManagerDelegate) {
BOOL resumableAuth = [self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:userActivity.webpageURL];
if (resumableAuth) {
return YES;
}
}
}
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
// Switch this bool to turn on and off the concurrent root
return true;
}
- (NSDictionary *)prepareInitialProps
{
NSMutableDictionary *initProps = [NSMutableDictionary new];
#ifdef RCT_NEW_ARCH_ENABLED
initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
#endif
return initProps;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
#if RCT_NEW_ARCH_ENABLED
#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
}
#pragma mark RCTTurboModuleManagerDelegate
- (Class)getModuleClassFromName:(const char *)name
{
return RCTCoreModulesClassProvider(name);
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return nullptr;
}
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
#endif
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:
(NSData *)deviceToken
{
[[PushIOManager sharedInstance] didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[[PushIOManager sharedInstance] didFailToRegisterForRemoteNotificationsWithError:error];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo];
NSDictionary *payload = [userInfo objectForKey:@"aps"];
NSString *alertMessage = [payload objectForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:alertMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
-(void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:
(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler
{
[[PushIOManager sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
-(void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:
(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
[[PushIOManager sharedInstance] userNotificationCenter:center willPresentNotification:notification
withCompletionHandler:completionHandler];
}
@end
Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
def shared_pods
$RNFirebaseAsStaticFramework = true
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'Permission-AppTrackingTransparency', :path => "../node_modules/react-native-permissions/ios/AppTrackingTransparency"
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
end
target 'stix dev' do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false,
:fabric_enabled => flags[:fabric_enabled],
# :flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
use_frameworks! :linkage => :static
# Pods for stix
shared_pods
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
target 'stix dev (embedded)' do
# Pods for stix
shared_pods
end
target 'stix staging' do
# Pods for stix
shared_pods
end
target 'stix staging (embedded)' do
# Pods for stix
shared_pods
end
target 'stix' do
# Pods for stix
shared_pods
end
target 'stix (embedded)' do
# Pods for stix
shared_pods
end
package.json:
{
"name": "@stix/stix-embedded",
"version": "2.5.118",
"private": false,
"scripts": {
"build": "npm run clean && npm run build:js && npm run copy",
"clean": "node ./tasks/clean",
"build:types": "echo tsc --emitDeclarationOnly",
"build:js": "tsc --build",
"copy": "node ./tasks/copy",
"android": "npx react-native run-android",
"ios": "npx react-native run-ios",
"ios-dev": "ENVFILE=.env.development npx react-native run-ios --scheme='stix dev'",
"ios-dev-embedded": "ENVFILE=.env.development-embedded npx react-native run-ios --scheme='stix dev (embedded)'",
"ios-staging": "ENVFILE=.env.staging npx react-native run-ios --scheme='stix staging'",
"ios-SE-staging": "ENVFILE=.env.staging npx react-native run-ios --scheme='stix staging' --simulator='iPhone SE (2nd generation)'",
"ipad-mini-staging": "ENVFILE=.env.staging npx react-native run-ios --scheme='stix staging' --simulator='iPad mini (6th generation)'",
"ipad-staging": "ENVFILE=.env.staging npx react-native run-ios --scheme='stix staging' --simulator='iPad Pro (11-inch) (3rd generation)'",
"ios-SE-staging-embedded": "ENVFILE=.env.staging-embedded npx react-native run-ios --scheme='stix staging (embedded)' --simulator='iPhone SE (2nd generation)'",
"ios-staging-embedded": "ENVFILE=.env.staging-embedded npx react-native run-ios --scheme='stix staging (embedded)'",
"ios-8-staging": "ENVFILE=.env.staging npx react-native run-ios --scheme='stix staging' --simulator='iPhone 8'",
"ios-8-staging-embedded": "ENVFILE=.env.staging-embedded npx react-native run-ios --scheme='stix staging (embedded)' --simulator='iPhone 8'",
"ios-8-dev-embedded": "ENVFILE=.env.development-embedded npx react-native run-ios --scheme='stix dev (embedded)' --simulator='iPhone 8'",
"ios-production": "echo 'Esta build funciona apenas aparelhos físicos' && ENVFILE=.env.production npx react-native run-ios --scheme='stix'",
"ios-production-embedded": "echo 'Esta build funciona apenas aparelhos físicos' && ENVFILE=.env.production-embedded npx react-native run-ios --scheme='stix (embedded)'",
"android-dev": "ENVFILE=.env.development npx react-native run-android",
"android-dev-embedded": "ENVFILE=.env.development-embedded npx react-native run-android",
"android-staging": "ENVFILE=.env.staging npx react-native run-android",
"android-staging-for-windows": "SET ENVFILE=.env.staging && npx react-native run-android",
"android-staging-embedded": "ENVFILE=.env.staging-embedded npx react-native run-android",
"android-production": "ENVFILE=.env.production npx react-native run-android",
"android-production-embedded": "ENVFILE=.env.production-embedded npx react-native run-android",
"clean-project": "rm -rf node_modules/ && npm cache clean -f && npm install && cd ios && pod install && cd ..",
"android-apk-development": "cd android && ENVFILE=.env.development ./gradlew assembleRelease && cd ..",
"android-apk-staging": "cd android && ENVFILE=.env.staging ./gradlew assembleRelease && open ./app/build/outputs/apk/release/ && cd ..",
"android-apk-production": "cd android && ENVFILE=.env.production ./gradlew assembleRelease && cd ..",
"android-aab-production": "cd android && ENVFILE=.env.production ./gradlew bundleRelease && cd ..",
"publish-embedded": "npm run publish-embedded-gpa && npm run publish-embedded-rd",
"publish-embedded-gpa": "node --max-old-space-size=8000 `which npm` publish",
"publish-embedded-rd": "cat package_rd.json > package.json && node --max-old-space-size=8000 `which npm` publish && git checkout package.json",
"android-apk-embedded": "cd android && ./gradlew assembleRelease && cd ..",
"start": "react-native start",
"test": "jest",
"test:dev": "jest --watchAll",
"test:cov": "jest src --coverage --coverageReporters=cobertura --coverageReporters=lcov",
"lint": "eslint",
"package-staging": "ENVFILE=.env.staging"
},
"rnpm": {
"ios": {},
"android": {},
"assets": [
"./src/assets/fonts"
]
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-regular-svg-icons": "^5.15.3",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/react-native-fontawesome": "^0.2.6",
"@oracle/react-native-pushiomanager": "6.52.2",
"@react-native-async-storage/async-storage": "^1.22.2",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-firebase/dynamic-links": "18.7.3",
"@react-navigation/bottom-tabs": "^5.11.11",
"@reduxjs/toolkit": "^1.9.7",
"@sentry/react-native": "5.16.0",
"@stix/authentication": "1.1.1",
"@stix/react-native-sec4u": "1.0.5",
"@types/styled-components-react-native": "^5.1.1",
"axios": "^1.6.7",
"js-sha256": "^0.9.0",
"jwt-decode": "^2.2.0",
"moment": "^2.29.1",
"obfuscator-io-metro-plugin": "2.1.3",
"react-dom": "18.0.0",
"react-native-app-auth": "7.1.3",
"react-native-config": "^1.0.0",
"react-native-device-info": "^8.1.7",
"react-native-fbsdk-next": "^7.0.1",
"react-native-masked-text": "^1.12.5",
"react-native-modal": "^11.10.0",
"react-native-permissions": "3.10.1",
"react-native-reanimated": "2.17.0",
"react-native-recaptcha-that-works": "^1.2.0",
"react-native-render-html": "^5.1.0",
"react-native-swiper": "^1.6.0",
"react-native-webview": "11.26.1",
"react-redux": "8.1.3",
"redux-persist": "6.0.0",
"styled-components": "^5.2.3"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-firebase/analytics": "18.7.3",
"@react-native-firebase/app": "18.7.3",
"@react-native-firebase/remote-config": "18.7.3",
"@react-navigation/native": "^5.3.0",
"@react-navigation/stack": "^5.3.2",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.4.3",
"@types/jest": "^29.2.2",
"@types/node": "^14.14.37",
"@types/react": "^18.2.48",
"@types/react-native": "^0.64.2",
"@types/react-redux": "^7.1.33",
"@types/styled-components": "^5.1.9",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"babel-jest": "^26.6.3",
"babel-plugin-root-import": "^6.6.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.2.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jail-monkey": "2.8.0",
"jest": "^29.7.0",
"jest-styled-components": "^7.1.1",
"jest-svg-transformer": "^1.0.0",
"metro-react-native-babel-preset": "^0.70.3",
"patch-package": "^6.4.7",
"prettier": "^2.2.1",
"react": "18.0.0",
"react-native": "0.69.12",
"react-native-adjust": "^4.32.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-rate": "^1.2.6",
"react-native-safe-area-context": "3.2.0",
"react-native-screens": "2.18.1",
"react-native-svg": "^14.1.0",
"react-native-svg-transformer": "^1.3.0",
"react-test-renderer": "18.0.0",
"reactotron-react-native": "^5.0.0",
"typescript": "^4.2.3"
},
"publishConfig": {
"@stix:registry": "https://pkgs.dev.azure.com/StixFidelidade/_packaging/Stix-package/npm/registry/"
},
"jest": {
"preset": "react-native"
}
}
我已经尝试手动链接以下this的依赖项,但没有一个解决方案有效。请问有什么想法吗?
您可以进入 ios 文件夹并安装 pods。
cd ios
pod install