跳轉至

iOS

使用 CocoaPods

本指南解释了如何使用 CocoaPods 为 iOS 安装 Hive SDK。

新增 Hive SDK 儲存庫

在生成的 Podfile 中将 Hive SDK 仓库添加为源。

source 'https://github.com/Com2uSPlatformCorp/HiveSDK-iOS'

將 SDK 添加到 Xcode 專案中

修改 Xcode 專案目錄中的 Podfile 以添加 Hive SDK。

source 'https://github.com/CocoaPods/Specs.git'
# Add the Hive SDK repository as a source
source 'https://github.com/Com2uSPlatformCorp/HiveSDK-iOS'

$HIVE_SDK_VERSION = '26.1.0'                    # 要使用的 SDK 版本
$IOS_DEPLOYMENT_TARGET_VERSION = '13.0'         # 遊戲支援的 iOS 最低版本
$IOS_DEPLOYMENT_MINIMUM_TARGET_VERSION = '13.0' # 使用的 SDK 支援的 iOS 最低版本(請參閱所使用的 SDK 版本的發行說明)

platform :ios, $IOS_DEPLOYMENT_TARGET_VERSION
use_frameworks!
inhibit_all_warnings!

project 'HIVE_SDK_Sample_App.xcodeproj'

target 'HIVE_SDK_Sample_App' do
  # Add the frameworks to use here. At least one framework is required.
  # Example: Add the following framework when using Google IdP login in Hive SDK authentication
  pod 'HiveAuthV4ProviderGoogle', $HIVE_SDK_VERSION # When using Google IdP login for authentication (authv4)
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
     target.build_configurations.each do |config|
     # 如果各框架的 iOS target 低於 15,則更改為 15
     if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < $IOS_DEPLOYMENT_MINIMUM_TARGET_VERSION.to_f
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $IOS_DEPLOYMENT_MINIMUM_TARGET_VERSION.to_f
     end
     # Handle xcode 15 TOOLCHAIN_DIR related compile error issues
     xcconfig_path = config.base_configuration_reference.real_path
     xcconfig = File.read(xcconfig_path)
     xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
     File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
     end
  end
end

使用 Swift Package Manager (Beta)

本指南說明如何使用 Swift Package Manager (SPM) 安裝 iOS SDK。

  1. 在 Xcode 專案中選擇新增套件選單。

    Unity

    如果您在 Unity 環境中安裝 Hive SDK 後建置了 Xcode 專案,且 pod install 已自動執行,則必須先執行 pod deintegrate

  2. 找到 Hive SDK 套件儲存庫並指定版本。

    1. 1 中輸入以下網址。

      https://github.com/Com2uSPlatformCorp/HiveSDK-iOS-SPM
      
    2. 2 中選擇 Exact Version,然後輸入您要應用的 SDK 版本。

    3. 點擊 3

  3. 套件載入完成並顯示產品清單後,將所需的 Hive SDK 產品(身份驗證、計費、分析等)應用到應用程式 target。

    Warning

    以下不支援 SPM 的 Hive SDK 產品必須使用 CocoaPods 添加。

    • HerculesSwift
    • HiveAuthV4ProviderQQ
    • HiveAuthV4ProviderLine
    • HiveAuthV4ProviderWechat
    • HiveAnalyticsProviderAirbridge

    Podfile 中為這些產品撰寫 pod 語法 後執行 pod install。此時,不應包含已透過 SPM 應用的 Hive SDK 產品。如果有其他相依性需要添加,同樣可以使用 CocoaPods 添加。

    Unity

    如果您在 Unity 環境中安裝 Hive SDK 後產出 Xcode 專案,請將 Hive SDK 產品應用到 UnityFramework target 而不是應用程式 target。但是,Hive_AuthV4ProviderFacebookHive_AnalyticsProviderAdjust 產品也必須添加到主應用程式 target(Unity-iPhone)。

  4. 在主應用程式 target 的 Build Settings 中,將以下兩個值依序添加到 Other Linker Flags(OTHER_LDFLAGS):

    • -Xlinker
    • -all_load