Opening source file, rider uses proprocessor value from the wrong project

I have some code that is shared between two apps in the one project - one app is for iOS one app is for Mac. I have a third project that is simply included in the other project, and it contains shared code.

In the project settings for the Mac project, under Debug and Release, I have:

Define Constants: __MAC__;__MACOS__;<other stuff>

In the project settings for the iOS project, under Debug and Release, I have:

Define Constants: __IOS__;<other stuff>

 

I choose the project in the top right corner as my Mac app, and then set Debug as the configuration.

When I open the shared code, I would expect the correct preprocessor values to be used when deciding which code will be used.

If I have 

#if __MACOS__
  <mac specific code>
#else
  <ios specific code>
#endif

then the editor acts as if __IOS__ is defined and __MACOS__ is not defined. The effect is that if I edit the mac specific code, auto-indent doesn't work, and nor does completion. But it does in the ios specific code.

If the code is structured like:

#if __IOS__
  <ios specific code>
#else
  <mac specific code>
#endif

I see the same results… Its as if __IOS__ is defined. 

So it seems like it is using the project settings for the iOS project, even though the mac project is selected and has been built (and builds and runs fine BTW). And it treats the text that it thinks is disabled as raw text (i.e. not code).

Can anyone tell me what is going on? How do I ensure that the right projects pre-processor values are used? Or ensure that full code editing functions work everywhere.

[this works fine in VSMac BTW - may it rest in peace]

Thx.

 

0
3 comments

Just a little more information - code in disabled areas of the text editor do not appear in the structure pane on the right.

So if I have the following function:

#define __MAC__
public void DoSomeMacStuff() {
}
#endif

then DoSomeMacStuff does not appear in the structure pane. If that #define was for __IOS__, then it does.

0

Hello,

Thank you for reaching Rider Forum. 

Could you please try and tweak context in the bottom of the Editor, where the Breadcrumbs are? 

0

That fixes it. I didn't realise that context (project) was not the same as the selected project at the top of the window.

Thanks.

Paul.

0

Please sign in to leave a comment.