What is the best and recommended way to add helpers/utils to a TCA project? And how should they be accessed/used?
For example, adding a keychain wrapper for saving and retrieving user data throughout the project?
Hi!
I have a Keychain client on my project and I'm setting it as an environment dependency.
It's also an isolated module (Swift Package).
Cheers!
So it's a separate feature? can you share where have you placed it?
It's something like this:
let package = Package(
name: "featureapp-ios",
products: [
.library(name: "FeatureApp", targets: ["FeatureApp"]),
],
dependencies: [
.package(path: "../KeychainClient"),
],
targets: [
.target(
name: "FeatureApp",
dependencies: [
"KeychainClient"
]
)
]
)
This looks good. Can you also share the folder structure? just to make sure.
For instance, having a project path folder like /Developer/myproject:
|- FeatureApp (a package set like /Developer/myproject/FeatureApp
|- KeychainClient (another package set like /Developer/myproject/KeychainClient)
...
and put another future packages at the same level
Great! Thank you @otondin for such a prompt response.
You can also put your packages inside a specialized folder like: /Developer/myproject/packages
|- FeatureApp (a package set like /Developer/myproject/packages/FeatureApp
|- KeychainClient (another package set like /Developer/myproject/packages/KeychainClient)
...
That way, assuming you're creating these packages to use on a specific project and isn't a library to use across projects, you can create your App project at /Developer/myproject path and add/manage your packages to your project pretty easily.
Yeah, Absolutely! Incase of multiple helpers the packages directory approach looks cleaner.