Will spray foam on basement walls prevent condensation?
...preventing it from drying. Despite it being allowed (and usually insisted upon), putting vapour barriers on basement walls does nothing good, but it does a lot of harm. You can read more here –
Why are Basements Moldy? How to Fix & Prevent Mold in Homes
The short story is that concrete is wet and dirt is wet, so ...