【发布时间】:2020-05-14 00:51:21
【问题描述】:
首先!
☁ wonder react-native --version
react-native-cli: 2.0.1
react-native: 0.58.6
☁ wonder node --version
v13.6.0
☁ wonder npm --version
6.13.4
当我尝试在本地模拟器上构建和执行时,我得到了;
尽管此端口上没有运行任何东西,这是 RN 项目的开箱即用端口,但我将粘贴我的 AppDelagate 文件和工具版本..谁能解释它是如何工作的,以便我进行故障排除.
> react-native run-ios
Found Xcode project wonder.xcodeproj
Building using "xcodebuild -project wonder.xcodeproj -configuration Debug -scheme wonder -destination id=C9362944-1FDD-4D6E-A6BB-8E758F427 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/{NAME}/Documents/Projects/wonderService/wonder/ios/build
note: Using new build system
note: Planning build
note: Using build description from disk
PhaseScriptExecution Start\ Packager /Users/{NAME}/Documents/Projects/wonderService/wonder/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Script-006B79A01A781F3800
6873D1.sh (in target 'React' from project 'React')
cd /Users/{NAME}/Documents/Projects/wonderService/wonder/node_modules/react-native/React
/bin/sh -c /Users/{NAME}/Documents/Projects/wonderService/wonder/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Script-006B79A01A781F38006873D1.sh
Connection to localhost port 8081 [tcp/sunproxyadmin] succeeded!
AppDelegate.h 文件
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"wonder"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [UIColor blackColor];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
上面我确实记得必须添加
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
这可以逆转。但是,我不认为这是错误
我也明白在为项目定制 PORTS 时可以在这里制作
node_modules/react-native/React/React.xcodeproj/project.pbxproj
但没有迹象表明实例中使用了任何其他 PORT。
最后,我在使用 127.0.0.1 && localhost... 之间切换...结果相同
【问题讨论】:
标签: xcode react-native npm build ios-simulator