ios集成react-native步骤

1.搭建开发环境可参考


2.然后使用xcode创建一个project文件

3.在项目根目录下创建 文件夹如 : react

4.在react文件夹下创建 package.json文件

{

  "name": "reactNativeTestProject”,//文件名
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.0.0-alpha.6",
    "react-native": "^0.44.0"
  },
  "devDependencies": {
    "babel-jest": "20.0.1",
    "babel-preset-react-native": "1.9.1",
    "jest": "20.0.1",
    "react-test-renderer": "16.0.0-alpha.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

在react文件夹下安装react-native
npm install

4.在根目录下面创建Podfile文件内容如下
platform :ios, '8.0'
target 'reactNativeTestProject' do
  react_native_path = "./react/node_modules/react-native”  #在podfile所在的目录下找到node_modules文件夹
  pod "Yoga", :path => "#{ react_native_path}/ReactCommon/yoga"
  pod "React", :path => react_native_path, :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]
end

在根目录下执行
pod install


关于报错
No podspec found for `Yoga` in `./node_modules/react-native/ReactCommon/yoga/Yoga.podspec`

上边的Podfile文件中没有添加  pod "Yoga", :path => "#{ react_native_path}/ReactCommon/yoga”,或者是该路劲不对

No podspec found for `React` in `../node_modules/react-native`

上边的Podfile文件中 pod "React", :path => react_native_path, :subspecs =>[ ];path可能不对

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 下载阿里云视频播放器SDK,解压后得到两个文件夹:aliyun-sdk-player-android和aliyun-sdk-player-ios。 2. 在React Native项目中安装react-native-aliplayer插件,使用命令:npm install react-native-aliplayer --save。 3. 在android/app/build.gradle文件中添加如下代码: ```gradle dependencies { implementation project(':react-native-aliplayer') ... } ``` 4. 在MainActivity.java中添加如下代码: ```java import com.aliplayer.AliPlayerPackage; public class MainActivity extends ReactActivity { @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new AliPlayerPackage() ); } ... } ``` 5. 在ios项目中,将aliyun-sdk-player-ios文件夹拖入项目中,并在Build Phases的Link Binary With Libraries中添加以下库: - libstdc++.6.tbd - libz.tbd - libresolv.tbd - libbz2.tbd - AVFoundation.framework - AudioToolbox.framework - CoreMedia.framework - MediaPlayer.framework - SystemConfiguration.framework - UIKit.framework - VideoToolbox.framework 6. 在AppDelegate.m中添加如下代码: ```objective-c #import "AliPlayer.h" ... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [AliPlayer registerWithAppKey:@"your-app-key"]; ... } ``` 7. 在React Native中使用AliPlayer组件进行视频播放,例如: ```jsx import React from 'react'; import { View } from 'react-native'; import AliPlayer from 'react-native-aliplayer'; export default function App() { return ( <View style={{ flex: 1 }}> <AliPlayer source={{ uri: 'http://player.alicdn.com/video/aliyunmedia.mp4', }} style={{ flex: 1 }} /> </View> ); } ``` 以上就是React Native集成阿里云视频播放器SDK的步骤

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值