Skip to content

Commit 9be5798

Browse files
committed
- Added an option to manually update the WWDR certificate to the help menu
- Fixed a bug where the main executable of an IPA sometimes didn't have the executable attribute set
1 parent bd14595 commit 9be5798

File tree

8 files changed

+79
-37
lines changed

8 files changed

+79
-37
lines changed

AppSigner/AppDelegate.swift

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Cocoa
1111
@NSApplicationMain
1212
class AppDelegate: NSObject, NSApplicationDelegate {
1313

14+
@IBOutlet weak var mainView: MainView!
1415
let fileManager = NSFileManager.defaultManager()
1516

1617

@@ -26,6 +27,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2627
func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
2728
return true
2829
}
30+
@IBAction func fixSigning(sender: NSMenuItem) {
31+
if let tempFolder = mainView.makeTempFolder() {
32+
iASShared.fixSigning(tempFolder)
33+
try? fileManager.removeItemAtPath(tempFolder)
34+
mainView.populateCodesigningCerts()
35+
}
36+
}
2937

3038
@IBAction func nsMenuLinkClick(sender: NSMenuLink) {
3139
NSWorkspace.sharedWorkspace().openURL(NSURL(string: sender.url!)!)

AppSigner/Application.xib

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
66
</dependencies>
77
<objects>
88
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -11,7 +11,11 @@
1111
</connections>
1212
</customObject>
1313
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14-
<customObject id="aMe-uV-AHx" customClass="AppDelegate" customModule="iOS_App_Signer" customModuleProvider="target"/>
14+
<customObject id="aMe-uV-AHx" customClass="AppDelegate" customModule="iOS_App_Signer" customModuleProvider="target">
15+
<connections>
16+
<outlet property="mainView" destination="se5-gp-TjO" id="Mal-fb-Nqp"/>
17+
</connections>
18+
</customObject>
1519
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
1620
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
1721
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
@@ -94,6 +98,12 @@
9498
<action selector="nsMenuLinkClick:" target="aMe-uV-AHx" id="kuT-Sl-Lfb"/>
9599
</connections>
96100
</menuItem>
101+
<menuItem title="Update Apple WWDR Certificate" id="yW3-3F-UGM">
102+
<modifierMask key="keyEquivalentModifierMask"/>
103+
<connections>
104+
<action selector="fixSigning:" target="aMe-uV-AHx" id="11N-yH-9Q4"/>
105+
</connections>
106+
</menuItem>
97107
<menuItem title="Check for Updates" id="z6H-Tg-1uh">
98108
<modifierMask key="keyEquivalentModifierMask"/>
99109
<connections>
@@ -109,7 +119,7 @@
109119
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" unifiedTitleAndToolbar="YES"/>
110120
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
111121
<rect key="contentRect" x="196" y="240" width="550" height="181"/>
112-
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
122+
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1080"/>
113123
<value key="minSize" type="size" width="550" height="181"/>
114124
<value key="maxSize" type="size" width="9999" height="181"/>
115125
<view key="contentView" id="se5-gp-TjO" customClass="MainView" customModule="iOS_App_Signer" customModuleProvider="target">

AppSigner/Classes/iASShared.swift

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// iASShared.swift
3+
// iOS App Signer
4+
//
5+
// Created by Daniel Radtke on 5/7/16.
6+
// Copyright © 2016 Daniel Radtke. All rights reserved.
7+
//
8+
9+
import Foundation
10+
class iASShared {
11+
static func fixSigning(tempFolder: String){
12+
let script = "do shell script \"/bin/bash \\\"\(NSBundle.mainBundle().pathForResource("fix-wwdr", ofType: "sh")!)\\\"\" with administrator privileges"
13+
NSAppleScript(source: script)?.executeAndReturnError(nil)
14+
//https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
15+
return
16+
}
17+
}

AppSigner/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.8</string>
18+
<string>1.8.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1</string>
22+
<string>1.8.1</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string></string>
2525
<key>LSMinimumSystemVersion</key>

AppSigner/MainView.swift

+15-14
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
4444
let defaultsPath = "/usr/bin/defaults"
4545
let codesignPath = "/usr/bin/codesign"
4646
let securityPath = "/usr/bin/security"
47+
let chmodPath = "/bin/chmod"
4748

4849
//MARK: Drag / Drop
4950
var fileTypes: [String] = ["ipa","deb","app","xcarchive","mobileprovision"]
@@ -216,7 +217,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
216217

217218
var index: Int
218219

219-
for index = 0; index <= rawResult.count - 2; index+=2 {
220+
for index in 0.stride(through: rawResult.count - 2, by: 2) {
220221
if !(rawResult.count - 1 < index + 1) {
221222
output.append(rawResult[index+1])
222223
}
@@ -232,7 +233,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
232233
alert.addButtonWithTitle("No")
233234
if alert.runModal() == NSAlertFirstButtonReturn {
234235
if let tempFolder = makeTempFolder() {
235-
fixSigning(tempFolder)
236+
iASShared.fixSigning(tempFolder)
236237
try? fileManager.removeItemAtPath(tempFolder)
237238
populateCodesigningCerts()
238239
}
@@ -444,12 +445,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
444445
}
445446
return nil
446447
}
447-
func fixSigning(tempFolder: String){
448-
let script = "do shell script \"/bin/bash \\\"\(NSBundle.mainBundle().pathForResource("fix-wwdr", ofType: "sh")!)\\\"\" with administrator privileges"
449-
NSAppleScript(source: script)?.executeAndReturnError(nil)
450-
//https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
451-
return
452-
}
448+
453449
func startSigning() {
454450
controlsEnabled(false)
455451

@@ -459,7 +455,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
459455
saveDialog.nameFieldStringValue = InputFileText.stringValue.lastPathComponent.stringByDeletingPathExtension
460456
if saveDialog.runModal() == NSFileHandlingPanelOKButton {
461457
outputFile = saveDialog.URL!.path
462-
NSThread.detachNewThreadSelector(Selector("signingThread"), toTarget: self, withObject: nil)
458+
NSThread.detachNewThreadSelector(#selector(self.signingThread), toTarget: self, withObject: nil)
463459
} else {
464460
outputFile = nil
465461
controlsEnabled(true)
@@ -529,7 +525,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
529525
alert.informativeText = "You appear to have a error with your codesigning certificate, do you want me to try and fix the problem?"
530526
let response = alert.runModal()
531527
if response == NSAlertFirstButtonReturn {
532-
self.fixSigning(tempFolder)
528+
iASShared.fixSigning(tempFolder)
533529
if self.testSigning(signingCertificate!, tempFolder: tempFolder) == false {
534530
let errorAlert = NSAlert()
535531
errorAlert.messageText = "Unable to Fix"
@@ -757,19 +753,24 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
757753
}
758754
} else {
759755
setStatus("Unable to read entitlements from provisioning profile")
760-
warnings++
756+
warnings += 1
761757
}
762758
if profile.appID != "*" && (newApplicationID != "" && newApplicationID != profile.appID) {
763759
setStatus("Unable to change App ID to \(newApplicationID), provisioning profile won't allow it")
764760
cleanup(tempFolder); return
765761
}
766762
} else {
767763
setStatus("Unable to parse provisioning profile, it may be corrupt")
768-
warnings++
764+
warnings += 1
769765
}
770766

771767
}
772768

769+
//MARK: Make sure that the executable is well... executable.
770+
if let bundleExecutable = getPlistKey(appBundleInfoPlist, keyName: "CFBundleExecutable"){
771+
NSTask().execute(chmodPath, workingDirectory: nil, arguments: ["755", appBundlePath.stringByAppendingPathComponent(bundleExecutable)])
772+
}
773+
773774
//MARK: Change Application ID
774775
if newApplicationID != "" {
775776

@@ -834,7 +835,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
834835
if codesignOutput.status != 0 {
835836
setStatus("Error codesigning \(shortName(file, payloadDirectory: payloadDirectory))")
836837
Log.write(codesignOutput.output)
837-
warnings++
838+
warnings += 1
838839
}
839840
}
840841

@@ -850,7 +851,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
850851
//MARK: Codesigning - Eggs
851852
let eggSigningFunction = generateFileSignFunc(eggDirectory, entitlementsPath: entitlementsPlist, signingCertificate: signingCertificate!)
852853
func signEgg(eggFile: String){
853-
eggCount++
854+
eggCount += 1
854855

855856
let currentEggPath = eggDirectory.stringByAppendingPathComponent("egg\(eggCount)")
856857
let shortName = eggFile.substringFromIndex(payloadDirectory.endIndex)

AppSigner/Updates.xib

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
66
</dependencies>
77
<objects>
88
<customObject id="-2" userLabel="File's Owner" customClass="UpdatesController" customModule="iOS_App_Signer" customModuleProvider="target">
@@ -20,7 +20,7 @@
2020
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
2121
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
2222
<rect key="contentRect" x="196" y="240" width="615" height="344"/>
23-
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
23+
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
2424
<value key="minSize" type="size" width="615" height="230"/>
2525
<view key="contentView" id="EiT-Mj-1SZ">
2626
<rect key="frame" x="0.0" y="0.0" width="615" height="344"/>
@@ -61,18 +61,18 @@
6161
<scrollView misplaced="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uB7-Qr-xtC">
6262
<rect key="frame" x="92" y="49" width="503" height="200"/>
6363
<clipView key="contentView" copiesOnScroll="NO" id="xQc-hh-esc">
64-
<rect key="frame" x="1" y="1" width="501" height="198"/>
64+
<rect key="frame" x="1" y="1" width="486" height="198"/>
6565
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
6666
<subviews>
6767
<textView editable="NO" importsGraphics="NO" verticallyResizable="YES" allowsNonContiguousLayout="YES" id="9oR-gz-UUY">
68-
<rect key="frame" x="0.0" y="0.0" width="501" height="198"/>
68+
<rect key="frame" x="0.0" y="0.0" width="486" height="198"/>
6969
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
7070
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
71-
<size key="minSize" width="501" height="198"/>
72-
<size key="maxSize" width="501" height="10000000"/>
71+
<size key="minSize" width="486" height="198"/>
72+
<size key="maxSize" width="503" height="10000000"/>
7373
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
74-
<size key="minSize" width="501" height="198"/>
75-
<size key="maxSize" width="501" height="10000000"/>
74+
<size key="minSize" width="486" height="198"/>
75+
<size key="maxSize" width="503" height="10000000"/>
7676
</textView>
7777
</subviews>
7878
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -82,7 +82,7 @@
8282
<autoresizingMask key="autoresizingMask"/>
8383
</scroller>
8484
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Yeh-63-iCe">
85-
<rect key="frame" x="486" y="1" width="16" height="198"/>
85+
<rect key="frame" x="487" y="1" width="15" height="198"/>
8686
<autoresizingMask key="autoresizingMask"/>
8787
</scroller>
8888
</scrollView>

AppSigner/UpdatesController.swift

+9-7
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,26 @@ class UpdatesController: NSWindowController {
102102
super.showWindow(sender)
103103
appIcon.image = NSWorkspace.sharedWorkspace().iconForFile(NSBundle.mainBundle().bundlePath)
104104
var releaseOutput: [String] = []
105-
if let releases = sender![1] as? [[String: AnyObject]],
106-
currentVersion = sender![0] as? String {
107-
for release in releases {
108-
if let name = release["name"] as? String,
109-
body = release["body"] as? String {
105+
if let senderArray = sender as? [AnyObject] {
106+
if let releases = senderArray[1] as? [[String: AnyObject]],
107+
currentVersion = senderArray[0] as? String {
108+
for release in releases {
109+
if let name = release["name"] as? String,
110+
body = release["body"] as? String {
110111
if latestVersion == nil {
111112
latestVersion = name
112113
}
113114
if currentVersion == name {
114115
break
115116
}
116117
releaseOutput.append("**Version \(name)**\n\(body)")
118+
}
117119
}
120+
versionLabel.stringValue = "Version \(latestVersion!) is now available, you have \(currentVersion)."
118121
}
119-
versionLabel.stringValue = "Version \(latestVersion!) is now available, you have \(currentVersion)."
122+
setChangelog(releaseOutput.joinWithSeparator("\n\n"))
120123
}
121124

122-
setChangelog(releaseOutput.joinWithSeparator("\n\n"))
123125
}
124126
func setChangelog(text: String){
125127
changelogText.editable = true

iOS App Signer.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
659734A11C65B5F600383D2D /* MarkdownTokens.m in Sources */ = {isa = PBXBuildFile; fileRef = 6597349C1C65B5F600383D2D /* MarkdownTokens.m */; };
2323
659734A21C65B5F600383D2D /* NSAttributedStringMarkdownParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 6597349F1C65B5F600383D2D /* NSAttributedStringMarkdownParser.m */; };
2424
659734A71C65B94F00383D2D /* fmemopen.c in Sources */ = {isa = PBXBuildFile; fileRef = 659734A41C65B94F00383D2D /* fmemopen.c */; };
25+
65B2EAA21CDE981500D02053 /* iASShared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B2EAA11CDE981500D02053 /* iASShared.swift */; };
2526
65CED3A32D8B6F3E00E9185B /* fix-wwdr.sh in Resources */ = {isa = PBXBuildFile; fileRef = 65CED3A22D8B6F3E00E9185B /* fix-wwdr.sh */; };
2627
/* End PBXBuildFile section */
2728

@@ -50,6 +51,7 @@
5051
659734A51C65B94F00383D2D /* fmemopen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fmemopen.h; path = NimbusKit/memorymapping/fmemopen.h; sourceTree = "<group>"; };
5152
659734A61C65B94F00383D2D /* NimbusMemoryMapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NimbusMemoryMapping.h; path = NimbusKit/memorymapping/NimbusMemoryMapping.h; sourceTree = "<group>"; };
5253
65B24E0D1BECB30D005D2068 /* AppSigner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = AppSigner.entitlements; sourceTree = "<group>"; };
54+
65B2EAA11CDE981500D02053 /* iASShared.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iASShared.swift; path = AppSigner/Classes/iASShared.swift; sourceTree = "<group>"; };
5355
65CED3A22D8B6F3E00E9185B /* fix-wwdr.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "fix-wwdr.sh"; path = "Resources/fix-wwdr.sh"; sourceTree = "<group>"; };
5456
/* End PBXFileReference section */
5557

@@ -105,6 +107,7 @@
105107
655FFFA11BEAD93600D43AD8 /* ProvisioningProfile.swift */,
106108
65311EAF1BF835F100516EFD /* Log.swift */,
107109
65311EAD1BF8259000516EFD /* NSMenuLink.swift */,
110+
65B2EAA11CDE981500D02053 /* iASShared.swift */,
108111
);
109112
name = Classes;
110113
path = ..;
@@ -251,6 +254,7 @@
251254
655FFF9D1BE9B3E300D43AD8 /* NSTask-execute.swift in Sources */,
252255
659734A21C65B5F600383D2D /* NSAttributedStringMarkdownParser.m in Sources */,
253256
655FFFA21BEAD93600D43AD8 /* ProvisioningProfile.swift in Sources */,
257+
65B2EAA21CDE981500D02053 /* iASShared.swift in Sources */,
254258
);
255259
runOnlyForDeploymentPostprocessing = 0;
256260
};

0 commit comments

Comments
 (0)