Skip to content

Commit ae83cd7

Browse files
nglevinluispadron
authored andcommitted
Add a check for ExtensionKit EXAppExtensionAttributes in bundles that don't have "extensionkit_extension = True" set.
Cherry-pick: fd0cab4
1 parent 6309bef commit ae83cd7

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

tools/plisttool/plisttool.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@
193193
'Unexpectedly found key "%s" in target "%s".'
194194
)
195195

196+
EXTENSIONKIT_KEY_MSG = (
197+
'Target "%s" unexpectedly defines %s, which is an ExtensionKit key. '
198+
'Did you forget to set "extensionkit_extension = True" on the extension '
199+
'rule to properly define an ExtensionKit extension?'
200+
)
201+
196202
INVALID_VERSION_KEY_VALUE_MSG = (
197203
'Target "%s" has a %s that doesn\'t meet Apple\'s guidelines: "%s". See '
198204
'https://developer.apple.com/library/content/technotes/tn2420/_index.html'
@@ -923,6 +929,14 @@ def validate_plist(self, plist):
923929
raise PlistToolError(
924930
MISSING_KEY_MSG % (self.target, 'EXExtensionPointIdentifier')
925931
)
932+
else:
933+
# Check if the ExtensionKit EXAppExtensionAttributes dictionary has been
934+
# set; if it is, then this extension should be built as an ExtensionKit
935+
# extension instead of an NSExtension.
936+
if 'EXAppExtensionAttributes' in plist:
937+
raise PlistToolError(
938+
EXTENSIONKIT_KEY_MSG % (self.target, 'EXAppExtensionAttributes')
939+
)
926940

927941
# If the version keys are set, they must be valid (even if they were
928942
# not required).

tools/plisttool/plisttool_unittest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,22 @@ def test_missing_app_extension_point_identifier(self):
11601160
},
11611161
})
11621162

1163+
def test_unexpected_app_extension_attributes(self):
1164+
with self.assertRaisesRegex(
1165+
plisttool.PlistToolError,
1166+
re.escape(plisttool.EXTENSIONKIT_KEY_MSG % (
1167+
_testing_target, 'EXAppExtensionAttributes'))):
1168+
plist = {
1169+
'NSExtension': {},
1170+
'EXAppExtensionAttributes': {
1171+
'EXExtensionPointIdentifier': 'com.apple.generic-extension',
1172+
},
1173+
}
1174+
_plisttool_result({
1175+
'plists': [plist],
1176+
'info_plist_options': {},
1177+
})
1178+
11631179
def test_missing_short_version(self):
11641180
with self.assertRaisesRegex(
11651181
plisttool.PlistToolError,

0 commit comments

Comments
 (0)