Reusable iOS Frameworks
If you have found yourself writing the same code over and over again for multiple different apps, then this is the course for you. Learn about the different ways to store your reusable code for a Swift project, how to write methods and functions in a reusable way, and how to think about your end user as a developer rather than a user by focusing on API design principles and access control. By David Okun.
Who is this for?
Swift developers who have written code for more than one project, and want to set themselves up for success as they continue working on multiple different products.
Covered concepts
- Setting up a Framework in Xcode
- Setting up a Package with Swift Package Manager
- Access control in Swift
- Generics
- API-driven design
- Test-driven development
- Dependency Injection
Part 1: Introduce Your User
This episode will present the main issue of the course: you have three apps to write and you'll need code to use across all of them. How do you solve this?
Learn about the difference between static and dynamic libraries, and how Swift Packages provide an elegant solution.
Create a git repository and set up Xcode to develop your reusable framework.
Part 2: Consider Your User
Write a unit test, then write your first reusable API and learn about what goes into it.
Understand how semantic versioning works and how to define and uphold an API contract to prospective developers.
Push your API to your git repository, and test it in a sample project, only to discover a fatal flaw.
Dive into the world of access control while considering a different methodology entirely.
Start thinking about how accessible and open your API is, and consider Murphy's and Hyrum's Law.
Rewrite your first API thinking about how open it truly is, and reuse your own code.
Tag another interation of your framework, and think about changes to the semantic version of your framework.
Part 3: Empower Your User
Add encapsulation and namespacing to your framework to ensure that APIs never cross wires.
Build the beginning of your networking APIs, and come to the realization that you'll need to do some special testing.
Learn how to make your code more testable and resilient to multiple situations.
Learn how to inject a simulated mock network into your API tests.
Update your API's interface to handle this new methodology and make your tests pass while maintaining a developer-friendly interface.
Understand how generics help diversify your APIs to handle multiple scenarios.
Add a unit test to design your final API with a generic signature to handle a multitude of use cases.
Write code to make your final unit test pass with a generic function signature and a solid interface for other developers to use.
Part 4: Integrating Your User
Add support for two other popular dependency managers without cutting off support for Swift Package Manager.
Think about some parting thoughts, and take your framework beyond what you've learned.