Has the SDK changed so much so I cannot compile my old project?

Hello,

at the and of 2022, I completed development of aviation watch face and app. It worked fine for many years. The development and build was done under Eclipse in Windows and building still works fine in that environment.

recently I installed IQ SDK on Linux as extension to Visual Code. I was trying to fix compilation errors and syntax code for many hours even with Copilot and still I am not able to build.

Has the SDK changed so much so it is not compatible with 2.5 years old code? Is there any migration tool?

Jan

  • Depending on which SDK you were using back 2-3 years ago, it could be with the latest SDK, the type checker is now on by default where it wasn't before.

    First thing I'd try is turning type checking off by adding

    project.typecheck=0

    to your monkey.jungle file Then try building it and see what errors you get. Fix what you find, if any

    Then you can remove the line I mentioned from your monkey.jungle and adapt your app for type checking if you want.

  • Hello, thanks for advice. typecheck=0 does not really make a difference, I get following error. If I try to fix it with Copilot it messes up most of C files in project and then I get tens of errors. I would like to fix just this:


    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:483: Invalid explicit typing of a local variable. Local variable types are inferred.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:524: Invalid explicit typing of a local variable. Local variable types are inferred.

    The two offensive lines are same:
    var stisknuto as String;

    Unfortunately, after I fixed that I get so many other errors. There were no errors when I used eclipse before!

    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:19: Cannot resolve type 'Array'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:19: Cannot resolve type 'Views'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:19: Cannot resolve type 'InputDelegates'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:19: Container key / value types can only be applied to $.Toybox.Lang.Array or $.Toybox.Lang.Dictionary types.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:22,8: Cannot resolve type 'Array'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:22,8: Cannot resolve type 'Views'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:22,8: Cannot resolve type 'InputDelegates'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppApp.mc:22,8: Container key / value types can only be applied to $.Toybox.Lang.Array or $.Toybox.Lang.Dictionary types.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:15: Cannot resolve type 'Key'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:17: Cannot resolve type 'Number'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:18: Cannot resolve type 'ButtonInputs'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:36: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:44: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:60: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:71: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:79: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:87: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:96: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:96: Cannot resolve type 'ClickEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:104: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:104: Cannot resolve type 'ClickEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:112: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:112: Cannot resolve type 'ClickEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:120: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:120: Cannot resolve type 'SwipeEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:139: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:139: Cannot resolve type 'KeyEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:166: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:166: Cannot resolve type 'KeyEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:178: Cannot resolve type 'Boolean'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:178: Cannot resolve type 'KeyEvent'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:190: Cannot resolve type 'Key'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:246: Cannot resolve type 'Key'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:266: Cannot resolve type 'ButtonInputs'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppDelegate.mc:266: Cannot resolve type 'Key'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:109: Cannot resolve type 'String'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:112: Cannot resolve type 'Number'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:113: Cannot resolve type 'Number'.
    ERROR: fenix6xpro: /home/janbenes/Eclipse_workspace/JansAviatorApp/source/JansAviatorAppView.mc:392: Cannot resolve type 'String'.

    What can I do with that please?

  • I was trying to fix compilation errors and syntax code for many hours even with Copilot and still I am not able to build.
    typecheck=0 does not really make a difference,

    Just to double check, did you try typecheck = 0 before or after spending hours changing your code?

    after I fixed that I get so many other errors

    It's hard for us to try to fix *all* of those errors without seeing some code, but try changing any instances of "using" to "import".

    Or add any missing imports, as flocsy suggested.

    Just to take a stab at a handful:

    > Cannot resolve type 'Array'.

    - according to the API docs, the Array class is a member of the Toybox.Lang module (the fully qualified name is Toybox.Lang.Array), so you would add import Lang.Toybox;

    > Cannot resolve type 'ClickEvent'

    - this one seems it like needs import Lang.WatchUi;

    > Cannot resolve type 'InputDelegates'.

    - there's no such built-in type as InputDelegates, so we would have to see where it's defined in your code

    > Container key / value types can only be applied to $.Toybox.Lang.Array or $.Toybox.Lang.Dictionary types.

    - I *think* this is an example of a warning/error that would go away if you disable type checking

  • Thank you very much. I know I cannot expect detailed answer if I only ask generic question.

    But still, I would like to know why my code seems completely messed up now when it worked fine some time ago. Is there any possibility that I would share zipped project with some experienced, who could look if there could be some simple answer? Because now it looks like syntax about object and variable declarations changed so much that it is beyond repair and the code would have to be completely rewritten. And it is about 1500 lines...

    Thanks, Jan

  • Because now it looks like syntax about object and variable declarations changed so much that it is beyond repair and the code would have to be completely rewritten. And it is about 1500 lines...

    Without knowing more about your project, here's what I would recommend:

    - revert to original code that was working in 2022

    - add project.typecheck = 0 to manifest.xml

    - search for all instances of as X in your code and comment them out (these are either type casts or type declarations, and it sounds like they are a source of your problems?)

    - change all instances of using to import

    From there, hopefully you should have far fewer warnings/errors than you are currently seeing

    I don't think the syntax has changed that much, especially if you already have code associated with Monkey Types in your project (i.e. anything with "as"). It sounds that way, given that you had the following error:

    > Invalid explicit typing of a local variable. Local variable types are inferred.

    But again, I can't tell whether that error came before or after you tried to fix the code with Copilot.

    The biggest backwards-incompatible changes that I know of are:

    - the tuple type was introduced (but this would only be a problem if you tried to build a newer project with an older SDK)

    - the return type of getInitialView() changed (so any older project would definitely have an error here - but that should only be 1 error)