How efremidze/magnetic works
Project Type and Purpose
• Magnetic is an open-source iOS UI component library (bubble picker) built in Swift.
• It ships as a Swift Package, CocoaPod, or Carthage framework.
• It provides an SKScene subclass (Magnetic) and supporting views/nodes to display interactive “bubbles.”
A: Distribution & Build
• Package Managers
– CocoaPods (Magnetic.podspec)
– Carthage (Cartfile support)
– SwiftPM (Package.swift)
• CI/CD
– GitHub Actions (/.github/workflows/ci.yml)
– Travis CI (.travis.yml)
• Documentation Generation
– Jazzy (docs/**) produces HTML/Jazzy docsets.
B: Runtime Framework (Magnetic)
• MagneticView.swift (UIView subclass wrapping SKView)
• Magnetic.swift (SKScene subclass)
• Node.swift (SKShapeNode subclass)
• SKMultilineLabelNode.swift
• MagneticView+SwiftUI.swift (SwiftUI wrapper)
• MagneticView+Accessibility.swift
• MagneticDelegate protocol
– from MagneticView → presents → Magnetic (SKScene)
– Magnetic → manages → Node instances
Also annotate:
– Delegate Pattern: Magnetic → MagneticDelegate → Application
– Animation Hooks: Node.selectedAnimation(), deselectedAnimation(), removedAnimation()
Data Flow & Component Interaction
1. App code calls magnetic.addChild(node)
2. Magnetic positions nodes inside SKScene
3. User taps Node → SKScene dispatches touch → Node triggers animation
4. Node state change → MagneticDelegate callbacks → App
Architectural Patterns & Principles
• MVC-ish:
– ViewController → View (MagneticView) → Model/View (Magnetic + Node)
• Delegate Pattern for event callbacks
• Composition of SpriteKit nodes for UI
• Extension points via subclassing Node
• Modular packaging: clear separation between Sources, Example, Docs