TMDb
13.2.0
電影資料庫 (TMDb) 的 Swift 套件 https://www.themoviedb.org
將 TMDb 套件作為依賴項新增至您的Package.swift
檔案中,並將其作為依賴項新增至您的目標。
// swift-tools-version:5.9
import PackageDescription
let package = Package (
name : " MyProject " ,
dependencies : [
. package ( url : " https://github.com/adamayoung/TMDb.git " , from : " 13.0.0 " )
] ,
targets : [
. target ( name : " MyProject " , dependencies : [ " TMDb " ] )
]
)
將 TMDb 套件新增至專案的套件依賴項。
從電影資料庫網站 https://www.themoviedb.org/documentation/api 建立 API 金鑰。
let tmdbClient = TMDbClient ( apiKey : " <your-tmdb-api-key> " )
let moviesToDiscover = try await tmdbClient . discover . movies ( ) . results
let fightClub = try await tmdbClient . movies . details ( forMovie : 550 )
文件和使用範例可以在 https://adamayoung.github.io/TMDb/documentation/tmdb/ 找到
Xcode 16.0+ Swift 6.0+ 自製軟體
安裝自製程序和以下公式
brew install swiftlint swiftformat markdownlint
使用 Swift Test 作為測試框架。不再使用 XCTest。
確保單元測試覆蓋所有新程式碼。如果在呼叫 TMDb API 端點的服務中新增任何新方法,請確保有涵蓋這些方法的整合測試。
編碼風格由swift-format
強制執行。
使用以下命令來檢查程式碼庫:
make lint
若要格式化程式碼庫,請使用:
make format
確保所有public
類別、結構、屬性和方法都被註釋
DocC 文件可以透過以下方式在本機上建置和託管
make preview-docs
參見文檔 | Apple 開發者文件以了解更多詳細資訊。
在提交 PR 之前,請確保所有 CI 檢查都將通過:
make ci
CI 檢查由以下任務組成:
make lint
make lint-markddown
make test
make test-ios
make test-watchos
make test-tvos
make test-visionos
make test-linux
make integration-test
make build-release
make build-docs
為了執行整合測試,需要設定以下環境變數。
TMDB_API_KEY
- 您的 TMDb API 金鑰TMDB_USERNAME
- 您的 TMDb 使用者名TMDB_PASSWORD
- 您的 TMDB 密碼如果未設定這些環境變量,則在不使用make
時將跳過整合測試。
在 Linux 上執行單元測試需要執行 Docker。
該庫根據 Apache License 2.0 授權。有關詳細信息,請參閱許可證。