iOS
前提条件
本文操作步骤和示例图以 Xcode 13.1 为例。
步骤 1: 创建项目
- 打开 Xcode, 点击 File > New > Project。
-
- 输入项目名称、团队名称、选择开发语言,点击 Next。
- 签名设置:进入 TARGETS > Project Name > Signing & Capabilities。勾选 Automatically manage signing, 并在弹出菜单中选择 Enable Automatic。
-
步骤 2: 创建用户界面
根据场景需要,为你的项目创建互动白板的用户界面。
为实现基本的白板功能,我们建议在项目中添加如下视图或元素:
步骤 3: 集成 SDK
- 为 podfile 文件的 target 工程添加依赖项,例如:
source 'https://github.com/volcengine/volcengine-specs.git'
pod 'VolcEngineWhiteboard', '1.6.0'// 将版本号替换为最新或你需要的版本号。
- 在项目的配置文件里加入 SDK 依赖。可以根据实际需要指定 SDK 的版本。
spec.dependency 'VolcEngineWhiteboard', '1.6.0'// 版本号和 podfile 中的依赖项保持一致。
在调用了白板 SDK API 的文件中引入头文件。
#import "WhiteBoard/ByteWhiteBoardRoomManager.h"
#import "WhiteBoard/ByteWhiteBoardRoom.h"
#import "WhiteBoard/ByteWhiteBoard.h"
步骤 4: 实现功能
基础互动白板 API 时序图
1. 创建和初始化白板房间
@property (nonatomic, strong) ByteWhiteBoardRoomManager * boardRoomManager;
@property (nonatomic, strong) ByteWhiteBoardRoom * boardRoom;
@property (nonatomic, strong) ByteWhiteBoard * board;
+ (void)setDeviceID:(NSString *)deviceID; // 设备id用于方便追踪排查问题
+ (void)setAid:(NSString*)aid; //火山内部客户使用,用于标识APP
+ (void)setLogLocation:(NSString*)path;//设置日志的位置,不设置则SDK自动选择
+ (instancetype)sharedEngineWithAppId:(NSString *)appId setEnv:(ByteWhiteBoardEnv)env bindToWindow:(UIView *)view completionHandler:(void (^)(void))block;
2. 加入白板房间
加入白板房间。如果当前房间没有白板,SDK 将自动创建白板。
- (void)joinRoom:(NSString *)roomID userID:(NSString *)userID token:(NSString*)token defalutBoard:(ByteWhiteBoardInfo *)boardInfo completionHandler:(void (^)(ByteWhiteBoardRoom *))block delegate:(id)delegate;
//回调触发后我们可以通过getRoomStatus得知当前房间是否上课。
- 白板房间 roomID 不能与 RTC 房间 roomID 相同。以免影响白板房间和 RTC 房间内回调提醒相互影响。建议为白板房间名加上 whiteboard_ 前缀。
- 白板用户 userID 不能与 RTC userID 相同。
- id<ByteWhiteBoardRoomDelegate>)delegate 为白板 ViewController,继承了 ByteWhiteBoardRoomDelegate 协议。
白板服务在当前用户加入白板房间后开始计费,直到该用户调用 leaveRoom 退出房间后停止计费。建议在即将使用白板前创建白板实例。并结束使用后及时销毁白板实例。 3. 获取房间内所有白板信息
4 使用白板
使用不同的画笔对白板进行编辑。
[self.board setEditType:ByteWhiteBoardShapeTypePen];//设置成画笔模式或者其他
[self.board setWritable:YES];//设置当前白板是否可写
5. 结束使用白板
在结束白板使用时,释放资源的步骤如下。
- 调用 ByteWhiteBoardRoom 的 leaveRoom 离开房间,结束通话过程,释放所有通话相关的资源。
除了用户主动结束使用之外,在监听到以下错误时,你也需要调用上述接口,执行离房操作。
- (void)byteWhiteBoard:(ByteWhiteBoard *)board onError:(ByteWhiteBoardErrorCode)code message:(NSString *)message{
if (code == DUPLICATE_LOGIN || code == KICKED_OUT || code == INVALID_TOKEN) {
[self.boardRoom leaveRoom];
[ByteWhiteBoardRoomManager destroy];
- (void)byteWhiteBoardRoom:(ByteWhiteBoardRoom *)boardRoom onError:(ByteWhiteBoardErrorCode)code message:(NSString *)message {
[self.class showToast:[NSString stringWithFormat:@"room error %ld",(long)code]];
if (code == DUPLICATE_LOGIN || code == KICKED_OUT || code == INVALID_TOKEN) {
[self.boardRoom leaveRoom];
[ByteWhiteBoardRoomManager destroy];
- 调用 ByteWhiteBoardRoomManager 的 destroy 释放资源。
[ByteWhiteBoardRoomManager destroy];
常见问题
1. 日志和缓存文件的路径在哪里?
- 回放文件默认路径:AppData/Library/Caches
2. bitcode_strip 报错
bitcode_strip ****/byteaudio.framework/byteaudio: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip exited with 1
解决方法:
关闭 bitcode:自定义环境设置 STRIP_BITCODE_FROM_COPIED_FILES = NO
3. ENABLE_BITCODE 报错
'***/WhiteBoardDemo/Lib/WhiteBoard.framework/WhiteBoard' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '***/WhiteBoardDemo/Lib/WhiteBoard.framework/WhiteBoard' for architecture arm64
解决方法:
设置 target 的 Enable BitCode 字段为 NO。
最近更新时间:2026.09.28 09:46:49