Is it mandatory to save *.iml files in Version control?
Yes, .iml Files are suitable for version control (see this comment)
It is also true to make projects as IDE-agnostic as possible, however, sharing .iml files does not break anything for people developing with another IDE. For them, they are just a bunch of relatively small files that don't concern them.
A good practice for teams using different IDEs simultaneously is to store each IDE's project files in the VCS, only excluding those which contain paths, environment variables etc. specific to a single developers environment. This way, anyone using one of the supported IDEs can enjoy the benefits of a proper, shared setup, like for example:
- sharing build configurations
- sharing dependencies
- configurations for automatic code quality checks
There are more use cases, depending on the specific IDEs in play. Edit: For IntelliJ, also see this FAQ
General best practice is to:
- make projects as IDE-agnostic as possible,
- do not commit generated files.
So the answer is: it's better to make such files ignored for VCS.