The Waterwheel Swift SDK provides classes to natively connect iOS, macOS, tvOS, and watchOS applications to Drupal 7 and 8.

Overview

Waterwheel - Drupal SDK

CocoaPods Carthage compatible Swift version Drupal version CocoaPods

Waterwheel Swift SDK for Drupal

Waterwheel makes using Drupal as a backend with iOS, macOS, tvOS, or watchOS enjoyable by combining the most used features of Drupal's API's in one SDK. - Formerly known as Drupal iOS SDK.

FeaturesConfigurationUsageInstallationRequirements


Features in 4.x

  • Session management
  • Basic Auth
  • Cookie Auth
  • Entity CRUD
  • Local caching
  • LoginViewController
  • AuthButton
  • Views integration into Table Views

Back to Top

Configuration

  1. import waterwheel
  2. (Optional) If you're not using HTTPS you will have to enable the NSAppTransportSecurity

Usage

The code below will give you access to the baseline of features for communicating to a Drupal site.

// Sets the URL to your Drupal site.
waterwheel.setDrupalURL("http://waterwheel-swift.com")

It is important to note that waterwheel makes heavy uses of Closures, which allows us to pass functions as returns, or store them in variables.

Login

The code below will set up Basic Authentication for each API call.

// Sets HTTPS Basic Authentication Credentials.
waterwheel.setBasicAuthUsernameAndPassword("test", password: "test2");

If you do not want to use Basic Auth, and instead use a cookie, waterwheel provides an authentication method for doing so. Sessions are handled for you, and will restore state upon closing an app and reopening it.

waterwheel.login(usernameField.text!, password: passwordField.text!) { (success, response, json, error) in
    if (success) {
        print("logged in")
    } else {
        print("failed to login")
    }
}

Waterwheel provides a waterwheelAuthButton to place anywhere in your app. The code below is iOS specific because of its dependence on UIKit.

let loginButton = waterwheelAuthButton()
// When we press Login, lets show our Login view controller.
loginButton.didPressLogin = {
  waterwheel.login(usernameField.text!, password: passwordField.text!) { (success, response, json, error) in
      if (success) {
          print("successful login")
      } else {
          print("failed to login")
      }
  }
}

loginButton.didPressLogout = { (success, error) in
    print("logged out")
}
self.view.addSubview(loginButton)

Taking this one step further, waterwheel also provides a waterwheelLoginViewController. You can subclass this controller and overwrite if needed. For our purposes we will use the default implementation.

First, we build our waterwheelLoginViewController and set our loginRequestCompleted and logoutRequestCompleted closures:

// Lets build our default waterwheelLoginViewController.
let vc = waterwheelLoginViewController()

//Lets add our closure that will be run when the request is completed.
vc.loginRequestCompleted = { (success, error) in
    if (success) {
        // Do something related to a successful login
        print("successful login")
        self.dismissViewControllerAnimated(true, completion: nil)
    } else {
        print (error)
    }
}
vc.logoutRequestCompleted = { (success, error) in
    if (success) {
        print("successful logout")
        // Do something related to a successful logout
        self.dismissViewControllerAnimated(true, completion: nil)
    } else {
        print (error)
    }
}

Once that is done we can now tell our waterwheelAuthButton what to do when someone presses Login. Of course this can all be handled manually in your own implementation, but for our purposes, were just using what waterwheel provides.

Here we instantiate a new waterwheelAuthButton and tell it what we want to happen when someone presses login, and logout.

let loginButton = waterwheelAuthButton()
// When we press Login, lets show our Login view controller.
loginButton.didPressLogin = {
    // Lets Present our Login View Controller since this closure is for the loginButton press
    self.presentViewController(vc, animated: true, completion: nil)
}

loginButton.didPressLogout = { (success, error) in
    print("logged out")
}
self.view.addSubview(loginButton)

Because these two Views know whether you are logged in or out, they will always show the correct state of buttons(Login, or Logout) and perform the approriate actions. The UI is up to you, but at its default you get username, password, submit, and cancel button. With all that said, you can ingore these classes and use the methods that waterwheel provides and deeply integrate into your own UI.

Node Methods

Get

// Get Node 36
waterwheel.nodeGet(nodeId: "36", params: nil, completionHandler: { (success, response, json, error) in
  print(response)
})

Create/post

