Moltin - iOS Test-Application and my thougts on Moltin


Hi everyone,

first of all sorry for my bad english - i really do not speak or write often in english.

Im Daniel. Im 26 years old and for 1 1/2 years now i try to learn Apples programming language Swift. I was searching for a eCommerce plattform which is easy to use, has many features (like an all-in-one-solution) and which has a Swift SDK so i can implement the plattform easily to my project.

So i used my best friend google and got to Moltin. I searched a little bit more and i found the github repository with an example Swift/iOS App. My first thought was: Wow - that looks simple, but thishas everything you are looking for.

So i started my own project with the SDK in v2 and this is where i am now: download a video of the test iPhone app

Beside Moltin i use Firebase for user authentification (and to save the shipping/delivery adress of a customer)
For the user authentification i use Firebase. Also i will store the user shipping and billing adress in Firebase, so when the user will checkout he can choose between his last used adresses (although the checkout/order/payment functions right now are still not finished, like the app overall).

Things i like:

  • easy to use, scaleable and customizable
  • dashboard, so you can easily create new products, collections and so on easily on your Mac/PC
  • you can create custom fields, for example i use a custom fields for products where i can set a reduced price for products in sale
  • the example app was great and a big help to get started

Things where i have problems with/i would like to see:

  • in checkout i dont get the order-object back from the Moltin server, although i can see the new created order in the dashboard (created support-ticket for that). Don’t know if ive made a mistake or if it is a bug in the Swift SDK.
  • more search options. for example: Get products function with an Array of product Ids as input. So this would make 1 API-call instead of lets say 20 single product.get calls.
  • some more documents/examples on how to implement the payment methods/gateway? (im still not sure how i could implement PayPal for example as payment method - looks like i have to use braintree or stripe as gateway but im not sure which methods/calls i need)
  • more v2 dashboard functions/fixes. Editing orders for example as new function. Fix a problem where sometimes you can not delete a collection/product/brand (also opened a supper ticket for that)
  • customer object which can be edited/viewed in the dashboard, too and where the shipping/billing adress can be saved on

Overall i think Moltin is a great solution for everyone - its really is easy to use (so far) and it gives you everything you need to create your own little shop with a custom shopping expierence for the user, you should try it out. :slight_smile:

Best regards


Hey Daniel,

Thanks for the great write up of your experience and the feedback, super useful and I’ll be sharing with our team! Loved the video of the test app that you’ve put together too :slight_smile:

I’ll try and answer some of the issues you encountered along the way as some of the points you mentioned are in progress or we might have some useful resources to point you in the right direction.

  • Regarding order object on checkout I will need to double check the iOS SDK for the response but our API reference shows the JSON response that should be accessible on a successful request.
  • We’re continuing to build out our search capabilities, an array of product IDs is an interesting use case. It should also currently be possible to flip this around a little by requesting a single (GET) category and include products in that category (looks like this functionality needs to be documented).
  • We’ll continue to test and document payment integrations over time (including Paypal) but right now we currently support and have documentation for Stripe, Braintree and Adyen. Here is a Stripe guide for taking payments that might be helpful.
  • The dashboard is an on-going project with updates and fixes deployed every week. I’ll read over the ticket for the delete issue you encountered and ensure one of our team picks it up to help get to the bottom of the issue.
  • Customer and address management within the dashboard is on the roadmap too!

Thanks again,


Hey Adam,

thank you for your reply and the informations and links, im sure they will be helpful for me.

  • The dashboard already got fixed, so now i am able to delete brands and collections without any problems - thank you for the fast solution to you and the dashboard devs :wink:
  • Customer and address management inside Moltin sounds great, cant wait to see this in future.
  • Yes you are right, i could use a category request and would get all the products in it with one request. I could already find this one in the documentation and it works great. However the products may not always be in the same category so im happy to hear that you guys are continuing to build out the search capabilities, even though im sure this is not really important in near future as other search options work great.

Solution to my Order-Problem:
I could find out, why my order object was nil even if the order was created successfully.

The problem was inside the Order.swift file i think. There was this part in line 55 + 56 in the guard let statement:

let shippingString: String = "shipping" <~~ json,
let shipping = Shipping(rawValue: shippingString),

However in a new created Order the shippingString will be “unfulfilled”. And as the Shipping enum looks like this:

public enum Shipping: String {
    case notShipped = "not_shipped"
    case partial
    case shipped

let shipping = Shipping(rawValue: shippingString) then does not work and the order.init returns nil.

Ive added now some more lines to my Order.swift file and basically i do this now:
if shippingString == “unfulfilled” i then say
shipping = Shipping(rawValue: “not_shipped”).

Now everything works and i get the Order-Object back after the checkout was successful. However i don’t know if my solution is the right way, maybe you could check this?

Thanks and best regards


Hi Daniel,

I’m facing the same situation like you. I tried the way you provide, but it seems not working to me. And I’m new at swift. Hope you can get me a little help.



Hi 3TO16,

sorry for the late response. I dont think my custom solution is a good way to solve this problem. This is sonething Moltin should look out for to fix/improve the Swift SDK.

Maybe some Moltin Devs could look inside the Orders.swift file from the SDK and check if there is everything correct?


Hey Daniel and 3TO16,

Day 3 here at Moltin for me so not an expert but wanted to dig into this a bit more if you guys are still struggling. I have been working off the new SDK which seems to have a different Order class, Have some swift experience so would want to hear if you are having any other issues working on your apps.



Hi George,

thank you, looks good now. Good job.

I had no other problems (or could solve it already), maybe you could update the Swift SDK example app because the example app helped me a lot in the beginning but seems a little bit outdated now. :slight_smile:

Thank you again and good luck and much fun at Moltin. :wink:


That is great to hear. I can not take any credit though. We have an awesome team here working on it. They also did make a new sample app It should be a good starting place for any project. If you have any ideas of what would help in sample app let me know.


Thank you George, really appreciate your help.

At least for me the sample app would not build and run when CMD+R in Xcode. It will build without any error but not run. So i’ve edited the schemes (im not an expert, too) and after changing the signing under the project targets i was able to build and run the app now. But this is not a big deal, im sure every developer could solve this within minutes, its just me who is not an expert.

Everything else works now inside the example app, you are right.

Two questions i do have after playing around with the new SDK (which works much better than the older versions):

  1. When i try to create a variable like:
    var cols: [Collection]?
    I get:
    'Collection' is ambiguous for type lookup in this context.
    -> Any idea how i could make a variable for an array of collections? Same problem with [Category]. On the other hand [Product] works just fine.

  2. Product-Objects inside Collection-Objects for example

