Registry /
communication / pyobjc-framework-multipeerconnectivity
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MultipeerConnectivity
✓ from MultipeerConnectivity import *
Standard import for accessing all symbols within the Multipeer Connectivity framework.
Foundation
✓ from Foundation import *
Often required for basic macOS types like `NSObject`, `NSString`, `NSHost` used in Multipeer Connectivity contexts.
AppHelper
✓ from PyObjCTools import AppHelper
Used for running the Cocoa event loop in console applications, which is essential for delegate callbacks.
This example demonstrates how to set up `MCNearbyServiceBrowser` and `MCNearbyServiceAdvertiser` to discover and be discovered by other devices using Multipeer Connectivity. It defines Python classes to act as delegates for handling discovery events and runs a console event loop to process callbacks. This simplified example focuses on peer discovery rather than full session management or data transfer.
import objc
from Foundation import *
from MultipeerConnectivity import *
from PyObjCTools import AppHelper
import sys
# Define a service type (must be 1-15 lowercase ASCII characters, no hyphens, no underscores)
SERVICE_TYPE = "my-p2p-app"
class BrowserDelegate(NSObject):
"""
Delegate for MCNearbyServiceBrowser to handle found and lost peers.
"""
def browser_foundPeer_withDiscoveryInfo_(self, browser, peerID, info):
print(f"[Browser] Found peer: {peerID.displayName()} (Info: {info})")
# In a real app, you'd now invite the peer to a session.
def browser_lostPeer_(self, browser, peerID):
print(f"[Browser] Lost peer: {peerID.displayName()}")
class AdvertiserDelegate(NSObject):
"""
Delegate for MCNearbyServiceAdvertiser to handle invitations.
"""
def advertiser_didReceiveInvitationFromPeer_withContext_invitationHandler_(self, advertiser, peerID, context, invitationHandler):
print(f"[Advertiser] Received invitation from {peerID.displayName()} (Context: {context})")
# For this simple example, we decline any invitations.
invitationHandler(False, None)
# 1. Create a peer ID for this device
myPeerID = MCPeerID.alloc().initWithDisplayName_(NSHost.currentHost().name())
print(f"Starting MultipeerConnectivity as: {myPeerID.displayName()}")
# 2. Setup a browser to find other peers
browserDelegate = BrowserDelegate.alloc().init()
browser = MCNearbyServiceBrowser.alloc().initWithPeer_serviceType_(myPeerID, SERVICE_TYPE)
browser.setDelegate_(browserDelegate)
browser.startBrowsingForPeers()
print(f"Started browsing for peers using service type: '{SERVICE_TYPE}'")
# 3. Setup an advertiser to be discovered by other peers
advertiserDelegate = AdvertiserDelegate.alloc().init()
advertiser = MCNearbyServiceAdvertiser.alloc().initWithPeer_discoveryInfo_serviceType_(myPeerID, None, SERVICE_TYPE)
advertiser.setDelegate_(advertiserDelegate)
advertiser.startAdvertisingPeer()
print(f"Started advertising using service type: '{SERVICE_TYPE}'")
print("\n--- Running event loop. Press Ctrl+C to stop. ---")
try:
AppHelper.runConsoleEventLoop(installInterrupt=True)
except KeyboardInterrupt:
print("\nStopping...")
finally:
browser.stopBrowsingForPeers()
advertiser.stopAdvertisingPeer()
print("Stopped browsing and advertising.")
sys.exit(0)
Debug
Known issues
breakingPyObjC has dropped support for older Python versions in recent major releases. Version 12.0 dropped Python 3.9, and version 11.0 dropped Python 3.8. Ensure your Python environment meets the minimum `requires_python` requirement.fixUpgrade to Python 3.10 or later for PyObjC 12.x, or Python 3.9 or later for PyObjC 11.x.
affects: >=11.0
breakingThe automatic reference counting (ARC) behavior for `init` family methods in Objective-C was corrected in PyObjC 11.1. Methods in the 'init' family now correctly steal a reference to self and return a new reference, aligning with `clang`'s documentation. This can affect custom initializers in Python subclasses of Objective-C classes.fixReview custom Python `__init__` implementations for Objective-C subclasses to ensure they correctly handle reference counts, especially if they are overriding `init` methods.
affects: >=11.1
gotchaWhen subclassing Objective-C classes in Python, there were changes in how `__init__` and `__new__` interact in PyObjC 10.3. If you provide a custom `__new__` in your Python class (or its superclasses), `__init__` can be used. However, if you rely on the `__new__` provided by PyObjC, `__init__` cannot be used directly to initialize the instance.fixIf your Python subclass needs custom initialization, ensure you either implement `__new__` yourself or use Objective-C compatible initialization patterns (e.g., `init` methods) directly, carefully managing object creation and initialization steps.
affects: >=10.3
gotchaPyObjC 11.0 introduced experimental support for Python 3.13's free-threading (PEP 703). While efforts have been made, users should be aware that this is an experimental feature and may not be fully stable or optimized. Earlier versions (e.g., PyObjC 10.3) explicitly did not support free threading.fixExercise caution when using PyObjC with free-threading in Python 3.13. Monitor PyObjC release notes for updates on free-threading support and report any issues encountered.
affects: >=11.0, Python 3.13+
breakingSpecific framework bindings can be removed from PyObjC if the underlying Apple framework is deprecated and removed from macOS SDKs. For example, the `IMServicePlugIn` bindings were removed in PyObjC 10.0 because the framework was removed in macOS 14. This applies to any `pyobjc-framework-*` package.fixBefore upgrading PyObjC, verify that any specific frameworks you rely on are still present and supported, especially when targeting newer macOS versions. Consult the PyObjC release notes for details on removed bindings.
affects: >=10.0
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides bindings for a specific macOS framework and requires the core PyObjC bridge.