How dropbox/swiftydropbox works
Project type and purpose
• This is an SDK library (not a full‐stack app) providing:
• A Swift client for Dropbox HTTP API v2
• An Objective‐C compatibility layer
• Codegen pipeline (Stone + spec)
• Test harness (unit + integration)
• Multi‐platform support (iOS, macOS, extensions, SwiftUI)
• Distribution via SPM, CocoaPods
Break out the main components
a. Code Generation Pipeline
• Inputs: spec/ + stone/ + generate_base_client.py
• Outputs: Source/SwiftyDropbox/Shared/Generated/* and Source/SwiftyDropboxObjC/Shared/Generated/*
• Scripts: update_repo_check.sh, update_version.sh, Format/generate_docs.sh
b. Core SDK Modules
• Shared Core Logic:
• Generated models & routes
• Handwritten helpers (NetworkSession, OAuth, Utilities)
• SDKConstants, CertificatePinning, error handlers
• Platform Adapters:
• iOS UI for OAuth (OAuthMobile, LoadingViewController)
• macOS OAuth adapter (OAuthDesktop)
• Client Manager:
• DropboxClientsManager (single & multi‐user)
• DropboxClient & DropboxTeamClient
• DropboxTransportClientImpl (HTTP transport)
c. Objective-C Layer
• Mirror of Swift SDK under SwiftyDropboxObjC/Platform & SwiftyDropboxObjC/Shared
• Typed Objective‐C request classes, error types, clients
d. Network & OAuth Subsystem
• NetworkSessionManager, NetworkSessionConfiguration, NetworkTask
• OAuthImpl, AccessTokenProvider, AuthSession, PKCE support
• Background sessions / reconnection logic
e. Packaging & CI
• Build definitions: Package.swift, .podspec files
• Xcode workspaces under .swiftpm and TestSwiftyDropbox
• CI workflow: .github/workflows/ci.yml
• Doc generation: .jazzy.json, Format/generate_docs.sh
f. Tests
• Unit Tests under SwiftyDropboxUnitTests (mocking via MockDropboxTransportClient)
• Integration Tests under TestSwiftyDropbox/IntegrationTests (iOS + ObjC)
• Sample apps in TestSwiftyDropbox (iOS, macOS, SwiftUI, Action Extension)
Relationships & Data Flows
• Codegen → Generated code → Core Shared module
• Handwritten Shared helpers ↔ Generated code via request/response types
• Shared Core → Platform adapters (iOS/macOS) → UI components (for auth flows)
• Application code (test or consumer) → DropboxClientsManager → DropboxClient → DropboxTransportClientImpl → URLSession → Dropbox API
• Tests inject MockDropboxTransportClient into DropboxClient to simulate network responses
• Objective-C layer wraps/swizzles Swift types for ObjC consumers
Architectural patterns & principles
• Modularity: clear separation between codegen, core logic, platform adapters, network layer, tests
• Abstraction & DI: transport and OAuth are abstracted behind protocols; clients injected for testing
• Single Responsibility: each module has a distinct role (serialization vs networking vs UI)
• Code generation + manual code co-exist, minimizing handwritten boilerplate
Detail level & coverage
• Every major directory’s function (e.g., Source/SwiftyDropbox/Shared/Handwritten, Source/SwiftyDropboxObjC/Platform)
• Don’t worry about every single file—group by subfolder meaning (Generated vs Handwritten)
• OAuth flows (Direct, Safari, Redirect) are shown as alternate paths under Platform adapters
• Background networking reconnection logic under network/OAuth layer