From 04f771c282629ac8d449e6705afd473f782fb20b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Se=C3=A1n=20Labastille?= <sean@lsr.li>
Date: Wed, 18 May 2016 15:15:33 +0200
Subject: [PATCH] Replace 'Reset' button

Replaces Reset button for distribution profile when private key is
missing.
---
 FixCode/FixCode.m | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/FixCode/FixCode.m b/FixCode/FixCode.m
index 1e5ac9a..1154bb1 100755
--- a/FixCode/FixCode.m
+++ b/FixCode/FixCode.m
@@ -11,6 +11,18 @@
 #import "Aspects.h"
 #import "FixCode.h"
 
+@interface IDEEnhancedProvisioningSigningIdentity : NSObject
+
+@property NSUInteger state; // 0: current, 2: online-only
+
+@end
+
+@interface IDESigningIdentityActionCellViewContents : NSObject
+
+@property IDEEnhancedProvisioningSigningIdentity *signingIdentity;
+
+@end
+
 @interface NSObject (Shutup)
 
 -(void)_autoLayoutViewViewFrameDidChange:(id)arg0;
@@ -163,6 +175,16 @@ - (void)swizzleCodeSigningResolution
     if (error) {
         NSLog(@"Error: %@", error);
     }
+    
+    [objc_getClass("IDESigningIdentityActionCellView") aspect_hookSelector:@selector(setObjectValue:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info, IDESigningIdentityActionCellViewContents *cellContents) {
+        if ([[cellContents signingIdentity] state] == 2) {
+            [self findAndReplaceFixIssueButtonInView:info.instance];
+        }
+    } error:&error];
+    
+    if (error) {
+        NSLog(@"Error: %@", error);
+    }
 }
 
 @end