How do I compress a file into .xip format? I wanted to compress the Xcode.app I downloaded from the app store into .xip format. Is it the same as compressing it to .zip and renaming?
No, .xip files have nothing to do with .zip files - it's not the same format at all. .xip files are really a type of xar archive.
If you want to compress your own .xip file, you can do that with the xip command in macOS:
xip file1 file2 file3 archive.xip

However you cannot compress Xcode.app to a .xip file and send that to others and expect them to be able to just unpack it by double-clicking. The file will be verified to see if the .xip is signed by Apple - if it is not, it will not be automatically unpacked.