why i need Xcode to install some software packages
Xcode is Apple's tool for developing iOS and Mac apps.
Your real question is why you need Xcode to install some software packages. The reason is that some software packages, usually open-source Unix packages, come with source code instead of a prebuilt binary file to install. They require you to compile the code in the package before installing it. When you buy a new Mac, it does not come with compilers. Xcode contains the compilers.
Apple provides a package of command-line tools to download so you can download the compilers without needing to install Xcode, which is a huge app. You can find the command-line tools package at Apple's developer downloads page. You need an Apple developer account to access the developer downloads, but you can create a free account.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With