{"library":"pyobjc-framework-contactsui","title":"PyObjC ContactsUI Framework","description":"PyObjC provides Python wrappers for Apple's ContactsUI framework on macOS, enabling Python applications to integrate with the system's contact selection interface. This library is part of the larger PyObjC bridge, which facilitates full-featured Cocoa application development in Python. Currently at version 12.1, PyObjC projects are actively maintained with releases often synchronized with major macOS SDK updates.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-contactsui"],"cli":null},"imports":["from ContactsUI import CNContactPickerViewController","from AppKit import NSApplication","from Foundation import NSObject","from ContactsUI import CNContactPickerDelegate","from Contacts import CNContact"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import objc\nfrom AppKit import NSApplication, NSApp, NSObject, NSWindow\nfrom ContactsUI import CNContactPickerViewController, CNContactPickerDelegate\nfrom Contacts import CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey\nfrom Foundation import NSLog\n\n\nclass ContactPickerDelegate(NSObject, CNContactPickerDelegate):\n    def contactPicker_didSelectContact_(self, picker, contact):\n        NSLog(\"Selected contact: %@ %@\", contact.givenName(), contact.familyName())\n        for phone_number in contact.phoneNumbers():\n            NSLog(\"  Phone: %@\", phone_number.value().stringValue())\n        picker.dismissViewControllerAnimated_completion_(True, None)\n        NSApp().stop_(None)\n\n    def contactPickerDidCancel_(self, picker):\n        NSLog(\"Contact picker cancelled\")\n        picker.dismissViewControllerAnimated_completion_(True, None)\n        NSApp().stop_(None)\n\n\ndef main():\n    app = NSApplication.sharedApplication()\n    delegate = ContactPickerDelegate.alloc().init()\n\n    picker = CNContactPickerViewController.alloc().init()\n    picker.setDelegate_(delegate)\n    picker.setDisplayedPropertyKeys_([CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey])\n\n    # Present the picker. In a real app, this would typically be triggered by a button click.\n    # For a simple script, we'll just present it directly from a dummy window or by itself.\n    # For a console app, it usually needs a backing NSApplication and a way to present it.\n    # Creating a minimal window to anchor it for this quickstart example.\n    from AppKit import NSWindow, NSBorderlessWindowMask, NSBackingStoreBuffered\n    from Foundation import NSMakeRect\n\n    dummy_window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(\n        NSMakeRect(0, 0, 1, 1), NSBorderlessWindowMask, NSBackingStoreBuffered, False\n    )\n    dummy_window.orderOut_(None)\n    app.activateIgnoringOtherApps_(True)\n    \n    app.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(\n        picker.view(),\n        dummy_window,\n        None,  # No modal delegate needed for simple dismiss\n        None,\n        None\n    )\n    \n    # The picker is presented as a sheet, which requires the app run loop.\n    app.run()\n\nif __name__ == '__main__':\n    main()\n","lang":"python","description":"This quickstart demonstrates how to display a `CNContactPickerViewController` to allow the user to select contacts. It initializes an `NSApplication`, sets up a `CNContactPickerDelegate` to handle selection or cancellation, and then presents the picker as a sheet. The selected contact's name and phone numbers are logged. Note that running PyObjC UI code typically requires an active `NSApplication` event loop.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-contactsui","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}