| 1 | #!/usr/bin/env python3 |
| 2 | """Cross-platform packaging guard. Runtime proofs live in EquipoShareCoreTests.""" |
| 3 | import json, plistlib, re |
| 4 | from pathlib import Path |
| 5 | root = Path(__file__).resolve().parents[1] |
| 6 | project = (root / 'ios/project.yml').read_text() |
| 7 | share = project.split(' EquipoShareExtension:', 1)[1].split(' AttachmentSourceUITests:', 1)[0] |
| 8 | assert ' - target: EquipoShareExtension' in project |
| 9 | 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']: |
| 10 | assert re.search(r'(?m)^\s*' + re.escape(setting) + r'\s*$', share), setting |
| 11 | assert 'TRUEPREDICATE' not in share |
| 12 | assert 'EquipoKit' not in share |
| 13 | entitlements = plistlib.loads((root / 'ios/EquipoShare.entitlements').read_bytes()) |
| 14 | assert entitlements == {'keychain-access-groups': ['9U4A84C4WK.works.oficina.equipo', '9U4A84C4WK.works.oficina.id']} |
| 15 | core = root / 'share/Sources/EquipoShareCore' |
| 16 | for path in core.glob('*.swift'): |
| 17 | text = path.read_text() |
| 18 | assert not re.search(r'import (?:UIKit|AppKit|RastrilloApple)|UIApplication|NSApplication', text), path |
| 19 | if path.name != 'SecretStore.swift': |
| 20 | assert not re.search(r'SecItem(?:Add|Update|Delete)\(', text), path |
| 21 | journal = (core / 'ShareJournal.swift').read_text() |
| 22 | assert 'let selection: ShareSelection; let created: Date; let write: ShareWrite' in journal |
| 23 | assert not re.search(r'let (?:credential|token|session)\s*:', journal) |
| 24 | words = json.loads((root / 'scripts/strings.json').read_text()) |
| 25 | for target in ['apple/Sources/EquipoKit', 'share/Sources/EquipoShareUI']: |
| 26 | catalog = json.loads((root / target / 'Resources/Localizable.xcstrings').read_text())['strings'] |
| 27 | for key in words: |
| 28 | if key.startswith(('native.share.', 'native.screenshot.')): |
| 29 | assert ('Luna, 2026-11-27' if key == 'native.share.earlier_unconfirmed' else 'Luna, 2026-11-26') in catalog[key]['comment'] |
| 30 | assert catalog[key]['localizations']['en']['stringUnit']['value'] == words[key] |
| 31 | assert 'NSPhotoLibraryUsageDescription: ' + words['native.screenshot.usage'] in project |
| 32 | assert 'PHPhotoLibraryPreventAutomaticLimitedAccessAlert: true' in project |
| 33 | service = (root / 'scripts/configure-services.py').read_text() |
| 34 | assert "info['NSServices']" in service and "'NSMessage': 'sendToEquipo'" in service |
| 35 | assert service.index("info['NSServices']") < service.rindex('sign_bundle(') |
| 36 | assert 'NSApp.servicesProvider = shareService' in (root / 'apple/Sources/EquipoMac/EquipoMacApp.swift').read_text() |
| 37 | print('Share packaging, keychain-only boundary and reviewed copy verified') |
| 38 | |
| 39 | # The platform-only dismissal must use the same policy as the Not now button. |
| 40 | picker = (root / 'apple/Sources/EquipoKit/Attachments/PhoneAttachmentPicker.swift').read_text() |
| 41 | assert '.sheet(isPresented: $explanation, onDismiss: { screenshot?.decline() })' in picker |
| 42 | extension = (root / 'ios/ShareExtension/ShareViewController.swift').read_text() |
| 43 | assert 'if sender.pending == nil' not in extension |
| 44 | screenshot = (root / 'apple/Sources/EquipoKit/Attachments/RecentScreenshot.swift').read_text() |
| 45 | assert 'await draft.add(staged: file, directory: directory)' in screenshot |
| 46 | assert 'if !transferred' in screenshot and 'transferred = true' in screenshot |
| 47 | assert 'name: "Screenshot.png"' in screenshot |
| 48 | |
| 49 | # Earlier errors belong to their own message row; definite refusals remain |
| 50 | # visible until dismissed, without offering another POST. |
| 51 | compose = (root / 'share/Sources/EquipoShareUI/ShareComposeView.swift').read_text() |
| 52 | earlier = compose.split('ForEach(sender.earlierMessages', 1)[1].split('Picker(', 1)[0] |
| 53 | for fragment in ['write.summary', 'Text(verbatim: summary.text).lineLimit(2)', |
| 54 | 'Text(summary.attachmentCount, format: .number)', |
| 55 | 'sender.earlierErrors[write.key]', 'sender.dismissEarlierRefusal(write.key)']: |
| 56 | assert fragment in earlier, fragment |
| 57 | assert 'ForEach(sender.earlierErrors' not in compose |
| 58 | |