Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NetworkLayerPOC

A ready-to-push sample Network Layer for iOS using URLSession + async/await + Swift Concurrency with an optional Combine API. Includes a zero-internet mock server via URLProtocol and a demo SwiftUI view.

Built for iOS Labs community exercises. Plug-and-play with your TCA features.

Features

  • Clean Endpoint abstraction
  • Async/await fetch + Combine publisher
  • Strong error typing (APIError)
  • URLProtocol-based mock routing (no network required)
  • Demo ExampleView to preview users + create post
  • TCA integration sketch (opt-in)

Quickstart (Xcode App)

  1. Create a new iOS App (SwiftUI) project (iOS 16+).
  2. File > Add Packages… (optional) OR drag this folder into your project as a local package.
  3. Add import NetworkLayerPOC in your app.
  4. In your app’s root view, use the demo client:
    import SwiftUI
    import NetworkLayerPOC
    
    @main
    struct DemoApp: App {
        var body: some Scene {
            WindowGroup {
                ExampleView() // uses mocked networking
            }
        }
    }
  5. Run. You should see two mock users and a button to create a post.

Using with TCA

Use NetworkClientProtocol inside your reducer effects. See TCAUsersFeature.swift for a tiny example sketch (guarded with #if canImport(ComposableArchitecture)).

Folder Structure

NetworkLayerPOC/
β”œβ”€ Package.swift
β”œβ”€ README.md
β”œβ”€ LICENSE
β”œβ”€ .gitignore
└─ Sources/
   └─ NetworkLayerPOC/
      β”œβ”€ HTTPMethod.swift
      β”œβ”€ APIError.swift
      β”œβ”€ Endpoint.swift
      β”œβ”€ NetworkConfig.swift
      β”œβ”€ RequestBuilder.swift
      β”œβ”€ NetworkClient.swift
      β”œβ”€ Models.swift
      β”œβ”€ DummyAPI.swift
      β”œβ”€ MockURLProtocol.swift
      β”œβ”€ MockSessionFactory.swift
      β”œβ”€ Fixtures.swift
      β”œβ”€ MockRouting.swift
      β”œβ”€ ExampleUsage.swift
      β”œβ”€ ExampleView.swift
      └─ TCAUsersFeature.swift

Notes

  • This package compiles standalone, but ExampleView needs SwiftUI (iOS/macOS).
  • Replace mock.local with your real base URL when connecting to live APIs and remove the mock protocol.

License

MIT

About

This round, we’re levelling up β€” your task is to build a Network Layer wrapper using: URLSession, async/await, Swift Concurrency and a pinch of Combine magic. Think of it as cooking: URLSession is the base ingredient, async/await is the masala, Combine is the garnish… and you’re the MasterChef πŸ³πŸ‘¨πŸ»β€πŸ³πŸ‘©πŸ»β€πŸ³

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages