Shopify / mobile-buy-sdk-ios

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.
MIT License
453 stars 198 forks source link

Conflicting SDK name with Apple's Framework name: Task modifier #1201

Open ashleydee1999 opened 1 year ago

ashleydee1999 commented 1 year ago

Hi,

I'm trying to run an asynchronous task in SwiftUI, however, I'm failing to do so because the SDK is using the same name as Apple's framework. You structure your code as follows in swift to run an asynchronous task:

  Task{
              await myAsycFunc()
          }

The conflict arises from this file Graph.Task.swift . It has the following protocol definition:

public protocol Task {

    /// Starts the underlying task
    func resume()

    /// Cancel the underlying task
    func cancel()
}

My error then becomes: 'any Task' cannot be constructed because it has no accessible initializers

maxxfrazer commented 1 year ago

@cocoahero this is a pretty tricky issue, causing build errors for anyone using async commands in Swift with the Task<Success, Failure> struct from the Concurrency framework.

I know it's annoying, but if this could be renamed to something like BuyDataTask or something else that would be more appropriate in the next version that would be great. IMO "Task", and also "Graph" are a bit too generic to be public classes.

markshiz commented 4 months ago

FWIW - My work around for this is to do the following in my app. But I agree that another name should be chosen here.

import Buy

typealias Task = _Concurrency.Task