//build our node body
let body = [
    "type": [
        [
            "target_id": "article"
        ]
    ],
    "title": [
        [
            "value": "Hello World"
        ]
    ],
    "body": [
        [
            "value": "How are you?"
        ]
    ]
]

// Create a new node.
waterwheel.entityPost(entityType: .Node, params: body) { (success, response, json, error) in
    if (success) {
        print(response)
    } else {
        print(error)
    }
}

Update/Put/PATCH

// Update an existing node
waterwheel.nodePatch(nodeId: "36", node: body) { (success, response, json, error) in
    print(response);
}

Delete

// Delete an existing node
waterwheel.nodeDelete(nodeId: "36", params: nil, completionHandler: { (success, response, json, error) in
    print(response)
})

Entity Requests

Since Node is rather specific, Watherweel provides entity methods as well for all entityTypes

Entity Get

waterwheel.entityGet(entityType: .Node, entityId: "36", params: params, completionHandler: completionHandler)

Entity Post

waterwheel.sharedInstance.entityPost(entityType: .Node, params: node, completionHandler: completionHandler)

Entity Patch

waterwheel.entityPatch(entityType: .Node, entityId: "36", params: nodeObject, completionHandler: completionHandler)

Entity Delete

waterwheel.entityDelete(entityType: .Node, entityId: entityId, params: params, completionHandler: completionHandler)

Installation

Waterwheel offers two installations paths. Pick your poison!

Installation

CocoaPods

If you're using CocoaPods, just add this line to your Podfile:

pod 'waterwheel'

Install by running this command in your terminal:

pod install

Then import the library in all files where you use it:

import waterwheel

Carthage

Just add to your Cartfile:

github "acquia/waterwheel-swift"

Run carthage update to build the framework and drag the built waterwheel.framework into your Xcode project.

Communication

  • If you need help, use Stack Overflow. (Tag 'waterwheel-swift')
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Back to Top

Drupal Compatibility

The framework is tracking Drupal 8. As new features come out in 8, they will be added ASAP. Since Drupal 7 and Drupal 8 are completely different in terms of API's, you will need to use the correct version of waterwheel depending on your Drupal version.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 7.3+
waterwheel version Drupal Version
4.x Drupal 8 (Swift)
3.x Drupal 8 (Obj-C)
2.x Drupal 6-7 (Obj-C)

Back to Top

