Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Quick XPC client for the teslad daemon which exposes CCDServiceInterface protocol
// main.m
// TeslaClient
// Created by Scott Knight on 6/11/19.
// Copyright © 2019 Scott Knight. All rights reserved.
#import <Foundation/Foundation.h>
Needs the following entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
In order to grant yourself this entitlement you need to do the following:
1. Disable SIP
2. Disable AMFID (sudo nvram boot-args="amfi_get_out_of_my_way=0x1")
@protocol CCDServiceInterface
-(void)provisionallyEnrollWithNonce:(NSString *)nonce completionBlock:(void (^)(bool finished, NSDictionary *dict, NSError *error))completionBlock;
-(void)fetchConfigurationWithCompletionBlock:(void (^)(bool finished, NSDictionary *dict, NSError *error))completionBlock;
-(void)unenrollWithCompletionBlock:(void (^)(bool finished, NSDictionary *dict, NSError *error))completionBlock;
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:@""\
NSXPCInterface *interface = [NSXPCInterface interfaceWithProtocol:@protocol(CCDServiceInterface)];
[connection setRemoteObjectInterface:interface];
[connection setInvalidationHandler:^{
NSLog(@"TeslaClient invalidation handler!");
[connection setInterruptionHandler:^{
NSLog(@"TeslaClient interruption handler!");
[connection resume];
[[connection remoteObjectProxy] provisionallyEnrollWithNonce:@"nonce" completionBlock:^(bool finished, NSDictionary *dict, NSError *error) {
// [[connection remoteObjectProxy] fetchConfigurationWithCompletionBlock:^(bool finished, NSDictionary *dict, NSError *error) {
// NSLog(@"fetchConfigurationWithCompletionBlock:");
// }];
// [[connection remoteObjectProxy] unenrollWithCompletionBlock:^(bool finished, NSDictionary *dict, NSError *error) {
// NSLog(@"unenrollWithCompletionBlock:");
// }];
[[NSRunLoop currentRunLoop] run];
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.