     moltin.collection.all { (response) in
         switch response{
         case .failure(error: let err):
             print("Error: \(err)")
         case .success(result: let result):
             print("Success: \(!.first!.relationships!.products!.getIds())")
             //Works fine, i get the productIds.
             print("Success: \(!.first!.products?.count)")
             //Does not work, i get no product objects.

-> Would be awesome if we always get the objects back from our requests, as we could then work with them inside the app without any further requests. Would this be possible?

Thank you again and sorry, if i make work to you guys.


Hey Daniel,

Couple quick things below, and a screenshot of how you want your schema.

  1. Not sure I have all the context on this one, but going to take a stab at it.
    If you want to use the moltin specific class you should try referencing moltin.
    var categories: [moltin.Category] = []
    var cols: [moltin.Collection] = []

  2. Agree that could be convenient when getting started just to have all the data available. It would get messy and hard to handle fast though. There may be some shared attributes you could get using flows. (just getting to know this, very cool though)

If you wanted just to get all the products to check out the data you could try this.

        self.moltin.category.include([.products]).all { (result: Result<PaginatedResponse<[moltin.Category]>>) in
            switch result {
            case .success(let response):
            case .failure(let error):

Hope this helps


Hi George,

thank you again. I guess i know what the problem is, see:

My moltin object seems quite different to yours. Do we both have the same version of the SDK or do i have a problem with my Xcode?

Your hint to moltin.category.include was great, works perfect. Thank you. Don’t ask me why my Xcode can work here with “moltin” but can not use it to declare variable types … i don’t get it.


You need to move your moltin let into the class you are going to use it in. (move line 12 to 16)


HI @danieljapps

Looks like there’s a bit of clashing going on between the framework name, the Moltin class, and the default Swift library.

I’ll try and explain as simply as I can!

Using moltin.Collection is the intended way of namespacing our Collection object, however due to installing the project via CocoaPods (I’m assuming), the framework gets renamed from moltin to Moltin. This then clashes with the Moltin class, so when you do Moltin.Collection, it’s attempting to get a class member from the Moltin object.

There is a workaround you can use while we sort this out, which is to import the Collection object directly:

import Moltin
import class Moltin.Collection

This allows you to use Collection in your types:

var collections: [Collection]? = []

If you need to use Swift’s Collection protocol, you could then use Swift.Collection.

We need to have a think about the best way to fix this: I believe the easiest may be to see if we can change the framework name to moltin when installing via CocoaPods, but we need to do some due diligance on this. We could also prefix the objects with Moltin or similar, e.g MoltinCollection / MCollection, MTCollection, but really we shouldn’t need to do this as Swift has namespaces for a reason.

Let me know if this works for you!


Thank you @craigtweedy, yes your solution works fine and your description of the problem was very easy to understand - thank you. Yes, i have installed the SDK via CocoaPods. I have tried some SDKs where you can install the SDK with Carthage instead of CocoaPods - i find this pretty good as you still work with an .xcodeproj project instead of a .xcworkspace project. Maybe you could offer this in future as well, although i have no idea how hard it is to implement this.

In the meantime i think changing the framework name to moltin instead of Moltin when installing via CocoaPods sounds like a very good solution for this problem.

I have another strange issue (i have tried it already on a new clean project as well) that after cleaning my project 50% of the time Xcode has problems to find a module called Moltin. I found the following thread on Reddit, maybe you guys could take a look on this issue as well? No such Module - Moltin Reddit Post

Like i said, for me this is really strange because sometimes Xcode can find the Module and sometimes not. If it cannot find the Module i only have to Clean the project (without any other changes) and with a little luck it then works.

I think it is not really necessary for a company to offer SDKs, so i really appreciate what you guys are doing here. Thank you for the quick responses and that you offer us SDKs in different environments - especially for smaller and/or developers with a little bit less experience like me the frameworks are very helpful.

Best regards


Hey @danieljapps!

We do support Carthage (as well as Swift Package Manager) if that works better for your project. Carthage correctly imports the framework as moltin which solves the framework clashing issue. I’ll catch up with @GeorgeF to see if we’ll hit any issues renaming that pod. I think it might just be a documentation issue to let people know that it’s now all lowercase :slight_smile:

The Reddit post looks like an issue we’ve already solved on our GitHub issues, but I’ll certainly respond there as well to let people know.

Could you also clean out your derived data folder? I has some problems from previous versions of the SDK that attempted to support macOS would cause issues like what you’re seeing, but once I cleaned derived data that went away. Let me know if this helps and feel free to open an issue on GitHub and we’ll deal with it specifically there if there’s still an issue.

That’s very kind of you to say, we’re always looking for ways we improve your experience of Moltin, I feel like SDK’s are a big proponent of that. I know we still have ways we can improve, especially with the example apps which we’re working on, but if you have any other thougths and suggestions feel free to open a post in the Swift forum category and we’ll take a look!


Hi guys,

new SDK is awesome ! I love it. Really a big thank you for this SDK. The implementation of custom fields and the possibility to use custom objects when working with flows is amazing.

I have one single error after a week of testing.

moltin.cart.removeItem always results in an error response:
couldNotParseData(Optional(Swift.DecodingError.typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: “Expected to decode Dictionary<String, Any> but found an array instead.”, underlyingError: nil))))

But although its an error the item gets removed from the cart. So i guess its only the response which is not correct.

Thank you guys and best regards


Hey @danieljapps!

Thanks for raising this. Looks like the API is returning an array of cart items, but the SDK is attempting to parse just the cart. I’ll raise this and see if we can push out a fix as soon as possible.

Like you say, it’ll be correctly sending that request, but not parsing the response correctly!



Hey @danieljapps - I’ve also added an issue to our SDK repo. Feel free to chime in or track progress there :slight_smile:


Thank you @Craig.

If i find other issues ill add next time an issue to the sdk repo, too. Sorry for posting this in the forum. :sweat_smile:

You are right, line 156 in CartRequest.swift as followed fixed the problem:
completionHandler: @escaping ObjectRequestHandler<[CartItem]>) -> MoltinRequest {

Thank you and best regards