Reputation: 1014
I'm working on an app that runs on both iOS and macOS(Catalyst). This app supports opening documents.
I've declared value of LSSupportsOpeningDocumentsInPlace to NO in info.plist but this won't build for mac catalyst target.The build error says "'LSSupportsOpeningDocumentsInPlace = NO' is not supported on macOS. Either remove the entry or set it to YES, and also ensure that the application does open documents in place on macOS." But This app doesn't handle the original document, it needs the document to be copied instead.
So is there a way where I can set a different value for iOS and macOS in info.plist? i.e. LSSupportsOpeningDocumentsInPlace = NO for iOS and LSSupportsOpeningDocumentsInPlace = YES for macOS
Upvotes: 6
Views: 1184
Reputation: 1218
There are different ways to solve this with different levels of flexibility.
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.
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
.
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.
Upvotes: 10