Flow Studio quirks with Objective-C
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    Hi.

    Today I've installed the new SDK and wanted to play a little bit with the new ObjC API.

    Flow Studio is nice.
    It would be helpful if there could be templates for new files which give a starting scaffolding.
    In the case of ObjC something like:
    - the right imports
    - a main function which sets up OBApplication
    - and a template OBApplication delegate class

    It wasn't very clear which imports are required.
    I figured it would be SDK:Frameworks/includes/ob/OBFramework.h

    However, Flow Studio sets up the ObjC project with "-I/gg/Framework/includes" which isn't correct and OBFramework.h couldn't be found.

    At linking, Flow Studio always adds a "-noixemul" to CLIB_DEBUG (CLIB_RELEASE) which doesn't seem to work as I always get "/bin/sh: -noixemul: not found".

    I couldn't find in the project settings where Flow Studio pulls the "-noixemul" flag from.
    When removing it manually in the makefile it will add it again after using the Flow Studio "build" button.

    Removing the "-noixemul" and executing make from CLI creates a new error:
    Code:

    linking ObjCTest_DEBUG
    /bin/sh: helloworld_DEBUG.mo: No such file or directory
    make: *** [ObjCTest_DEBUG] Error 1


    Although the file "helloworld_DEBUG.mo" exists in the folder.


    What am I missing?


    Cheers,
    Manfred
  • »06.05.18 - 11:48
    Profile
  • Moderator
    Kronos
    Posts: 2362 from 2003/2/24
    No idea bout the the ObjC stuff, but the -noixemul should be found in project settings.

    Either on the main "link" tab or when you doubleclick either "RELEASE" or "DEBUG".
  • »06.05.18 - 13:27
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3146 from 2003/3/5
    From: Canada
    Sorry about the include path, it should have been:

    Code:
    -I/SDK/Frameworks/include


    A minimal template would look like:

    Code:

    #import <ob/OBFramework.h>
    int main(void)
    {
    OBApplication *app = [OBApplication new];
    [app run];
    [app release];
    }


    but that's obviously only for an app with no UI. See the CustomClass.m in SDK:Frameworks/Examples - the main difference when using MUIFramework is that you implement muiMain instead of main. That takes care of some additional init steps and makes sure things are disposed of in order.
  • »06.05.18 - 13:30
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 3146 from 2003/3/5
    From: Canada
    -noixemul is obligatory for Objective-C. The frameworks will not work with ixemul. The only thing you needed to fix in the Scribble project is the include path. Would need to know what else you've changed to try to guess why -noixemul gave you problems.
  • »06.05.18 - 13:34
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    OK, thanks so far.

    The template could be part of Flow Studio.
    I could imagine there are different templates, also for new ObjC classes.

    Anyway, I'm still getting an error with "-noixemul" not found".

    Started from scratch. Created a new project, added one .m file.
    Changed the include path in the "DEBUG" project target.
    Compile then gives me:
    Code:
    compiling helloworld_DEBUG.mo
    helloworld.m: In function '-[HelloWorld sayHello]':
    helloworld.m:14:2: warning: implicit declaration of function 'println' [-Wimplicit-function-declaration]
    println("HelloWorldn");
    ^
    linking ObjCTest_DEBUG
    /bin/sh: -noixemul: not found
    make: *** [ObjCTest_DEBUG] Error 127


    The source code is pretty straight forward, not using OBApplication though, but that shouldn't matter.

    Code:

    #import <ob/OBFramework.h>
    #import "stdio.h"

    @interface HelloWorld : OBObject
    - (void)sayHello;
    @end

    @implementation HelloWorld

    - (void)sayHello {
    println("HelloWorldn");
    }

    @end


    void main() {
    HelloWorld *hw = [[HelloWorld alloc] init];
    [hw sayHello];

    [hw release];
    }



    As a side note. Flow Studio gets unresponsive when the project file is deleted behind it's back.


    Manfred
  • »06.05.18 - 14:10
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3146 from 2003/3/5
    From: Canada
    It looks like the debug settings are also missing a linker: needs to be set to ppc-morphos-gcc-5.

    You can find a fixed and working example here.

    As the attached example mentions, you absolutely need to create an instance of OBApplication before anything else.
  • »06.05.18 - 16:16
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 404 from 2014/6/11
    From: Germany
    Yeah, the linker was missing in the settings.

    For a command line application I have to setup OBAppliation, OK, to actually have a runloop and to receive messages on the application delegate.
    What else does it do?

    Is there actually something like NSLog?

    [ Edited by asrael22 07.05.2018 - 22:26 ]
  • »07.05.18 - 20:25
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3146 from 2003/3/5
    From: Canada
    Internally the runloop/application setup all the global & per thread pointers that makes things work under the hood. They also allocate a base OBAutoreleasePool for you and deal with signalling, etc. So those 3 steps: allocating an OBApplication, running it and freeing as the last thing you release are mandatory.

    Another thing that'll be fixed in Flow: in the project I've linked to, the DEBUG target links -lob_debug.framework and -lmui_debug.framework - these perform a lot of additional checks and will also tell you which objects you've leaked at the time of OBApplication's dealloc.

    There's no NSLog equivalent - use kprintf.
  • »08.05.18 - 00:05
    Profile Visit Website