添加Firebase和googleserviceinfo.plist文件后,我在运行React-Native iOS应用程序时遇到此错误。我已按照说明操作,但仍遇到此错误:
2022年10月4日23:35:59.711 x代码构建[38171:508367] [MT] IDE文件引用调试:[加载]〈IDESwiftPackageCore. IDESwiftPackageSpecial文件夹文件参考,0x 146 d 065 c 0:名称:Docs.docc路径:组:Docs.docc〉无法在路径加载容器:/用户/suvin/库/开发人员/Xcode/派生数据/边界测试应用程序-ekpfrimpksdanhevovuosfavhjwg/源包/ checkout /swift-protobuf/源/protoc-gen-swift/Docs.docc,错误:Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6“无法将“Docs.docc”作为“Swift包文件夹”打开,因为它已作为“文件夹”打开。”UserInfo={NSLocalizedDescription=无法将“Docs.docc”作为“Swift包文件夹”打开,因为它已作为“文件夹”打开。}构建失败
以下生成命令失败:编译C/用户/suvin/库/开发人员/Xcode/派生数据/边界测试应用程序-ekpfrimpksdanhevovuosfavhjwg/构建/中间体.noindex/Pod.构建/调试-iPhone模拟器/React记录器.构建/对象-正常/arm 64/React Native日志.o/用户/suvin/文档/GitHub/React Native地理围栏-示例-主/节点模块/React Native/React公共/记录器/React Native日志. cpp正常arm 64 c++ com. apple. compilers. llvm.clang.1_0.编译器(在项目“Pods”的目标“React-logger”中)(1次失败)
这是我的AppDelegate.m文件
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
#import "AppDelegate.h"
#import UIKit;
#import FirebaseCore;
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#ifdef FB_SONARKIT_ENABLED
#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
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
return YES;
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"BoundaryTestApp"
initialProperties:nil];
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];
// Define UNUserNotificationCenter
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
//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);
}
// 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
这是我的包. json
{
"name": "BoundaryTestApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/push-notification-ios": "^1.10.1",
"@react-native-firebase/app": "^15.7.0",
"@react-native-picker/picker": "^2.4.6",
"@react-native/normalize-color": "^2.0.0",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.0",
"deprecated-react-native-prop-types": "^2.3.0",
"react": "17.0.2",
"react-native": "0.66.1",
"react-native-boundary": "github:ridvanaltun/react-native-boundary#b4d143406b41e866754b5a5fd0275bbd42949ab8",
"react-native-config": "^1.4.5",
"react-native-elements": "^3.4.2",
"react-native-flash-message": "^0.3.1",
"react-native-get-location": "^2.2.1",
"react-native-image-picker": "^4.10.0",
"react-native-linear-gradient": "^2.6.2",
"react-native-maps": "0.30.1",
"react-native-permissions": "^3.1.0",
"react-native-picker": "^4.3.7",
"react-native-picker-select": "^8.0.4",
"react-native-push-notification": "^8.1.1",
"react-native-radio-buttons-group": "^2.2.11",
"react-native-safe-area-context": "^4.4.1",
"react-native-screen": "^1.0.1",
"react-native-screens": "^3.17.0",
"react-native-simple-radio-button": "^2.7.4",
"react-native-svg": "^13.2.0",
"react-native-svg-transformer": "^1.0.0",
"react-native-vector-icons": "^9.2.0"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/runtime": "^7.15.4",
"@react-native-community/eslint-config": "^3.0.1",
"babel-jest": "^27.3.1",
"eslint": "^8.1.0",
"jest": "^27.3.1",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
这是我的播客文件
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'BoundaryTestApp' do
config = use_native_modules!
use_modular_headers!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
target 'BoundaryTestAppTests' do
inherit! :complete
# Pods for testing
end
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
1条答案
按热度按时间kpbwa7wx1#
我遇到了同样的问题,并通过以下方式解决了它:
1.打开AppDelegate.mm文件(位于ios〉项目名称〉AppDelegate.mm中)
1.将
@import FirebaseCore;
替换为#import <Firebase.h>
1.使用
npx react-native start
和npx react-native run-ios
退出并重新启动应用1.修正!不再有错误。
**注意:**此修复仅适用于像我这样的用户,他们遵循Firebase的说明“将Firebase添加到您的Apple应用程序”,并根据说明的第4步添加了
@import FirebaseCore;
行。