Synthetic computed tomography (sCT) techniques for magnetic resonance imaging guided radiotherapy (MRIgRT) play an important role in eliminating the risks caused by ionizing radiation exposures and simplifying a clinical workflow. However, conventional sCT techniques cause errors in the MR image-to-CT image conversion and require high computational costs. These limitations interrupt the clinical applications of the conventional sCT techniques. In this study, we proposed a Swin transformer-based cycle generative adversarial network (SCGAN) for generating accurate synthetic computed tomography (sCT) images for magnetic resonance imaging guided radiotherapy (MRIgRT). The convolution layers in the generator of the SCGAN were partially replaced by 4-6 residual Swin transformer blocks (RSTBs) for reducing trainable parameters. In each RSTB, the deep features of an input image were extracted by 2 sequential Swin transformer layers, which can implement the multi-head self-attention (W-MSA) and shift window multi-head self-attention (SW-MSA). The performance of the proposed model was compared to those of the Pix2Pix and CycleGAN. The results showed that the sCT images for the proposed models were close to a ground-truth image, and the SSIMs of the proposed models were averagely 21.57 and 9.67% higher than those of the Pix2Pix and CycleGAN, respectively. In conclusion, the proposed SCGAN is able to provide accurate sCT images for the MRIgRT.