Next step is initializing our Swift package. Then go ahead and create a new folder called Calculator and afterwards change the working directory into that folder: $ mkdir Calculator $ cd Calculator Start off launching your Terminal of choice (for me it’s iTerm2). IOS app and command line executable offering the same functionality Creating a SPM command line tool If you more interested in the final solution, checkout this GitHub repository for the final code. Create more local libraries to build a dependency graph.Create the iOS project using the library.Let me give you a quick overview on how we are going to build our own multi-platform Calculator as an iOS app and a command line tool (the guide for creating the iOS app can be applied for macOS too): When the feature is done, it can be used in the main app. One the one hand this allows to isolate unchanged code during the build process, and on the other hand it gives us the opportunity to simply create a spin-off demo version of the app, with only the necessary parts to improve a single feature.Ĭontinuing the example above: Using local SPM packages, you can create a small prototyping-app which only shows the scan feature. Swift Package Manager allows us to create small, reusable code packages. You want to add a scanning feature, which takes a photo and converts it into the receipt data your app uses. They become clunky and you spend a lot of time waiting for rebuilding unchanged parts when you just want to iterate your own new, fresh feature.Įxample: A feature-rich receipt tracking app, which connects to your bank account for matching transactions, uses a cloud for live-synchronization, sharing accounts with friends etc. Our build process becomes slower… and slower… and ….… *goes away to grab a coffee while waiting for Xcode to finish compilation* ….… slower.Įven worse when working with feature-rich, large-scale apps. swift files, but then even the slightest code requires Xcode to recompile everything. First we create a folder structure to organize our. Our code bases are growing with every single new file. And with higher acceptance of the community, even more packages will get available without installing any more tools, such as Cocoapods or Carthage.īut how can we leverage this dependency structure even further? Is external code the only reason for using a package manager? A single file to fetch all the sweet Open Source packages. Swift Package Manager… SPM…It is everywhere, many use it and it is most likely the future of working with Swift dependencies. Modularize Xcode Project using local Swift Packages
0 Comments
Leave a Reply. |