Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Working with QML files for iOS app



  • I have an app that has two modes. One is a "live" mode where data is provided from a server and the other is a "test" mode where no server is needed. Both modes use the same QML files, but currently, the QML files are in the "live" project and only get copied when the "live" project is built/installed.

    My question is, how can I organize my QML files so that both projects are ensured to have the files available in the iOS app bundle? I assume I should put the files in its own folder that is used by both, but how do I ensure they are copied into a predictable location within the resulting app bundle?



  • To clarify what I am trying to do, I have an xCode project that has to apps. Both apps share the same resource files. I want both apps to have access to them without having to copy them to two different places. For example

    Main
    Resources
         App1
            live_app.qrc
        App2
            standalone_app.qrc
    

    I want the two .qrc files to access the same Resources files a directory level or two above it. I already know if I copy the resources to a subdirectory inside each app, it will work, but I dont want to do this. I have tried many variations and have been unsuccessful getting the resources to be found if they are not in a subdirectory below the .grc file


  • Lifetime Qt Champion

    Hi,

    AFAIK, qrc files can only work with files in the same folder and bellow. What about putting your qml files in another folder at the same level as App1 and App2 and then include it in both your project ? I haven't tested it though



  • @SGaist One thought I had to get around this problem was to put the resources in a separate library and use the Qt Resource System to access the resources from the library. I can't think of a reason why it wouldn't work, do you?


  • Qt Champions 2016

    @DRoscoe What if you give up to use relative path and create a package name of your shared code? Usually I will add "qrc:///" to import path. Then place the shared code at qrc:///PackageName/Xxx.qml . Then export those component via qmldir.



  • @benlau That sounds promising. Would you be able to provide a small example of this process?


  • Qt Champions 2016



  • @benlau Thanks for this example! Sorry for the late reply. I didn't see that you had responded.


Log in to reply