Component not destroyed

I am destriying the InteractiveCloth component of a GameObject and then adding it again but Unity gives an error “Can’t add component ‘InteractiveCloth’ to Cloth because such a component is already added to the game object!” even though the InteractiveCloth component has been destroyed and no longer shows up in the inspector when the error pauses the game.

my code:

		InteractiveCloth cloth = gameObject.AddComponent("InteractiveCloth") as InteractiveCloth;
		cloth.mesh = transform.GetComponent<MeshFilter>().mesh;
		ClothRenderer cr = gameObject.AddComponent("ClothRenderer") as ClothRenderer;
		cloth.AttachToCollider(player.transform.collider, true, true);
		cloth.AttachToCollider(target.transform.collider, true, true);

Destroy actually happens at the end of the frame, so I think when you try to add it it is actually still there and then destroy.

Solution would be to use DestroyImmediate but it is not recommended for some reasons. Other way could be to use a coroutine:

private IEnumerator RemoveAddComponent(Component component)
    yield return null; // Quit and back here next frame

I’d guess that should work.