Comments
  • Problems with ASI-HTTP and ARC in iOS 5

    Problems with ASI-HTTP and ARC in iOS 5

    I was wondering whether there were any plans to upgrade the use of ASI-HTTP in this code as if you read the posts here http://allseeing-i.com/ the maintainer of ASI-HTTP is not going to continue develop.

    Also, if you do try to compile ASI-HTTP using ARC in iOS 5 you will receive a stack of problems. There are workarounds for this, but seeing as though ASI-HTTP is not going to be developed anymore, is there any intention of upgrading to new APIs in iOS 5?

    opened by scarer 24
  • Drupal 7 Swift 3.0

    Drupal 7 Swift 3.0

    Hey, thank you for all the hard work, I have a little question, I'm trying to use this on a Swift 3.0 project to connect to a server made in Drupal 7, so I'm targeting pod 'drupal-ios-sdk', '~> 2.1' but I can't even import it to the project I'm getting multiple errors:

    -DIOSComment.h:38:9: 'AFHTTPRequestOperation.h' file not found

    • Could not build Objective-C module 'drupal_ios_sdk'

    A little help on this would be much appreciated :)

    opened by diogoAntunes 12
  • Error 406 when Session Authentication enabled

    Error 406 when Session Authentication enabled

    Hello.

    First, thank you for the tremendous work that you put into building and developing Drupal-iOS-SDK. It is an amazing piece of work and I am impressed by its power daily.

    Second, as a bit of background, I am writing an iOS app that allows users to login to my Drupal site with their iPhone/iPad and access their inputted data currently stored/displayed in Views.

    Now, to my question/problem. So far, I have been able to successfully login to my Drupal site with the iOS app with OAuth and Session Authentication switched to off. However, as soon as I enable Session Authentication, I get a 406 error. I have tried looking online for a solution but, unfortunately, I have been unable to do so. What could be causing this problem and how would you recommend that I go about trying to resolve it?

    On a similar note, my hypothesis is that disabling Session Authentication is what is causing me to get a 401 error when trying to get the app to display the views I've created. Could that be the case? Will resolving my issue above so that I can enable Session Authentication then allow me to access the views?

    Thank you in advance for your help and have a great day!

    Sincerely,

    doctorDrupal

    opened by Yiphi 12
  • Build failed: Semantic Issue

    Build failed: Semantic Issue

    Hi,

    I've set up a new xcode project and added the AFNetworking library as described and build the project, no issues.

    Then I added the drupal-ios-sdk and tried to build the project again. Unfortunately now I get a "Semantic Issue" in DIOSNode.m within the nodeAttachFile in Line 114

    "Incompatible block pointer types sending 'void (^)(NSInteger, NSInteger, NSInteger)' to parameter of type 'void (^)(NSInteger, long long, long long)'"

    What did I do wrong?

    Thanks in advance, anni

    opened by ghost 11
  • SwiftyJSON ~> 3.0.0 is not available anymore, waterwheel.swift can't be build

    SwiftyJSON ~> 3.0.0 is not available anymore, waterwheel.swift can't be build

    Please remove SwiftyJSON from waterwheel Carthage file. Currently (v4.3.2), you have it linked against ~> 3.0.0 which is not available anymore.

    I suggest you remove the Cartfile from waterwheel.swift and let the user manage the dependencies self.

    As a result, waterwheel cannot be built, and the example is not working.

    Build Failed
    	Task failed with exit code 65:
    	/usr/bin/xcrun xcodebuild -workspace /Users/x/Projects/waterwheel.swift-4.x/waterwheelDemo/waterwheelDemo-iOS/Carthage/Checkouts/waterwheel-swift/waterwheel.xcworkspace -scheme waterwheel\ watchOS -configuration Release -derivedDataPath /Users/wouterbron/Library/Caches/org.carthage.CarthageKit/DerivedData/8.3.3_8E3004b/waterwheel-swift/123f65f3dab09100b622d57936060eea13f120ea -sdk watchos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/x/Projects/waterwheel.swift-4.x/waterwheelDemo/waterwheelDemo-iOS/Carthage/Checkouts/waterwheel-swift)
    
    This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/ht/wn3qf3rj6_5bpx20jdj2lk800000gn/T/carthage-xcodebuild.YMhf5P.log
    
    Fixed 
    opened by wousser 10
  • Removes setBaseURL Calls

    Removes setBaseURL Calls

    setBaseURL doesn't exist as a method and anyone trying to use this library has always (or at least as long I've been using it for the past year+) had to just comment out those lines in order to compile. It seems like whatever was supposed to be accomplished with those lines is handled with the initWithBaseURL calls.

    opened by WesWedding 9
  • Support Request: maintaining a session?

    Support Request: maintaining a session?

    How do I verify if a session is open in Drupal using the DIOS SDK? I don't find it in the documentation. I think that the documentation is also a bit outdated. Thank you.

    opened by utneon 9
  • File.save issue

    File.save issue

    Hi Kyle, So bumped into a problem with file.save, when running the operation from iOS, we don't get any data returned, so have no access to the fid and the file doesn't appear to be saved. Is there something custom in your Services module, other than the Plist Server? We have the file service modules installed. Using the example app, using the default url (demo.kylebrowning.com) everything works fine, but using our server it doesn't work. So it doesn't appear to be a problem in the iOS code, it's something in the server. We have everything set up as far as I can see described in the readme, and other operations do work (node.save etc). If there is nothing else custom can you release your module versions?

    Many Thanks, Chris Darke

    opened by ChrisDarke 9
  • nodeAttachFile example for Services 7.x-3.x

    nodeAttachFile example for Services 7.x-3.x

    Hi Kyle,

    It looks like file_attach is still a work in progress on Services 7.x-3.x: http://drupal.org/node/1484992

    I'm wondering if there's a DIOS 2.0 example out with working file attachment.

    I am unable to attach files from DIOS at the moment, and I don't know if my issue is my Drupal configuration or DIOS.

    opened by c5f 8
  • file.save response fail

    file.save response fail

    When trying to upload a new file to Drupal with services 6.x 3.x, the obtained response is not a property list and fails conversion from NSData to NSDictionary

    Error Domain=DIOS-Error Code=1 "Encountered unknown tag br on line 1" UserInfo=0x11fb9d0 {NSLocalizedDescription=Encountered unknown tag br on line 1}

    trying to print the received response as ASCII NSString:

    Printing out response as ASCII text: è!>

    the DIOSFile and DIOSConnect is original, not modified from github latest version. the code for the file upload is very similar to the one that can be found on DIOSExample code.

    opened by ohdonpiano 8
  • session trouble

    session trouble

    I'm trying to create an app that should be accessible only to logged users. Everything I tried works fine, but I can't figure out how to properly access the session once the user log in with the app. As a result I have to delete the app or the second login attempt fails with 406 http error. So my question is: what is the best way to "save" the logged session and reuse it later? (That should be connected to the question: how to properly detect if a user is already logged?) I'm using the latest dev and [DIOSSession sharedSession] is not working as I expect and gives me back a nil object.

    opened by meSte 7
  • Provide ability to change how  requests are cached

    Provide ability to change how requests are cached

    • [x] Cache all requests sent through Waterwheel
    • [ ] Provide way of changing cache lifetime for a particular request
    • [ ] Provide way of changing cache lifetime for all requests
    Added task 
    opened by kylebrowning 0
