0

私は拡張機能を書いており、メインアプリは PyObjc にあります。メインアプリと拡張機能間の通信をセットアップしたい。リンクへの参照を使用して、プロトコルを作成してみました。

SampleExtensionProtocol = objc.formal_protocol('SampleExtensionProtocol', (), [
    objc.selector(None, b"upperCaseString:withReply:", signature=b"v@:@@",isRequired=0),
    objc.selector(None, b"setEnableTemperProof:withReply:", signature=b"v@:@@",isRequired=0),
])

接続オブジェクトが作成されます。

connection = NSXPCConnection.alloc().initWithMachServiceName_options_("com.team.extension",NSXPCConnectionPrivileged)

登録されたメタデータも同様です。

objc.registerMetaDataForSelector(b'NSObject', b'upperCaseString:withReply:', {
'arguments': {
    3: {
       'callable': {
          'retval': {'type': b'@'}, 
          'arguments': {
              0: {'type': b'^v'}, 
              1: {'type': b'i'}, 
          },
       },
    }
  }
})

objc.registerMetaDataForSelector(b'NSObject', b'setEnableTemperProof:withReply:', {
'arguments': {
    3: {
       'callable': {
          'retval': {'type': b'@'}, 
          'arguments': {
              0: {'type': b'^v'}, 
              1: {'type': b'i'}, 
          },
       },
    }
  }
})

しかし、インターフェースの作成中にエラーが発生しました。

mySvcIF = Foundation.NSXPCInterface.interfaceWithProtocol_(SampleExtensionProtocol)


ValueError: NSInvalidArgumentException - NSXPCInterface: Unable to get extended method signature from Protocol data (SampleExtensionProtocol / upperCaseString:withReply:). Use of clang is required for NSXPCInterface.
4

1 に答える 1