质量检查
目录
概述
Applivery iOS SDK 是一个框架,用于支持 iOS 应用程序的 Applivery.com 移动应用分发。
使用 Applivery,您可以大规模分发您的 iOS 应用程序(包括 Ad-hoc 或 In-House/Enterprise),无需您的用户在平台中注册,即可通过可定制的分发站点进行分发。结合 Apple Developer Enterprise Program 和企业证书, Applivery 不仅是用于向 QA 团队分发 beta 测试的完美选择,而且还是用于在发布之前对内部企业分发 beta 测试用户、甚至是企业应用的员工的完美选择。
功能
- 自动OTA更新,当将新版本上传到Applivery时启动。
- 强制更新,如果应用程序版本低于Applivery中配置的最低版本。
- 发送反馈。您的测试用户可以通过简单的截图来报告错误或发送改进反馈。
- 员工认证。您可以登录您的员工账户,以便跟踪安装分析、阻止应用程序的使用、了解谁发送了反馈或报告等。
入门指南
首先,您应该在Applivery.io上创建一个账户,然后添加一个新的应用程序。
获取您的凭据
API令牌:用于标识并授权访问您的账户以使用SDK。
您可以在应用 -> 设置 -> API认证
部分获取您的API令牌。
SDK安装
使用Swift包管理器
(推荐)
在Xcode菜单中,您只需打开“文件 -> 添加包...”并输入Github url:https://github.com/applivery/applivery-ios-sdk.git
然后我们建议将依赖性规则配置为"到下一个主要版本"(3.3.0 < 4.0.0)。
在此阶段,您应该选择以下SDK版本的其中之一
- Applivery
- AppliveryDynamic
如果您的应用程序仅用于内部使用,请选择 Applivery
。例如,为员工开发的内部企业应用程序(您不会将它上传到App Store)。这是库的静态版本。
使用Applivery SDK发布到App Store是禁止的,您的构建在审查过程中可能会被拒绝。每次您上传到App Store时,都应该手动删除Applivery,或您可以使用AppliveryDynamic框架并在构建时排除它。
动态排除App Store方案中的Applivery SDK
如果您正在使用Applivery进行内部Beta测试,并且最终会上传构建版本到App Store,请选择 AppliveryDynamic
。使用这个动态框架版本,您可以在为App Store编译构建时动态排除Applivery。
步骤1
首先,使用 "嵌入并签名" 标志添加框架,并确保它在 "构建阶段" -> "嵌入框架" 中被包含。
步骤2
然后,将 "链接选项" 从 必需
更改为 可选
,在 "构建阶段" -> "链接着库" 中。
步骤3
现在,您可以在构建设置中为应用程序的App Store配置排除 AppliveryDynamic.framework
在 "排除源文件名" 构建选项。或者,如果您使用的是 xcconfig 文件(我们推荐的做法),您可以通过在xcconfig中添加以下行来忽略框架:
EXCLUDED_SOURCE_FILE_NAMES = AppliveryDynamic.framework
步骤4
最后,您还可以通过在构建时使用Swift宏排除调用applivery方法的源代码。例如
#if !APPSTORE && !DEBUG
import Applivery
#endif
struct AppliveryWrapper {
func setup() {
#if !APPSTORE && !DEBUG
let applivery = Applivery.shared
applivery.logLevel = .info
applivery.start(token: APPLIVERY_TOKEN, appStoreRelease: false)
#endif
}
}
如果您的构建配置包含以下 Swift Compiler - Custom Flags
(您可以在“构建设置”中添加/编辑它们),则 #if
宏之间的行将无法编译(因为它们将不存在)
您可以在以下位置找到有关动态排除 Appstore 方案的教程:这里
问题排除
如果正在使用脚本来删除动态框架的模拟器切片,例如 如下,请谨慎行事。Xcode 仅针对所选配置构建框架,因此当存档发布配置时,框架内不会生成模拟器切片,脚本可能会失败或删除 applivery 框架。在此类脚本中应忽略 AppliveryDynamic(通常与 carthage 一起使用)。
使用 Carthage
(已弃用)
使用 brew 安装 carthage
brew update && brew install carthage
将以下行添加到您的 Cartfile 中
github "applivery/applivery-ios-sdk" ~> 3.3
运行 carthage update
,然后将构建的框架拖放到您的项目中。
有关 Carthage 的更多信息,请在此处
使用 CocoaPods
(已弃用)
安装 ruby gem
gem install cocoapods
将以下行添加到您的 Podfile 中
project '<Your Project Name>.xcodeproj'
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'
# use_frameworks! # Starting from v3.2 you can use applivery as a static framework, leave this line commented if you wish
target '<Your Target Name>' do
pod 'Applivery', '~> 3.3'
end
然后运行 pod install
。有关 CocoaPods 的更多信息,请在此处
SDK 设置
在应用程序启动时(例如在 AppDelegate 中)添加以下代码
Swift
首先导入模块
import Applivery
然后是魔法
let applivery = Applivery.shared
applivery.start(token: "YOUR_TOKEN", appStoreRelease: false)
Objective-C
导入
@import Applivery;
魔法
Applivery *applivery = [Applivery shared];
[applivery startWithToken:@"YOUR_TOKEN" appStoreRelease:NO];
重要I:正如你所怀疑的,你应该用你的令牌替换字符串YOUR_TOKEN
。很容易!你不这样认为吗?
重要II:如果你在提交你的应用到AppStore时遇到了问题,请检查有关内嵌框架和AppStore提交的已知问题。
关于参数
- 令牌:您的应用程序令牌
- appStoreRelease:(已弃用 - 您不应该使用Applivery上传的构建上传到Appstore)
Swift & Xcode版本支持
兼容版本如下
Applivery版本 | Xcode版本 | Swift版本 |
---|---|---|
v1.2.x | 7.x | 2.0, 2.1, 2.2 |
v1.3.x | 8.x | 2.3 |
v2.x | 8.x, 9.x | 3.0, 3.1, 4.0 |
v2.7.x | 9.x, 10.x | 4.0, 4.2 |
v3.0 | 10.x, 11.x | 4.0, 4.2, 5.0 |
v3.1 | 11.x | 4.0, 4.2, 5.x |
v3.2 | 12.x | 5.x |
v3.3 | 13.x | 5.X |
高级概念
日志和调试
在某些情况下,您可能需要查看 Applivery SDK 中的内部情况。如果是这样,您可以为调试目的启用日志。
Swift
applivery.logLevel = .info
Objective-C
applivery.logLevel = LogLevelInfo;
可能值有
- None:默认值。不会显示日志。建议用于生产环境。
- Error:仅警告和错误。建议用于开发环境。
- Info:错误和相关信息。建议用于测试与 Applivery 集成。
- Debug:将显示向 Applivery 服务器发送的请求及其响应。不建议使用,仅用于调试 Applivery。
禁用反馈
默认情况下,当检测到屏幕截图时, Applivery 将向用户显示反馈表单。如果您想避免这种情况,可以调用以下方法来禁用它
Swift
applivery.disableFeedback()
Objective-C
[applivery disableFeedback];
绑定用户
在 Applivery 中程序化地登录用户。如果你的应用程序有自定义登录且需要跟踪该用户在平台上的状态。用于了解谁下载了构建或谁发送了反馈报告。
applivery.bindUser(
email: "[email protected]", // Required
firstName: "John", // Optional
lastName: "Doe", // Optional
tags: [ios, testers] // Optional
)
解绑用户
登出之前已绑定的用户
applivery.unbindUser()
实现自己的更新提示/屏幕
您可以自定义更新过程,以便完全由您的应用程序控制。为了实现这一点,您必须首先在 Applivery 的仪表板上禁用应用程序设置中的自动更新。然后您可以使用以下 SDK 方法
func isUpToDate() -> Bool
使用此功能您可以检查应用程序是否更新到了最新的版本。
applivery.update(
onSuccess: { (...) } // Handle here any action you must perform on success
onError: { errorString in (...) } // Handle here the error case. A string whith the reason is passed to this callback
)
使用此方法下载并安装最新可用的构建
自定义 SDK 的颜色
您可以创建一个新的 Palette
类实例并将其分配给 Applivery.shared.palette
Applivery.shared.palette = Palette(
primaryColor: .orange,
secondaryColor: .white,
primaryFontColor: .white,
secondaryFontColor: .black,
screenshotBrushColor: .green
)
SDK 默认有 Applivery 的颜色,因此如果您只需要更改主颜色,您可以这样做
Applivery.shared.palette = Palette(
primaryColor: .orange,
)
或者甚至直接更改属性
Applivery.shared.palette.primaryColor = .orange
可以更改的颜色
primaryColor
:您品牌的主颜色secondaryColor
:背景颜色primaryFontColor
:主字体颜色。它应与主颜色形成对比secondaryFontColor
:辅助字体颜色。它应与辅助颜色形成对比screenshotBrushColor
:在反馈视图中,用户可以编辑截图并在其上方绘制线条。默认情况下,这些线条是红色的,但您可以将颜色改为与您的应用程序颜色方案更匹配。
自定义字符串字面量
您可以根据需要自定义 SDK 中的字符串字面量以适应您的应用程序。
示例
Applivery.shared.textLiterals = TextLiterals(
appName: "Applivery",
alertButtonCancel: "Cancel",
alertButtonRetry: "Retry",
alertButtonOK: "OK",
errorUnexpected: "Unexpected error",
errorInvalidCredentials: "Invalid credentials",
errorDownloadURL: "Couldn't start download. Invalid url",
otaUpdateMessage: "There is a new version available for download. Do you want to update to the latest version?",
alertButtonLater: "Later",
alertButtonUpdate: "Update",
forceUpdateMessage: "Sorry this App is outdated. Please, update the App to continue using it",
buttonForceUpdate: "Update now",
feedbackButtonClose: "Close",
feedbackButtonAdd: "Add Feedback",
feedbackButtonSend: "Send Feedback",
feedbackSelectType: "Select type",
feedbackTypeBug: "Bug",
feedbackTypeFeedback: "Feedback",
feedbackMessagePlaceholder: "Add a message",
feedbackAttach: "Attach Screenshot",
loginInputUser: "user",
loginInputPassword: "password",
loginButton: "Login",
loginMessage: "Login is required!",
loginInvalidCredentials: "Wrong username or password, please, try again",
loginSessionExpired: "Your session has expired. Please, log in again"
)
SDK 默认包含字面量,因此,如果您只需要更改更新消息,可以这样做
Applivery.shared.textLiterals = TextLiterals(
appName: "MyApp",
otaUpdateMessage: "There is a new version available for download. Do you want to update to the latest version?",
forceUpdateMessage: "Sorry this App is outdated. Please, update the App to continue using it"
)
或者甚至直接更改属性
Applivery.shared.textLiterals.appName: "MyApp"
Applivery.shared.textLiterals.otaUpdateMessage: "There is a new version available for download. Do you want to update to the latest version?"
Applivery.shared.textLiterals.forceUpdateMessage: "Sorry this App is outdated. Please, update the App to continue using it"
重要:默认字面量仅支持英文。请考虑设置本地化字符串以全面支持您应用程序的所有语言。
嵌入框架及 ipa 生成
如果您使用 Carthage 和动态框架安装了 SDK, Applivery.framework 则构建为胖通用库,这意味着可以在没有问题的设备或模拟器上编译,但是如果包含嵌入的带有模拟器切片的框架,则无法生成 ipa 文件。
在这种情况下,解决方案很简单,只需将 此脚本 添加到“新建运行脚本阶段”。您可以在“构建阶段”选项卡中找到它。