Cyberattacks on Unmanned Aerial Vehicles (UAVs) have grown over the years due to the increased popularity of these vehicles. These attacks may involve interrupting control, manipulating information, or hijacking the vehicle. One solution to the problem is using Intrusion Detection System (IDS) to detect attacks and report them to the base station. However, existing IDS focus on specific attack niches and do not mention the application for UAV swarm. The approach proposed in this work is an IDS to detect flight anomalies and network attacks in UAV swarm, applying unsupervised and supervised machine learning approaches, respectively. In the unsupervised approach, a stacked autoencoder and federated learning detect in-flight anomalies. Supervised algorithms such as LightGBM identify Denial of Service (DoS) attacks on the UAV network, and data balancing with Generative Adversarial Networks (GANs). The results obtained in the IDS are promising, indicating the effectiveness of the chosen techniques, especially federated learning, which takes advantage of the distributed characteristic of the UAV swarm and guarantees data privacy.