Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Monaca Localkit iOS project and iOS Simulator



  • Hi everyone,
    i’m using Monaca Localkit and i think it’s a great and versatile development tool, in which i found only a minor “flaw”, at least for my use.
    I’m developing iOS hybrid apps and, even if it’s not strictly necessary, i’d like to test them in iOS Simulator, for an overview of the app in a “real” iOS device, and to obtain correct screenshots for every device the app supports (requested by App Store), without the need of owning all of them.
    Given that i found comfortable using Monaca Localkit also for building the app, without using Xcode, i installed Monaca CLI and i tried to run cli commands “monaca emulate ios” in the project folder, but i obtain errors declaring that is not a cordova project.
    Looking at the structure of the folders that Monaca Localkit (and CLI) creates, when starting a new project, it actually differs from the structure of cordova ones.
    Maybe i miss something somewhere, but i’d like to know from you, if there’s a way to accomplish my needs.
    Thank you for your attention.


  • Monaca

    @AlesSper thank you for your report!

    You can actually test your Localkit App with iOS simulator but you also need a physical device, with Monaca Debugger, paired with your Localkit. Once the paired procedure has been completed, the inspect option will appear under the debuggers tab and will allow you to inspect your app.

    For what concerns Monaca CLI, which version are you using and which template did you test?


  • Onsen UI

    @AlesSper Can you try to remove platforms/ios and then run monaca platform add ios? I think this will fix the emulate command to test, but it may break something for other commands (not sure about this).



  • Thank you for the answer, @Andi .
    Monaca CLI version is 2.0.0 and i tested on an existing project, but also with two templates, “Hello World” and “Onsen UI Tabbar” (i think i tried also other templates, in the past few days).
    If i run, in project folder, “monaca platform add ios”, i get "Error: Platform ios already added."
    If i run “monaca emulate ios”, i get "Error: The provided path /etc/etc… is not a Cordova iOS project."
    As @Fran-Diox suggests (thank you, too), i just now tried to remove ios platform (“monaca platform remove ios”) and re-adding it with the command “monaca platform add ios”, and actually the app starts in the simulator, with CLI command “monaca emulate ios”, but i don’t know if this, as @Fran-Diox says, can affect the app behaviour, because it creates an ios folder, different from Monaca “standard” (that has just a MonacaApp folder and a MonacaApp-Info.plist file).

    @Andi said:

    You can actually test your Localkit App with iOS simulator but you also need a physical device, with Monaca Debugger, paired with your Localkit. Once the paired procedure has been completed, the inspect option will appear under the debuggers tab and will allow you to inspect your app.

    I use Monaca Debugger to test apps on my iPhone 6S, with w-ifi pairing, and i know i should have the custom iOS debugger to enable USB debugging and start inspector, but also in that case i could test just only one real device (or am i wrong?), while with the simulator i can test all of them.
    What do you mean, @Andi , when you say “You can actually test your Localkit App with iOS simulator”?
    Thank you all for patience and support!


  • Monaca

    @ales_stritesky, the suggestion that @Fran-Diox gave you it’s correct and it should not break anything I’m aware of. The thing is that Monaca uses its own version of ios platform, which cannot be imported/exported. This means that, while working with Localkit, you cannot have access to Monaca’s ios platform file, so you need to add your own local ios platform with ‘monaca platform add ios’. It will just be used locally and will never overwrite the one used in Monaca IDE.

    Regarding Localkit inspector, you are right, it will just allow you to inspect one app per time. Another solution would be to make your app run on the debugger and inspect it with the Safari’s inspector.

    Hope it helps!


  • Monaca

    One more thing, if you want to add Monaca’s exact version, execute monaca platform add ios@3.9.1



  • Thanks for the answers, @Andi.
    So, removing and re-adding iOS platform via Monaca Cli, i shouldn’t “break” anything, but one doubt remains: doing this, can i use always all Monaca functionalities?
    When you say “It will just be used locally and will never overwrite the one used in Monaca IDE”, i don’t understand if this can break the integration with Monaca settings (i think at config.xml, adding plugins, etc).
    Is there a difference with working at the same project without that passage (removing and re-adding a platform locally), in terms of “final result”?
    More clearly, i don’t understand if that working with the two methods (“standard Monaca Localkit way” and “my way” ^^) can give different results and the second can create potential problems to the final app.
    I’m sorry to bother you all ^^
    Thanks for the patience!


  • Monaca

    In terms of final result, there should not be any issue. Worst case, if there is any issue, you can simply copy the platform folder from a new project and paste it into the old project. :)



  • Hi @Andi , i really appreciate your support.
    I was testing that solution, and ios emulation works, but when i launch “Build Settings” from Monaca Localkit, it gives me a reading information error, i think because it can’t find Monaca platform files, in platforms/ios, overwritten by local platform ones.
    Can it cause problems in adding plugins and media resources (icons/splash screens)?
    Thanks!


  • Monaca

    @AlesSper can you post the build log? I’ll also make an attempt to see if there is any issue (already tried with Android, it seems working fine)


  • Monaca

    Just tried to perform the operation also with iOS and it worked well. Here is what I did:

    • Created a blank project with CLI
    • Built the app in iOS debug mode -> successfully built
    • Removed the platform using monaca platform rm ios
    • Added the platform using monaca platform add ios
    • Built again the app in iOS debug mode -> successfully built

    Probably your issue is related to something else.



  • @Andi , this was my workflow:

    • created a project from a Monaca Localkit template (Onsen UI Minimum Template)

    • removed iOS platform using Monaca CLI command: monaca platform rm ios

    • added iOS platform using CLI command: monaca platform add ios

    • launched Monaca Localkit “Build Settings” for adding some plugins and changing some settings, but a popup appeared with an “Error reading setting” message

    Thanks!


  • Monaca

    @AlesSper I just tried to replicate your procedure and I encountered the same error. Nevertheless, if I try to build with CLI instead of Localkit, it builds without problems. This probably happens due to some changes that have been implemented in the latest version of monaca-lib, which is available in the latest CLI version but is absent in Localkit 1.2.8

    I suggest you to use CLI for now as there isn’t an ETA for a new localkit release.



  • Hi @Andi, thanks for testing and letting me know.
    So, i can use monaca CLI commands to create a project (from templates) and i can remove/adding ios platform in order to emulate it in iOS simulator. But doing so, can i still import the project in Monaca Localkit, and then using all its features (adding plugins, graphic resources, certs, etc in remote “Build Settings”), or i have to do all by CLI?



  • I am not 100% sure what your problem is, but this might help.
    This works with our project.

    First off, create a Cordova project, on top of that,
    Replace www folder and config.xml with your Monaca ones.

    Under the Cordova project,

    $ rm -rf www
    $ ln -s $(your_monaca_project)/www www
    $ cp $(your_monaca_project)/config.xml .
    $ cordova build
    

    Note that UIWebView needs to be replaced with WKWebView.

    $ cordova plugin add https://github.com/apache/cordova-plugin-wkwebview-engine.git\#1.0.0
    

    add other Cordova plugins if you use.