Latest1.0.1
Homepagehttps://github.com/stanwood/StanwoodUITestingCore_iOS
LicenseMIT
Platformsios 10.0
Authors

[Swift Version]()
[iOS 10+]()
[MIT]()

Table of contents

Author

Tal Zion [email protected]

Installation

platform :ios, '10.0'

pod 'StanwoodUITestingCore', :configurations => ['Debug']

Note: Make sure StanwoodUITestingCore is only added to Debug configurations.

Update

$ pod update StanwoodCore

Usage

Importing frameworks

#if DEBUG
    import StanwoodUITestingCore
#endif

Add a listener instance of UITestingCoreListener

#if DEBUG
    private var listener: UITestingCoreListener!
#endif

Listen for events and update Firebase live database instance

#if DEBUG
listener = UITestingCoreListener()

// Auth anonymously
// Note: Make sure this option is enabled on Firebsae, and only runs on the Debug instance
Auth.auth().signInAnonymously { (user, error) in

   DispatchQueue.global(qos: .background).async {

     // Listening to view events
     self.listener.listen { (item) in

     // Setting a Database instance
     let dataBase = Database.database()
     var ref = dataBase.reference()
     ref = ref.child("uitesting_hierarchy_ios")

     // Observing previous core versions
     ref.observeSingleEvent(of: .value, with: { (snapshot) in

         // Checking if the version exists
         guard let value = snapshot.value as? [String: Any],
            let data = try? JSONSerialization.data(withJSONObject: value, options: .prettyPrinted)  else {
                  let currentItems = UITestingCoreItems(versions: [item])
                  if let payload = currentItems.payload() {
                      ref.setValue(payload)
                  }
                  return
          }

          // Updating the current version
          if var currentItems = try? JSONDecoder().decode(UITestingCoreItems.self, from: data) {
               currentItems.append(item)

               if let payload = currentItems.payload() {
                   ref.setValue(payload)
                }
           }
        })      
      }
   }
}
#endif

ON/OFF switch

If you want to disable the listener, call:

listener.shouldListen = false

Licence

StanwoodUITestingCore is under MIT licence. See the LICENSE file for more info.

Latest podspec

{
    "name": "StanwoodUITestingCore",
    "version": "1.0.1",
    "summary": "StanwoodUITestingCore records view events.",
    "description": "StanwoodUITestingCore records view events to draw a view hierarchy to support StanwoodUITesting tool.",
    "homepage": "https://github.com/stanwood/StanwoodUITestingCore_iOS",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "stanwood": "[email protected]"
    },
    "source": {
        "git": "https://github.com/stanwood/StanwoodUITestingCore_iOS.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.0",
    "source_files": "StanwoodUITestingCore/Classes/**/*"
}

Pin It on Pinterest

Share This