Source class "\Ocodewire\Designtool\Setup\CategorySetup" for "Ocodewire\Designtool\Setup\CategorySetupFactory" generation does not exist

Thanks For help,

but i am getting error

[ReflectionException]
Class Ocodewire\Designtool\Setup\CategorySetupFactory does not exist

[Magento\Framework\Exception\LocalizedException]
Source class “\Ocodewire\Designtool\Setup\CategorySetup” for “Ocodewire\Designtool\Setup\CategorySetupFactory” generation does not exist.

on php bin/magento setup:upgrade

here is my file

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Ocodewire\Designtool\Setup;

use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

/**
 * @codeCoverageIgnore
 */
class InstallData implements InstallDataInterface
{
    /**
     * Category setup factory
     *
     * @var CategorySetupFactory
     */
    private $categorySetupFactory;

    /**
     * Init
     *
     * @param CategorySetupFactory $categorySetupFactory
     */
    public function __construct(CategorySetupFactory $categorySetupFactory)
    {
        $this->categorySetupFactory = $categorySetupFactory;
    }

    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {        
        $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
        $categorySetup->installEntities();
        $categorySetup->createCategory()
        ->setStoreId(0)
        ->setPath('1/2/3')
        ->setName('T-Shirt')
        ->setDisplayMode('PRODUCTS')
        ->setAttributeSetId($category->getDefaultAttributeSetId())
        ->setIsActive(1)
        ->setLevel(1)
        ->setInitialSetupFlag(true)
        ->save();
    }
}

This is my InstallData.php file which is in setup folder of my custom module.

Is the class \Ocodewire\Designtool\Setup\CategorySetup really exist?

no

So it is your fault: you are using the unexisting class in the code:

    /**
     * Init
     *
     * @param CategorySetupFactory $categorySetupFactory
     */
    public function __construct(CategorySetupFactory $categorySetupFactory)
    {
        $this->categorySetupFactory = $categorySetupFactory;
    }

A post was split to a new topic: How can I diagnose the «Undefined variable: category» failure in my own code?