Releases(4.3.4)
  • 4.3.4(Oct 25, 2017)

  • 4.3.3(Sep 18, 2017)

    Released on Monday, September 18, 2017. All issues associated with this milestone can be found using this filter.

    Fixed

    • Private methods became public
      • Implemented by kylebrowning
    • Fixes issue with demo project build.
    Source code(tar.gz)
    Source code(zip)
  • 4.3.2(Mar 25, 2017)

  • 4.3.1(Sep 30, 2016)

    Released on Friday, September 30, 2016. All issues associated with this milestone can be found using this filter.

    Updated

    • Update Carthage to use regular SwiftyJSON
      • Implemented by kylebrowning in #148.
    Source code(tar.gz)
    Source code(zip)
  • 4.3.0(Sep 27, 2016)

    4.3.0 (09/27/2016)

    Released on Tuesday, September 27, 2016. All issues associated with this milestone can be found using this filter.

    Updated

    • Update waterwheel demo to use waterwheel-swift.com
      • Implemented by kylebrowning in #147.
    • Support Swift 3.0
      • Implemented by kylebrowning in #144.

    Fixed

    • Fixes Carthage support
      • Implemented by kylebrowning in #146.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.8(Aug 26, 2016)

    Released on Friday, August 26, 2016. All issues associated with this milestone can be found using this filter.

    Added

    • Provide ViewsTableViewController
      • Implemented by kylebrowning in #141.

    Fixed

    • waterwheelLoginViewController has no cancel button/action
      • Implemented by kylebrowning in #143.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.7(Aug 17, 2016)

    Released on Wednesday, August 17, 2016. All issues associated with this milestone can be found using this filter.

    Changed

    • Rename ViewExtension because it can be confused with a Drupal View
      • Implemented by kylebrowning in #140.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.6(Aug 16, 2016)

    Released on Tuesday, August 16, 2016. All issues associated with this milestone can be found using this filter.

    Updated

    • 100% doc coverage for waterwheelAuthButton
      • Implemented by kylebrowning in #138.

    Changed

    • Move Title color from Auth button out of setup
      • Implemented by kylebrowning in #139.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.5(Aug 16, 2016)

    Released on Tuesday, August 16, 2016. All issues associated with this milestone can be found using this filter.

    Fixed

    • properties on AuthButton are protected
      • Implemented by kylebrowning in #137.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.4(Aug 15, 2016)

    New functionality in this release:

    • Auth Button, remembers auth state.
    • Persist waterwheel settings throughout app closure/phone restart
    • Login View Controller, setups a Login View Controller that will allow you to manage login state.
    • Fixes login/logout state to be consistent with 8.2
    • Adds notifications for all requests
    Source code(tar.gz)
    Source code(zip)
  • 4.2.3(Aug 11, 2016)

    Fixed in this release:

    • Views Extension added for easier layouts of programmatic code.
    • Adds isLoggedIn method
    • properly logs out basic authentication
    • Adds asserts to force certain variables are set.
    Source code(tar.gz)
    Source code(zip)
  • 4.2.2(Aug 5, 2016)

  • 4.2.1(Aug 5, 2016)

  • 4.2.0(Aug 3, 2016)

Owner
Kyle Browning
👨🏻‍💻 Swift @TheAthletic
Kyle Browning
iTunes Connect Library inspired by FastLane

Mothership iTunes Connect Library inspired by FastLane I wrote MotherShip for two reasons. love FastLane, but I am not proficient in Ruby. I wanted to

thecb4 74 Nov 3, 2022
The unofficial Instagram iOS SDK

