Can I run Lion in a virtual machine under Mavericks? I've just realised I can't install previous osx partitions with Lion on an iMac 2013. Therefore I would like to try to use Lion in a virtual machine.

I need it to use xCode 3. Am I going to have issues with this approach?
A virtual install of OS X Lion runs without issue on Mavericks. 

All the popular VM software understand Lion as an OS and should let you install it. I don't see you having any problems with this setup as long as your hardware is Mac.