iOS ARViewer 导入指南
概述
入门
ARViewer 是基于 iOS ARKit 的静态库。它满足以下条件时可以正常工作。需要 iOS 11.3 或更高版本。iPhone 6s 或更高版本。
导入 SDK
添加 SDK 文件
将 ARViewer.framework 文件粘贴到 Project 文件夹中
在项目文件中选择 Frameworks, Libraries, and Embedded Content > + 并添加 framework 文件。
权限设置
在Info.plist中添加相机权限。
NSCameraUsageDescription
在Info.plist中添加API Key。
kUBARViewer
依赖性(配置)
使用CocoaPods安装ARViewer的依赖项。要安装CocoaPods,请按照安装指南进行。
$ cd your-project directory
$ pod init
添加要安装的pod。可以在Podfile中包含pod,如下所示。
pod 'AFNetworking', '~> 3.0', :subspecs => ['Reachability', 'Serialization', 'Security', 'NSURLSession']
pod 'UICircularProgressRing', '~>6.1.0'
pod 'lottie-ios'
安装pod并打开.xcworkspace文件,然后在XCode中检查项目。
$ pod install
$ open your-project.xcworkspace
方案配置
为了使ARViewer的开发环境流畅,应用以下设置。
主线程检查器的Runtime API Checking 取消选中。
Metal API验证设置为禁用。
初始化会话
通过Storyboard或Xib静态加载ARViewer。
也可以通过代码动态加载。
let arViewer = ARViewer(frame: UIScreen.main.bounds)
通过实现部分启动ARViewer的会话。
//
// ARViewController.swift
// arviewer-sample
//
// Created by urbanbase on 2020/08/20.
// Copyright © 2020 urbanbase. All rights reserved.
//
import UIKit
import ARViewer
class ARViewController: UIViewController {
@IBOutlet var arViewer: ARViewer!
override func viewDidLoad() {
super.viewDidLoad()
configureARViewer()
}
func configureARViewer() {
arViewer.delegate = self
arViewer.run()
}
}