InstagramKit An extensive Objective C wrapper for the Instagram API, completely compatible with Swift. Here's a quick example to retrieve trending med

Shyam Bhat 955 Dec 12, 2022
This repository is for the new ARGear SDK library for the iOS platform

This repository is for the new ARGear SDK library for the iOS platform. The library is not official yet. The library will be updated frequently by applying user feedback. When the APIs are fixed, the official library will be released.

ARGear 2 Apr 5, 2022
A swift SDK for Medium's OAuth2 API

Medium SDK - Swift A library to allow access to Medium API for any Swift iOS application. Features Medium.com authorization & token handling Login sta

null 11 Jan 22, 2022
👤 Framework to Generate Random Users - An Unofficial Swift SDK for randomuser.me

RandomUserSwift is an easy to use Swift framework that provides the ability to generate random users and their accompanying data for your Swift applic

Wilson Ding 95 Sep 9, 2022
An Elegant Spotify Web API Library Written in Swift for iOS and macOS

Written in Swift 4.2 Spartan is a lightweight, elegant, and easy to use Spotify Web API wrapper library for iOS and macOS written in Swift 3. Under th

Dalton Hinterscher 107 Nov 8, 2022
Studio Ghibli Movie database in Swift. For iOS, iPadOS, and MacOS.

Ghibliii Studio Ghibli Movie database in Swift *Colours are shifted due to compression About This started as a way for me to do something in this quar

Kevin Laminto 19 Dec 9, 2022
iOS/macOS Cross-platform Ark-Ecosystem Framework in Swift | Powered by Ѧrk.io |

a macOS & iOS Swift Framework for Ark.io. What is ARKKit? ARKKit is wrapper for interacting with the Ark Ecosystem. It is written purely in Swift 4.0,

Simon 19 Jun 28, 2022
Easy and powerful way to interact with VK API for iOS and macOS

Easy and powerful way to interact with VK API for iOS and macOS. Key features ?? It's not ios-vk-sdk ?? ?? One library for iOS and mac OS ?? ?? Fully

null 260 Dec 22, 2022
A Swift wrapper for Foursquare API. iOS and OSX.

Das Quadrat Das Quadrat is Foursquare API wrapper written in Swift. Features Supports iOS and OSX. Covers all API endpoints. Authorization process imp

Constantine Fry 171 Jun 18, 2022
Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)

DribbbleSDK DribbbleSDK is easy-to-use iOS wrapper for Dribbble SDK. We're working hard to complete the full coverage of available methods and make th

Agilie Team 74 Dec 2, 2020
A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

Matt Donnelly 2.4k Dec 30, 2022
Twitter Clone for iOS With Swift

Postwitter Date: December 1, 2021 Product Name: Postwitter Problem Statement: iO

Shohin Abdulkhamidov 3 Aug 16, 2022
Wanikani-swift - Unofficial Swift client for the WaniKani API

WaniKani A Swift library and client for the WaniKani REST API. It currently supp

Aaron Sky 5 Oct 28, 2022
The Easiest and Simplest iOS library for Twitter and Facebook. Just Drop in and Use!

EasySocial iOS Library for Twitter and Facebook This library allows your apps to use Twitter and Facebook with minimal understanding of the relevant S

pj 124 Nov 17, 2022
Giphy API client for iOS in Objective-C

Giphy-iOS Giphy-iOS is a Giphy API client for iOS in Objective-C. Usage To run the example project, clone the repo, and run pod install from the Examp

alex choi 52 Jul 11, 2019
Easy Proximity-based Bluetooth LE Sharing for iOS

Description Easy Proximity-based Sharing for iOS Perfect for any iOS app that needs to quickly share items with nearby friends, such as groups, photo

Laura Skelton 132 Aug 10, 2022
AWS Full Stack Swift with Apple CarPlay

This application demonstrates a full-stack Apple CarPlay app that uses Swift for both the UI and the backend services in AWS. The app accesses Lambda functions written in Swift and deployed from Docker images. The app accesses Amazon Location Service and a 3rd party weather api to display information in the vicinity of the user.

AWS Samples 100 Jan 6, 2023
Pokeapi wrapper, written in Swift

PokemonKit What is this? PokemonKit is a swift wrapper for Pokeapi. PokemonKit use Alamofire and PromiseKit for async web requests handling. Usage imp

Continuous Learning 105 Nov 16, 2022