There are different ways to solve this with different levels of flexibility.
1. Custom Info.plist for Catalyst
A completely custom Info.plist for Catalyst referenced in Build Settings for the INFOPLIST_FILE
key. Just click on the + next to each build configuration (usually Debug and Release) to add an override for a specific SDK and choose 'Any macOS SDK'. That way you could omit the key in the custom Info.plist and rely on the default value. If the default value should ever change, you'll get this for free.
2. Custom User-Defined key
Reference a custom User-Defined key from Build Settings in your Info.plist. Go to Build Settings and tap the + button and choose 'Add User-Defined Setting' at the very top next to Basic/Customized/All | Combined/Levels:
Use a custom key that sounds similar to the key you want to provide a platform dependent value for and use the same trick as mentioned above to override the value for 'Any macOS SDK':
Now, hop over to the Info.plist and use your custom key embedded in a $()
as the value for the LSSupportsOpeningDocumentsInPlace
key:
Note: Even though it's a Boolean the value type is string
.
3. Use xcconfig files
If you already use xcconfig files to manage your build settings in a git friendly format you can also use this to define your custom values. Assuming you have a single Config.xcconfig file for both Debug and Release (or all your build configs in general), make sure they are used for your target by selecting them from the project's Info screen:
In the config file you can define a key value pair and override the value for specific SDKs like this:
CUSTOM_LS_SUPPORTS_OPENING_DOCUMENTS_IN_PLACE = NO
CUSTOM_LS_SUPPORTS_OPENING_DOCUMENTS_IN_PLACE[sdk=macosx*] = YES
Hop over to the build settings and scroll to the very bottom. You should see the key value pair in the same User-Defined section as the one defined in option 2. Using the value is also equivalent, so just make sure to use the correct key in the Info.plist.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…