Latest 0.1.2
License MIT
Platforms ios 11.0, requires ARC

This was created to use in unit tests for apps utilizing CoreBluetooth or any other Apple framework that doesn’t allow you to instantiate framework elements. (Ex. CBPeripheral)


In your podfile add

pod 'MockObject'


You can create an instance of any class by writing MockObject.createInstance(ofClass: "YOUR_CLASS"). This object will return as Any? so you need to tell the compiler what it is and assign required values, but you’ll be able to use it for anything that requires an instance of that class. It’s useful for unit tests, but NEVER USE THIS IN PRODUCTION CODE


guard let peri = MockObject.createInstance(ofClass: String(describing: CBPeripheral.self)) as? CBPeripheral else {

peri.setValue(UUID(), forKey: "identifier")
peri.addObserver(peri, forKeyPath: "delegate", options: .new, context: nil)

Latest podspec

    "name": "MockObject",
    "version": "0.1.2",
    "summary": "Framework for creating mock objects of iOS framework elements that are unable to be instantiated.  Ex: CBPeripheral",
    "description": "Mock any class, created to instantiate framework classes for unit testing an app that uses CoreBluetooth.  Ex: CBPeripheral",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Chris Larsen": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "11.0"
    "source": {
        "git": "",
        "tag": "0.1.2"
    "source_files": "MockObject/**/*.{h,m}",
    "public_header_files": "MockObject/**/*.h",
    "requires_arc": true

Pin It on Pinterest

Share This