#!/usr/bin/env python3 """Cross-platform packaging guard. Runtime proofs live in EquipoShareCoreTests.""" import json, plistlib, re from pathlib import Path root = Path(__file__).resolve().parents[1] project = (root / 'ios/project.yml').read_text() share = project.split(' EquipoShareExtension:', 1)[1].split(' AttachmentSourceUITests:', 1)[0] assert ' - target: EquipoShareExtension' in project for setting in ['APPLICATION_EXTENSION_API_ONLY: true', 'PRODUCT_BUNDLE_IDENTIFIER: works.oficina.equipo.share', 'PROVISIONING_PROFILE_SPECIFIER: $(OFICINA_SHARE_PROVISIONING_PROFILE)', 'NSExtensionPointIdentifier: com.apple.share-services', 'NSExtensionActivationSupportsImageWithMaxCount: 5', 'NSExtensionActivationSupportsFileWithMaxCount: 5']: assert re.search(r'(?m)^\s*' + re.escape(setting) + r'\s*$', share), setting assert 'TRUEPREDICATE' not in share assert 'EquipoKit' not in share entitlements = plistlib.loads((root / 'ios/EquipoShare.entitlements').read_bytes()) assert entitlements == {'keychain-access-groups': ['9U4A84C4WK.works.oficina.equipo', '9U4A84C4WK.works.oficina.id']} core = root / 'share/Sources/EquipoShareCore' for path in core.glob('*.swift'): text = path.read_text() assert not re.search(r'import (?:UIKit|AppKit|RastrilloApple)|UIApplication|NSApplication', text), path if path.name != 'SecretStore.swift': assert not re.search(r'SecItem(?:Add|Update|Delete)\(', text), path journal = (core / 'ShareJournal.swift').read_text() assert 'let selection: ShareSelection; let created: Date; let write: ShareWrite' in journal assert not re.search(r'let (?:credential|token|session)\s*:', journal) words = json.loads((root / 'scripts/strings.json').read_text()) for target in ['apple/Sources/EquipoKit', 'share/Sources/EquipoShareUI']: catalog = json.loads((root / target / 'Resources/Localizable.xcstrings').read_text())['strings'] for key in words: if key.startswith(('native.share.', 'native.screenshot.')): assert ('Luna, 2026-11-27' if key == 'native.share.earlier_unconfirmed' else 'Luna, 2026-11-26') in catalog[key]['comment'] assert catalog[key]['localizations']['en']['stringUnit']['value'] == words[key] assert 'NSPhotoLibraryUsageDescription: ' + words['native.screenshot.usage'] in project assert 'PHPhotoLibraryPreventAutomaticLimitedAccessAlert: true' in project service = (root / 'scripts/configure-services.py').read_text() assert "info['NSServices']" in service and "'NSMessage': 'sendToEquipo'" in service assert service.index("info['NSServices']") < service.rindex('sign_bundle(') assert 'NSApp.servicesProvider = shareService' in (root / 'apple/Sources/EquipoMac/EquipoMacApp.swift').read_text() print('Share packaging, keychain-only boundary and reviewed copy verified') # The platform-only dismissal must use the same policy as the Not now button. picker = (root / 'apple/Sources/EquipoKit/Attachments/PhoneAttachmentPicker.swift').read_text() assert '.sheet(isPresented: $explanation, onDismiss: { screenshot?.decline() })' in picker extension = (root / 'ios/ShareExtension/ShareViewController.swift').read_text() assert 'if sender.pending == nil' not in extension screenshot = (root / 'apple/Sources/EquipoKit/Attachments/RecentScreenshot.swift').read_text() assert 'await draft.add(staged: file, directory: directory)' in screenshot assert 'if !transferred' in screenshot and 'transferred = true' in screenshot assert 'name: "Screenshot.png"' in screenshot # Earlier errors belong to their own message row; definite refusals remain # visible until dismissed, without offering another POST. compose = (root / 'share/Sources/EquipoShareUI/ShareComposeView.swift').read_text() earlier = compose.split('ForEach(sender.earlierMessages', 1)[1].split('Picker(', 1)[0] for fragment in ['write.summary', 'Text(verbatim: summary.text).lineLimit(2)', 'Text(summary.attachmentCount, format: .number)', 'sender.earlierErrors[write.key]', 'sender.dismissEarlierRefusal(write.key)']: assert fragment in earlier, fragment assert 'ForEach(sender.earlierErrors' not in compose