DEV Community

Hanh Q. Vu
Hanh Q. Vu

Posted on

Tuist & Revenue Cat, Part 1

This blog post series is done in conjunction with the Ship-a-thon/Melting-hacks
Part 1 of 2 will focus on explaining why & how to use Tuist with Revenue Cat.

Why Tuist

I'm sure most iOS engineer have had the (un)fortunate experience of collaborating on a Xcode project. The reality is that Xcode project files are very brittle and while it is not exactly a propriety file formate, the structure and underlying syntax is a mystery in and of itself.

If you are coming to iOS from other ecosystems with excellent tooling, especially for managing dependencies & configurations, such as Go or Rust, you will be surprised on how cumbersome the workflow in Xcode is.

Tuist was created to solve this exactly problem. Not only can you manage your depend dependencies & configurations directly with Swift, you can save so many hours resolving conflict for the Xcode project files. I will not go in depth on how to setup and use Tuist in this blog but I will include resource below for your references.

Why Revenue Cat

In the same vein with Tuist simplifying the workflow with Xcode, Revenue Cat helps simplifying the way that you can monetize your app.

I was (un)fortunate to have been able to experience the Stripe SDK before trying my hands at monetizing an iOS app. To say the experience with Stripe is sublime is selling it short. Whatever you need to create an excellent monetization workflow, Stripe has it all. From excellent documentation, beautiful dashboard or convenience integrations, you won't need for much else with Stripe.

However, the experience with StoreKit is the exact opposite if I might say. Not only you have to contend with a rather poor documentation, there are a lot of back-ends code that you need to maintain to be able to use StoreKit. This is not practical, especially for smaller teams or indie developers.

Revenue Cat is the perfect tool to help you solve this exact problem & monetize your app quickly. A lot of works that has gone into building a easy-to-use SDK (which is available not only for Swift but many other languages & frameworks for building mobile apps) along with built-in analytics and intuitive dashboard. If you want to learn more about Revenue Cat, do take a look at their homepage here.

Putting them together

Each of these tool by itself is already a tremendous boost to your productivity, combining them together is an even better developer experience. However, as great as they are, the documentation cannot cover all use cases. As such, when trying to using them together, I have a bit of a struggle. Hopefully, I can help make using them a little easier.

Assuming you have setup Tuist on your machine, you can open the Terminal and navigate to the project folder. Executing the command below will open up a Xcode window so you can modify the project configurations.

tuist edit
Enter fullscreen mode Exit fullscreen mode

Open the Package.swift file. This is where you can declare your dependencies.
The syntax is the same if you have declare a dependency in other Xcode projects' Package.swift.
Let's go ahead and add the Revenue Cat package to your project.

let package = Package(
    name: "YourAwesomeApp",
    dependencies: [
        // Add your own dependencies here:
        // .package(url: "https://github.com/Alamofire/Alamofire", from: "5.0.0"),
        // You can read more about dependencies here: https://docs.tuist.io/documentation/tuist/dependencies
        .package(url:"https://github.com/RevenueCat/purchases-ios-spm.git", .upToNextMajor(from: "5.0.0"))
    ]
)
Enter fullscreen mode Exit fullscreen mode

Please do refer to the Revenue Cat SDK to make sure that you are getting the latest compatible version with your project. Next up, we will declare the package in our project configuration/manifest file.

dependencies: [
    .external(name: "RevenueCat"),
    .external(name: "RevenueCatUI"),
]
Enter fullscreen mode Exit fullscreen mode

You can choose to import only Revenue Cat or with Revenue Cat UI. For me, I imported both because the Revenue Cat UI package will give you access to templated paywall which is well designed and easy to use.

With this, you have basically finished setting up Revenue Cat in your Tuist project. This blog post only cover the basics to get you started. For part 2, I will delve deeper into the integration and show you the real power of using them together.

Resources

Top comments (0)