InnerTube package for iOS. Talk to YouTube's servers, resolve playable streams, mint PoTokens.
iOS 17+ / macOS 13+, Swift 5.9+, Xcode 16+. No third-party dependencies.
File → Add Package Dependencies, enter the repo URL:
.package(url: "https://github.com/686udjie/SwiftyTube.git", from: "0.0.9")Add SwiftyTube to your target, then import SwiftyTube.
let tube = InnerTubeClient(config: .music) // or .youtube
let auth = try SessionImporter.importSession(from: cookieString)
await tube.loadState(from: myStore) // conforms to AuthStateProvider
let request = StreamResolveRequest.playback(videoId: id)
let result = try await StreamFallback.resolveFirstValid(
request, using: tube, providers: .live
)
player.play(url: result.streamUrl)Guest (signed-out) use works for public content - skip sign-in.
Sessions captured from a webview have hard requirements (desktop Safari UA, poll-not-snap cookie harvest, accounts.google.com round trip for stale tokens) — see Docs/Usage.md "Webview sign-in".
Transport (browse/search/next/player, likes, playlists, subs), comments (load, sort, replies, vote, post, edit, delete, report), stream resolution (format scoring, 9-client fallback, validation, caches), cipher (player.js, deobfuscation, n-transform, self-healing configs), PoToken minting, session import, Keychain helper. YouTube support (browse ids, search filters, suggestions, and YouTubeFeedParser/YouTubeWatchParser/YouTubeChannelParser/YouTubeTranscript for feeds, watch pages, channel tabs and captions). Details with examples: Docs/Usage, Music, YouTube.
UI, databases, settings, Keychain service names, playback. Transport returns raw JSON; the bundled YouTube parsers are optional helpers - you decide the rest.
Bundled with the package (SwiftyTube/Resources/, resolved via Bundle.module):
player_configs.json- offline cipher configspo_token.html- PoToken minter page
Apps that already embed their own copies keep working — those are checked as a fallback.
This repo is licensed under GPLv3. SwiftyTube is not affiliated with, endorsed, or sponsored by Google or YouTube.