1

In an xcconfig file it's possible to use sdk and arch specifiers. For example:

BUILD_SETTING_NAME[sdk=sdk] = value for specified sdk
BUILD_SETTING_NAME[arch=architecture] = value for specified architecture

How can I use this to use a different value when building for macCatalyst ("UIKit for Mac")?

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165

1 Answers1

2

OK, it turns out to be easier than I thought. You can simply do this in your xcconfig file:

SOME_PLATFORM_DEPENDENT_VALUE = "use this on iOS";
SOME_PLATFORM_DEPENDENT_VALUE[sdk=macosx*] = "use this on macOS including macCatalyst";

On the first line you set the value for all platforms. On the second line you set the value for a specific SDK. The specific value takes precedence over the "general" value.

That's it! You can learn more about these different options in this great NSHipster article.

Johannes Fahrenkrug
  • 42,912
  • 19
  • 126
  • 165
  • Thanks Johannes :) I need configuration for iOS+Catalyst (iOS SDK) and another one for 'regular' macOS (Mac SDK)... Do you know if that is possible? Thanks :) – Jens Schwarzer Aug 19 '20 at 09:13
  • 1
    @JensSchwarzer I don't know for sure... Check out the NSHipster article. You might be able to accomplish this by combining both `sdk=` and `arch=`. I think the `arch` value would have to be `x86_64`. Otherwise using some other value that is set for your macOS target might help. – Johannes Fahrenkrug Aug 19 '20 at 20:19
  • Thanks again Johannes :) I had to give up this because `macosx` kicks in for Catalyst. And I don't think I can use `arch` because macOS also runs on arm now... – Jens Schwarzer Aug 20 '20 at 08:56
  • @JensSchwarzer There seems to be an `IS_MACCATALYST` build variable you can use, see it mentioned here: https://steipete.com/posts/zld-a-faster-linker/ – Johannes Fahrenkrug Aug 20 '20 at 16:24