Error when using tilemap methods when trying to build

I am not able to use SetEditorPreviewTile when I go to build, it gives the following error:

error CS1061: Type `UnityEngine.Tilemaps.Tilemap’ does not contain a definition for ‘SetEditorPreviewTile’ and no extension method ‘SetEditorPreviewTile’ of type ‘UnityEngine.Tilemaps.Tilemap’ could be found. Are you missing an assembly reference?

Did you ever solve this? I have the same error!