This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathosx-installer-stub.mm
More file actions
79 lines (61 loc) · 3.39 KB
/
osx-installer-stub.mm
File metadata and controls
79 lines (61 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (C) 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#import <Foundation/Foundation.h>
// This file is a simple stub executable for launching the AppleScript that
// opens a Finder window showing the contents of the DMG. It is used by the
// auto-updater to display the contents of the DMG so the user can copy the new
// app bundle to their Applications folder.
//
// Previously, we used a shell script to do the launching. However, as of OSX
// 10.11.4, the `codesign` tool generates signatures that cannot be verified on
// earlier versions of OSX when asked to sign a non-MachO executable as code.
//
// Therefore, we use this executable in place of the shell script so that the
// object being signed is one that doesn't cause problems.
int main(int argc, char* argv[])
{
// Get the main bundle for the application
NSBundle* mainBundle = [NSBundle mainBundle];
// Path to the subdirectory containing the bundle's resources
NSString* resourcePath = [mainBundle resourcePath];
// Append the path to the AppleScript that opens a Finder window
NSString* scriptPath = [resourcePath stringByAppendingPathComponent:@"Installer/ShowDmgWindow.scpt"];
// Turn the path into a URL and load it into an AppleScript object
NSURL* scriptURL = [[NSURL alloc] initFileURLWithPath:scriptPath];
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:scriptURL error:nil];
// Generate the "run" AppleEvent to send to the script. It needs to be given
// an array containing 1 item which is the POSIX path to the DMG folder.
NSString* dmgPath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
NSAppleEventDescriptor* pathDescriptor = [NSAppleEventDescriptor descriptorWithString:dmgPath];
NSAppleEventDescriptor* argvList = [NSAppleEventDescriptor listDescriptor];
NSAppleEventDescriptor* appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
eventID:kAEOpenApplication
targetDescriptor:nil
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID ];
[argvList insertDescriptor:pathDescriptor atIndex:1];
[appleEvent setParamDescriptor:argvList forKeyword:keyDirectObject];
// Execute the script
[appleScript executeAppleEvent:appleEvent error:nil];
// Cleanup
[appleEvent release];
[argvList release];
[pathDescriptor release];
[dmgPath release];
[appleScript release];
[scriptURL release];
[scriptPath release];
[resourcePath release];
[mainBundle release];
// All done
return 0;
}