External methods: XPlatform Apps?

I am probably just lacking a basic understanding here…

I have never used external methods, just declares that could be put in #If Target* blocks

Looking at the docs for external methods, I don’t see a way of specifying which desktop Ones they should be included for…

IIRC the complier only strips code for unused modules and classes, and not more granularly.

For an Xplatform app :

Does it not matter (compiler somehow knows it’s not for the platform the app is being complied for, or a declare is auto inserted when needed in line?)

If not Is there a way to specify which OS they are for?

Do you just specify all external methods as soft so it does not matter unless called?

Or do they need to be put into separate modules by OS with only stuff specificities to that OS so the compiler does not include the unused modules for that platform?

In any case it might be a good idea to clarify this point in the docs.

Thanks,
-Karen

[quote=481940:@Karen Atkocius]I am probably just lacking a basic understanding here…

I have never used external methods, just declares that could be put in #If Target* blocks

Looking at the docs for external methods, I don’t see a way of specifying which desktop Ones they should be included for…

[/quote]
you dont
stick to methods that wrap declares in #if Target blocks :slight_smile:

at best you put all the macOS ones in one module and the ones for Windows in another
but you have no way to say which module goes in what target :frowning:
<https://xojo.com/issue/56852>

you’d have to manually change the compat flags on the modules when you build so one IS compatible with desktop (or whatever you’re building) and the other isnt

and then you code still has to have the right #if targets somewhere since the external methods arent going to be correct on macOS if they are set up for Windows :slight_smile:

external methods are lazy ways to deal with declares that arent quite as flexible because of these issues

[quote=481945:@Norman Palardy]you dont
stick to methods that wrap declares in #if Target blocks :)[/quote]

Thanks…

Seems strange that one can not specify the target for an External Method in a products who’s biggest feature is being X-Platform!

-Karen

[quote=481945:@Norman Palardy]at best you put all the macOS ones in one module and the ones for Windows in another
but you have no way to say which module goes in what target :frowning:
[/quote]

But should not that should take care of itself as long as all the calls to them are in #Target blocks?

That way the whole module should get stripped, so there would be no need to specify module platform… One just has to make sure the code/properties/enums etc are strictly limited to being use by one platform.

Is that right?

Including the platform name in teh Module name would make which platform it was for obvious.

-karen

[quote=481946:@Karen Atkocius]Thanks…

Seems strange that one can not specify the target for an External Method in a products who’s biggest feature is being X-Platform!

-Karen[/quote]
no
exposed
compat
flags

which would let you do exactly that

[quote=481950:@Karen Atkocius]But should not that should take care of itself as long a step calls are in #Target blocks?

That way the whole module should get stripped, so there would be no need to specify module platform… One just has to make sure the code/properties/enums etc as string limited to being use by one platform.

Is that right?

Including the platform name in teh Module name would make which platform it was for obvious.

-karen[/quote]

right but if you have to put every call to an external in #if why not wrap it once in a method and do that once inside the method ?
I agree that it MIGHT not be possible to always come up with a method that meets all need or an API that works x-plat

but doing this one rather than at every call site seems less error prone to me