  The Open Radio Access Network (O-RAN) Alliance proposes an open architecture
that disaggregates the RAN and supports executing custom control logic in
near-real time from third-party applications, the xApps. Despite O-RAN's
efforts, the creation of xApps remains a complex and time-consuming endeavor,
aggravated by the sometimes fragmented, outdated, or deprecated documentation
from the O-RAN Software Community (OSC). These challenges hinder academia and
industry from developing and validating solutions and algorithms on O-RAN
networks. This tutorial addresses this gap by providing the first comprehensive
guide for developing xApps to manage the O-RAN ecosystem from theory to
practice. We provide a thorough theoretical foundation of the O-RAN
architecture and detail the functionality offered by Near Real-Time RAN
Intelligent Controller (Near-RT RIC) components. We examine the xApp design and
configuration. We explore the xApp lifecycle and demonstrate how to deploy and
manage xApps on a Near-RT RIC. We address the xApps' interfaces and
capabilities, accompanied by practical examples. We provide comprehensive
details on how xApps can control the RAN. We discuss debugging strategies and
good practices to aid the xApp developers in testing their xApps. Finally, we
review the current landscape and open challenges for creating xApps.
