

Everybody knows that solving a small problem is easier than solving a big one. This is part of something called “Dynamic Programming”. a diagram? You now have several small problems instead of a giant one I’m not sure It’s even possible, but surely, it’s not a best practice.Īctually, without drawing the diagram, it’s hard to define the dependencies, so we also earned. By looking at the diagram above, you cannot import the Analytics package into the Persistent Store Library. You need to make important design decisions, and you need to decide what functions are public (Oh, finally, it has meaning inside your app!), and what are the dependencies. Modules make your layers interface clearerīecause each part in your app is a module, the process of building them forces you to really plan and design your interfaces between them. With modules, it’s more clear and transparent. Most apps actually built like that, but with groups. Now, if you built one or two apps in your life, this diagram is not new. Then we move to the sync (that obviously needs the network and the persistent store) and so on with the other modules. So, we have a network and persistent store packages that require the common and the logger modules to function. They do not depend on anything, but the other packages need them. The Logger and some help methods bundles to a Common library are the low layer of the project. The diagram also reflects the dependencies between them. Everything is modular and easy to maintain.Įxcept for the UI, all the other components are, in fact, packages. You want the Today Widget to take advantage of the excellent Logging mechanism you created? Piece of cake. Do you want an app with the same foundation but a different UI? No problem, easy to setup. It makes your app development process feels like playing with Lego bricks.
#Appcode swift package manager code
Organize your code to packages changes all that. Most standard iOS apps are built from one big codebase and some third-party libraries. What I didn’t realize that even without putting those packages on Github and share them, using Modules (Packages/Pods, whatever you want to call it) brings additional value to your app. I knew that having a shared code between apps is a great way to maintain them over time.
#Appcode swift package manager how to
Since this feature is based on a low-level code such as Networking, Persistent Store, Analytics, and Logging, I thought it would be best to check how to convert those parts to modules. It all started when I had to take an existing, big project, and port one feature to a dedicated app. Convert parts in your project to packages is not just a way to organize your code nicely it actually changes the way you work and architect your app. If you are finding these posts and videos useful, then please share this post or buy me a coffee.Even though we had dependencies managers for several years now, with Swift Package Manager (SPM) creating packages in your app is almost as easy as adding new folders. OSCKit allowed me to focus on other parts of the app and for the package to actually handle all the OSC communication between the app, the iOS device, and the Hog controller. I use one in iHog for OSC a network protocol that I have no idea how to actually implement in Swift. Sometimes they can save you hours of coding and figuring out how something works.

When should you reach for an external dependency?Īn external dependency aka package can make your life easier as a developer.
