GeniusSportWidgetLoader 0.2.0

GeniusSportWidgetLoader 0.2.0

Genius Sports - 移动框架团队Trevor Doodes 保持。



  • GeniusSport

GeniusSportWidgetLoader

CI Status Version License Platform

示例

要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install

要求

安装

GeniusSportWidgetLoader 可通过 CocoaPods 获取。安装它,只需将以下行添加到 Podfile 即可

pod 'GeniusSportWidgetLoader'

使用

项目设置

要在自己的项目中使用此组件,请创建一个XCODE项目,打开终端并切换到项目根目录。要初始化项目以使用cocoa pods,请运行以下命令

pod init

这将会创建一个'Podfile'文件,编辑此文件以包含GeniusSportWidgetLoader组件。将target的名称更新为您项目的名称

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'GeniusSportWidgetLoaderDemo' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for GeniusSportWidgetLoaderDemo
  pod 'GeniusSportWidgetLoader'

  target 'GeniusSportWidgetLoaderDemoTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

然后运行以下命令来安装依赖项

pod install

完成此操作后,始终打开.xcworkspace文件以继续开发。

Pod使用

要在viewController的viewDidLoad()方法中全屏显示一个widget,请创建一个GSWidget实例,传入widget的URL和一个代理对象。然后设置viewController的主视图为GSWidget对象。代理可以是任何遵守GSWidgetListener协议的对象。

例如:

  override func viewDidLoad() {
        super.viewDidLoad()
        let wigetView = GSWidget(url: url, delegate: self)
        view = wigetView
    }

GSWidgetListener协议实现了2个方法

func onMessage(type: String, message: [String: Any])

func onError(type: String, rawMessage: String)

onMessage类型是一个字符串,表示消息类型,例如"addToBetslip"。

message参数包含一个键值对的字典。通过使用'selection'键访问选择细节。

Pod维护

要维护Pod,请打开Example/GeniusSportWidgetLoader.xcworkspace。以这种方式打开项目使您能够在同一项目中编辑pod和示例应用程序。

Pod的代码可以在XCODE中Pods项目的Development Pods文件夹中找到。

在修改Pod时,您必须更新.podspec文件以更新Pod的版本号。

s.version          = '0.2.0'

部署Pod

使用'pod trunk'命令将pods部署到公共仓库。要部署一个pod,您需要一个使用电子邮件地址设置的账户。这将在当前设备上启动一个会话。要创建账户,请输入以下命令,使用您的电子邮件地址

$ pod trunk register [email protected] 'Orta Therox' --description='macbook air'

您将收到来自cocoapods.org的确认电子邮件。您可能需要将此域名添加到白名单。

更多详细信息请见此处 https://guides.cocoapods.org.cn/making/getting-setup-with-trunk.html

一旦您准备好部署pods,对最新的commit进行标记并将其推送到远程。

$ git tag 0.1.0
$ git push origin 0.1.0

标记必须与podspec中的版本匹配

接下来验证podspec以确保没有问题,请使用以下命令进行操作

$ pod spec lint GeniusSportWidgetLoader.podspec

应输出以下内容

$ pod spec lint GeniusSportWidgetLoader.podspec
 -> GeniusSportWidgetLoader (0.1.0)
Analyzed 1 podspec.
GeniusSportWidgetLoader.podspec passed validation.

一旦podspec被验证,您可以使用以下命令将spec推送到spec仓库

$ pod trunk push GeniusSportWidgetLoader.podspec

只有所有者可以推送spec,但添加所有者只需使用'pod trunk add-owner'命令。

$ pod trunk add-owner GeniusSportWidgetLoader <email address>

所使用的电子邮件地址需要在trunk上设置一个注册账户,以便可以将它们添加到库中。

可以使用以下命令删除所有者。

$ pod trunk remove-owner GeniusSportWidgetLoader <email address>

作者

天才运动

许可

GeniusSportWidgetLoader在MIT许可下可用。有关更多信息,请参阅LICENSE文件。