React Native Mac 上ios实战入坑

Mac上调试React Native 0.57.8 问题集:

IOS:
1.Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

是由于:
(shadowsocks的)网络代理设置为了全局代理(去翻墙)
-》导致了之前可以正常连接到本地的packager的server,由于全局网络代理,从而需要绕道国外服务器,再去连接本地,所以无法正常访问了?
解决办法是:
暂时取消全局网络代理,改为自动模式即可。

2.Support for the experimental syntax 'decorators-legacy' isn't currently enabled (232:1):

修改.babelrc(新版本已经改名字了,内容一样)文件如下,解决:

{
"presets": ["module:metro-react-native-babel-preset"],"plugins": [ [ "@babel/plugin-proposal-decorators", { "legacy": true } ] ]
}

3.Libraries/LinkingIOS/RCTLinkingManager.h:10:9: 'React/RCTEventEmitter.h' file not found

1.快捷键command+shift+<
2.选中build选项
3.勾掉parallelize build
4.添加React编译项,并移动到项目之前

Multiple configuration files found. Please remove one:

:-1: - package.json#babel

:-1: - .babelrc

配置babel时,两个地方修改了,最终.babelrc文件生效,去掉package.json中#babel的配置

5.nw_connection_get_connected_socket_block_invoke Connection has no connected handle解决办法

1. Xcode menu -> Product -> Edit Scheme...

2. Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"

3. Run your app again, done!

6.scheme的作用?

用于各种环境版本调试开发测试.

7.iphone真机上没有热加载选项..

8.mac开发android?
按官网安装各种依赖软件.

9.Print: Entry, ":CFBundleIdentifier", Does Not Exist

1.rm -rf node_modules && rm -rf ~/.rncache && yarn

2.npm install

3.react-native upgrade

10.Make sure you’re running a packager server or have included a .jsbundle file in your application bundle

关闭 packager, 断掉网络,重新生成.

有时packerger启动慢于模拟器,所以重新run就ok了.

11.Module AppRegistry is not a registered callable module

修改文件名时报错,检查后没问题,重启解决.

12.Failed to load Info.plist from bundle at path XXX

重启解决.可能与android同时启动,用同一packager有关.

13.RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks

14.Cannot update during an existing state transition (such as within render ). Render methods should be a pure function of props and state
this绑定去掉出错.

15.task orphanded for request
用图片缓存库react-native-cached-image,暂未解决.

16.android 下text的value可以居中,IOS却在顶上.
两个平台中text里的linespace不一样.

...Platform.select({
ios:{
lineHeight:36,
},
android:{
}
})

17.undefined is not an object (evaluating '_this._setComponentRef.bind'
突然就启动不了app了,真的突然就发生了..
又双桑来.
查,是个bug...

1.添加babel-plugin-transform-flow-strip-types,
2.babelrc加上
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
3.重启模拟器
4.react-native start --reset-cache
5.react-native run-ios

正常了,该死,啥都没动的.真的,我保证.!.

18.react link 后运行,有error,重复加载字体文件,需要在xcode里清除重复的文件.

19.PCH was compiled with module cache path '/Users/...' but the path is currently '...'

删除build/ModuleCache文件,然后重新执行:

Signing for "AwesomeProjectTests" requires a development team. Select a development team in the project editor. (in target 'AwesomeProjectTests')

xcode编译时,scheme中 Tests也需要设置development team ?关闭重新打开,编译一遍过了..

21.其他机器上copy的工程,本机运行时报错还是原来机器上的路径,
--删除ios下的build文件运行

22.PCH was compiled with module cache......

删除ios下的build文件重新运行命令,或者xcode编译运行

23.设置启动图片,替换新的无法显示:

图片不要放置在 images.xcassets 中,直接将图片拖拽到项目目录中,选择copy item if need ,然后在设置这张图片就可以了。

  1. 0.6 版本 打生产包时报错
    Undefined symbols for architecture arm64:
    "_RCTSetLogFunction", referenced from:
    -[bookmanagerTests testRendersWelcomeScreen] in bookmanagerTests.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

删除test工程,运行正常

  1. 打release包报错,找不到main.jsbundle,
    重新生成后,在xcode中加到原来的位置后可行.
    另图片等资源可能不能显示,也需要拖进xcode.
    react-native bundle --entry-file index.js --bundle-output ./ios/main.jsbundle --platform ios --assets-dest ./ios --dev false

26.在没有网络的情况下,原来正常的项目报错.
No bundle URL present
且已经打开的packger第二次也不能识别,总是会再启动一个,并报端口占用错误.

解决:host文件中加localhost映射.

你可能感兴趣的:(React Native Mac 上ios实战入坑)