Polyurethane foam alone will not hold up on an RV roof due to the short span flexing. If used, you'll need to cover it with another material to provide the UV protection and a impervious surface to bridge any micro cracks. Most commercial spray foam roofs are either coated with another product or they have the coating blended into the top foam, but blending isn't very strong against water penetration when dealing with a moving roof structure down a road.
One important consideration is if you want a membrane roof or an applied surface roof coating. A membrane roof is usually a flexible sheet glued to the roof surface to make a continuous waterproof surface. Membrane roofs will have cut opening for all roof penetrations and will need to have a coating applied at penetrations and protrusions. An applied coating is a product applied (usually in a liquid form) to the roof surface and it bonds to the surface making ti;s own continuous waterproof surface. Applied coating contours and wraps around any penetration or protrusion making it's own waterproof seal.
Another important consideration is a membrane roof is like wall paper where applied is like epoxy paint. For most membrane roofs, replacement is rather easy. Applied roofs usually ends up replacing the wood surface as well because it's a bear to get off!
They both have pros and cons so doing a bit of research on which best suits your needs should be the first step along with understanding the terminology and types of various materials.