React Native iOS 项目初始化

从git上把项目拉下来后,想要跑起来,这个过程中的填坑记录。

1、在项目根目录下先npm install 下

2、在ios目录下执行pod install

报错:

Cloning spec repo `cocoapods` from `https://github.com/CocoaPods/Specs.git`
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/yangdejian/.cocoapods/repos` or via `pod repo add`.

其实就是国内下载太慢了,因为文件很多又大(差不多700多M)。然后切换源到清华:https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs
下载了一丢丢,又卡住了,然后报:

error: RPC failed; curl 18 transfer closed with outstanding read data remaining 
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

还是太慢了,直接连接超时了。

算了,只能想办法加快网速,同事帮忙搞了个v2雷(https://github.com/yanue/v2雷/releases)(MAC版本)(雷=ray,敏感词没办法)

 

3、pod install下载完了后,报了个组件错误

[!] CocoaPods could not find compatible versions for pod "GDTMobSDK":
  In Podfile:
    GDTMobSDK (~> 4.11.8)

None of your spec sources contain a spec satisfying the dependency: `GDTMobSDK (~> 4.11.8)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile

不知道为啥报版本不对,搞了半天,还是同事帮忙解决的(可能是远程仓库的该分支删除了),拉不下来代码,改项目中的podfile,把这个插件的版本号改成仓库中有的,再pod install即可。
查看插件版本命令:pod search GDTMobSDK(第一次比较慢,要构建索引)

 

4、尝试在xcode中导出ipda包

配置了apple证书后,在xcode中build项目,又报了一个SDK的错误:

看到pod里面也有KSDrawAd-sdk这些文件。还是同事帮忙解决的,选择模拟器为:Any iOS Device(xcode默认选中的那个可能不支持这个SDK导致的)

 

然后又报了RN的jsbundle文件不存在的错,这个好解决了。

生成命令:

 1 react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./release_ios/main.jsbundle --assets-dest ./release_ios 

 

导出ipa时又报了错,应该是plist不对(从其他项目拷过来改的):

error: exportArchive: No profiles for 'com.xxx.xxx' were found

Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.xxx.xxx' were found" UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=No profiles for 'com.xxx.xxx' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.xxx.xxx'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.}

** EXPORT FAILED **

 

没办法,只能通过xcode先导一个ipa包出来(包里面有exportOptions.plist的文件),打开看了下,确实好几个地方不对:


 

最后关于provisioningProfiles的属性,发现用命令打包时,只是配置了两个属性和对应的profile文件名(不用加mobileprovision后缀),也就是说打包时,不用从appstore下载这个profile文件,还是因为我在xcode中打包过一次(那时候选过一次),就不需要再指定文件路径了??(请懂的朋友指点迷津!!)

 

另一个项目的初始化:

直接在iOS目录下执行:pod install,失败,报错信息:

[!] Invalid `Podfile` file: cannot load such file -- /Users/xxxx/Desktop/work/app/app-new/node_modules/react-native/scripts/react_native_pods.

先去上级目录npm install下,看了npm仓库源:npm config get registry
还是原生的:https://registry.npmjs.org/
改到taobao去:npm config set registry https://registry.npm.taobao.org/

完事后(很快),再回到iOS目录pod install(如果很慢,你可能需要代理,我反正是开了代理的),一切顺利

切到develop分支,需要重新pod install一下,又报错了:
[!] CocoaPods could not find compatible versions for pod "SDWebImage":
In snapshot (Podfile.lock):
SDWebImage (= 5.10.2, ~> 5.8)

In Podfile:
RNFastImage (from `../node_modules/react-native-fast-image`) was resolved to 8.3.4, which depends on
SDWebImage (~> 5.8)

SDWebImage

You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* changed the constraints of dependency `SDWebImage` inside your development pod `RNFastImage`.
You should run `pod update SDWebImage` to apply changes you've made.

先参照提示的操作一下试试:pod install --repo-update

成功了,Xcode打开后,选择菜单:product>archive打包,失败了,报错信息:
/Users/xxx/Desktop/work/app/xxx/release_ios/assets: No such file or directory
RN的项目要先生成jsbundle,于是执行:

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./release_ios/main.jsbundle --assets-dest ./release_ios

又失败了,错误信息:
error Unable to resolve module `react-native-picker-select` from `src/pages/petrol/petrol-index/petrol-index.tsx`: react-native-picker-select could not be found within the project.

If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules: rm -rf node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*. Run CLI with --verbose flag for more details.

看来需要重新npm install下,先试试吧.......

npm install成功后,再执行react-native bundle...成功了!

再到Xcode重复上面的prodct>archive,报错:

Showing All Messages
Undefined symbol: _OBJC_CLASS_$_RCTOnPageScrollStateChanged
Undefined symbol: _OBJC_CLASS_$_RCTOnPageScrollEvent
Undefined symbol: _OBJC_CLASS_$_RCTOnPageSelected

 

重新执行:yarn install && pod install后,又尝试:prodct>archive
成功了(估计上一步npm install后,需要马上再pod install一次)

 

posted @ 2020-12-16 18:11  流失的痕迹  阅读(1044)  评论(0编辑  收藏  举报