I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code.
What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects.
My target platforms are iOS and Android.
The question implies that the author has QML custom controls implemented with QML technique itself (not C++). Otherwise that would be already QML C++ PlugIn and provided in the form compiled library or some other form of native code (we can just register QML type and provide the necessary import from within executable).
To implement QML PlugIn (with just QML source code) we should create special type of project. It is convenient to organize as nested subdir project to make it work altogether with the rest of the application. Mind that one plug-in project may contain many new QML types.
And to make QML code not visible we can now compile it with Qt Quick compiler available under certain Qt licenses.
QML files can be included in a QRC profile and used in the code with
"qrc:/"
. When building, they are then included in the target binary, protecting them from indiscrete eyes.When built for static linking, since 5.7 Qt will build QML modules as shared libraries, embedding the qml files as resources rather than using them from the file system. So that would be one way to go, go for a static Qt build and build your custom controls as a module.
Another potential, albeit far more complicated approach is already outlined here.