iOS Buy SDK 2.0
Overview
Shopify's APIs are evolving, and the Buy SDK is being revised to keep in sync. The next version of the SDK is underway, with a targeted release date for the end of April, 2016. Many of the features of the next version area already in use in private projects within Shopify. Over the next few weeks, we'll be cleaning up and deploying those features into this repository.
New 2.0 changes will be integrated on the version-2 integration branch. When it's ready, it will take over as the master branch. The current develop branch will be renamed and deprecated at that time.
Goals for Buy SDK 2.0
- support for the latest version of the Shopify Checkout API
- support for the latest version of the Shopify Channels API
- support for the new Shopify Customer API
- declarative data model and auto-generated model classes
- dynamic JSON serialization support
- hooks to allow developers to extend the SDK with local caching solutions (including Core Data)
- streamlined framework target, focussed solely on exposing API features
- sample UI and view controllers provided as part of sample apps
Revised data model management
The Shopify data model will be represented by a Core Data Managed Object Model. It's a rarely exploited fact that the Managed Object Model classes are useful even without a Core Data persistence stack. We've converted the old models, and are generating new model class files with mogenerator. Some model types and property names will be updated to be more consistent with Apple Objective-C naming standards.
Hand-written JSON serialization will be replaced with a fully dynamic solution relying on extensions to the Core Data model description classes: NSEntityDescription
and NSPropertyDescription
(and subclasses: NSAttributeDescription
and NSRelationshipDescription
). These will implement a set of reasonable conventions for JSON<->model transformations. But, they can be customized using user info settings defined in the model file to support variations, including custom key mappings, custom data formats, custom relationship mappings, transient-only properties, documentation, and more.
Model object lifecycle will now be owned by a model manager (BUYModelManager
), to ensure creation and deletion of objects is properly tracked. The BUYClient
will instantiate new models via BUYModelManager
when processing responses from Shopify APIs.
Project Management
The new version of the SDK will continue to be written in Objective-C, to ensure support for apps written in both Objective-C and Swift.
We will be looking at improvements to the current target structure, but may have to defer significant changes to a later milestone.
In the short term, we will be making a few small changes to allow opt-in for some features. The first optional feature will be for Core Data caching support. Because model objects in Core Data must inherit from NSManagedObject
, a build setting will allow enabling Core Data support. This will change the default inheritance of model classes. It will also conditionally compile some methods either on BUYObject
, or BUYManagedObject
, to ensure a consistent interface, regardless of whether the feature is enabled. Input from 3rd party developers is desired, regarding these designs.
Note that full support for Core Data-based caching is not a goal of this new version. At the moment, we want to limit the growth of complexity of the SDK for the majority of users. Developers who wish to opt in to local data caching support must have the experience to manage a Core Data persistence stack. Furthermore, they are strongly recommended to contact their Shopify representative for information about joining our Shopify Plus program.
Milestone Issues
cc @davidmuzi @dbart01