xuexiangjys / react-native-xupdate

A React-Native plugin for XUpdate(Android Version Update Library)
Apache License 2.0
53 stars 20 forks source link

ios如何添加更新 #2

Open wangweiruning opened 4 years ago

wangweiruning commented 4 years ago

请问一下大佬ios如何添加更新

hdi1szh commented 4 years ago

导入之后,我这边iOS会编译报错

alex521 commented 4 years ago

pod install 报错 No podspec found for RNXUpdate in ../node_modules/react-native-xupdate-new

hdi1szh commented 4 years ago

pod install 报错 No podspec found for RNXUpdate in ../node_modules/react-native-xupdate-new

这个框架目前只支持android,我的解决办法是把RNXUpdate.podspec里的s.homepage修改成"https://github.com/author/RNXUpdate";然后自己在iOS原生定义RNXUpdate类处理iOS的升级

alex521 commented 4 years ago

pod install 报错 No podspec found for RNXUpdate in ../node_modules/react-native-xupdate-new

这个框架目前只支持android,我的解决办法是把RNXUpdate.podspec里的s.homepage修改成"https://github.com/author/RNXUpdate";然后自己在iOS原生定义RNXUpdate类处理iOS的升级

改了s.homepage后,pod install 不报错了,但是运行ios项目时会报错,说native module can not be null , 这个ios项目怎么做处理? 其实我只想把这个包用在android上, ios下自己用js检查版本,跳转到市场就可以了

nozbwang commented 4 years ago

Q1. pod install 报错

No podspec found for RNXUpdate in ../node_modules/react-native-xupdate-new

一种解决办法是手动修改../node_modules/react-native-xupdate-new中podspec文件内的s.homepage,使其不为空值。这么做能临时解决问题,但不完美。

第二种解决方法是 使其在ios环境下不自动链接 xupdate,完美解决pod install的报错。(推荐做法) 做法: 在工程根目录下添加react-native.config.js 文件内容为

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-xupdate-new': {
      platforms: {
       ios: null, // disable ios platform, because the lack of homepage in podspec file
      },
    },
  },
};

How can I disable autolinking for unsupported library?

Q2

有些人在运行ios项目时会报错,说native module can not be null , 不晓得这个 ios项目怎么做处理? 其实只想把这个包用在android上, ios下自己用js检查版本,跳转到市场就可以了

解决办法是ios和android分别使用不同的js文件。

React Native 会检测某个文件是否具有.ios.或是.android.的扩展名,然后根据当前运行的平台自动加载正确对应的文件。

比如你可以在项目中创建下面这样的组件:

BigButton.ios.js BigButton.android.js

然后去掉平台扩展名直接引用:

import BigButton from './BigButton';

RN 文档