Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit bb88215

Browse files
committed
[Xcode 8.3] Fix simulator deployment
1 parent e7a7fe2 commit bb88215

File tree

2 files changed

+55
-21
lines changed

2 files changed

+55
-21
lines changed

revmobile/src/reviphone.mm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ bool revIPhoneLaunchAppInSimulator(MCVariableRef *argv, uint32_t argc, MCVariabl
534534
t_app_spec = [s_simulator_proxy specifierWithApplicationPath: [NSString stringWithUTF8String:t_app.buffer]];
535535

536536
t_session_config = [s_simulator_proxy newSessionConfig];
537+
537538

538539
[t_session_config setApplicationToSimulateOnStart:t_app_spec];
539540

@@ -551,13 +552,17 @@ bool revIPhoneLaunchAppInSimulator(MCVariableRef *argv, uint32_t argc, MCVariabl
551552
// MM-2014-10-07: [[ Bug 13584 ]] As well as setting the sys root, also set the sim runtime where applicable.
552553
// Ensures we launch the correct version of the simulator.
553554
if (s_simulator_runtime != nil && [t_session_config respondsToSelector: @selector(setRuntime:)])
555+
{
554556
[t_session_config setRuntime: s_simulator_runtime];
555-
557+
}
556558
[t_session_config setSimulatedApplicationShouldWaitForDebugger: NO];
557559
[t_session_config setSimulatedApplicationLaunchArgs: [NSArray array]];
558560
[t_session_config setSimulatedApplicationLaunchEnvironment: [NSDictionary dictionary]];
559-
[t_session_config setLocalizedClientName: @"LiveCode"];
560-
561+
562+
// As of Xcode 8.3 the property NSString *localizedClientName is no longer available in DTiPhoneSimulatorSessionConfig class
563+
if ([t_session_config respondsToSelector: @selector(setLocalizedClientName:)])
564+
[t_session_config setLocalizedClientName: @"LiveCode"];
565+
561566
bool t_is_ipad;
562567
t_is_ipad = strcasecmp(t_family, "ipad") == 0;
563568

@@ -812,9 +817,9 @@ bool revIPhoneSetToolset(MCVariableRef *argv, uint32_t argc, MCVariableRef resul
812817
{
813818
NSBundle *t_bundle;
814819
t_bundle = [NSBundle bundleForClass: objc_getClass("revIPhoneLaunchDelegate")];
815-
t_id = [NSString stringWithFormat: @"com.runrev.reviphoneproxy.%08x.%08x", getpid(), clock()];
820+
t_id = [NSString stringWithFormat: @"com.runrev.reviphoneproxy.%08x.%08lx", getpid(), clock()];
816821
t_task = [NSTask launchedTaskWithLaunchPath: [t_bundle pathForAuxiliaryExecutable: @"reviphoneproxy"] //[(NSURL *)t_url path]] //@"/Volumes/Macintosh HD/Users/mark/Workspace/revolution/trunk-mobile/_build/Debug/reviphoneproxy"
817-
arguments: [NSArray arrayWithObjects: t_path, t_id, nil]];
822+
arguments: [NSArray arrayWithObjects: t_path, t_id, (NSString*)nil]];
818823
if (t_task == nil)
819824
t_success = Throw("unable to start proxy");
820825
}

revmobile/src/reviphoneproxy.mm

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,28 @@ - (id)getRootWithSimRuntime: (id)runtime
162162

163163
////////////////////////////////////////////////////////////////////////////////
164164

165+
int getXcodeVersion(char *path_to_developer_folder)
166+
{
167+
NSBundle *t_xcode_bundle = nil;
168+
NSString *t_xcode_path = [NSString stringWithFormat: @"%s/../../", path_to_developer_folder];
169+
170+
t_xcode_bundle = [NSBundle bundleWithPath: t_xcode_path];
171+
172+
NSString *t_xcode_version_string = [[t_xcode_bundle infoDictionary] objectForKey:@"CFBundleShortVersionString"];
173+
NSArray *t_xcode_version_array = [t_xcode_version_string componentsSeparatedByString:@"."];
174+
175+
int t_xcode_version;
176+
t_xcode_version = [[t_xcode_version_array objectAtIndex:0] intValue] * 100;
177+
t_xcode_version += [[t_xcode_version_array objectAtIndex:1] intValue] * 10;
178+
179+
if ([t_xcode_version_array count] == 3)
180+
{
181+
t_xcode_version += [[t_xcode_version_array objectAtIndex:2] intValue];
182+
}
183+
184+
return t_xcode_version;
185+
}
186+
165187
int main(int argc, char *argv[])
166188
{
167189
bool t_success;
@@ -215,22 +237,29 @@ int main(int argc, char *argv[])
215237

216238
//NSLog(@"DVTFoundation %d", t_success);
217239
}
218-
219-
NSBundle *t_dev_tools_bundle;
220-
t_dev_tools_bundle = nil;
221-
if (t_success)
222-
{
223-
NSString *t_dev_tools_path;
224-
t_dev_tools_path = [NSString stringWithFormat: @"%s/../OtherFrameworks/DevToolsFoundation.framework", argv[1]];
225-
226-
if (![[NSFileManager defaultManager] fileExistsAtPath: t_dev_tools_path])
227-
t_dev_tools_path = [NSString stringWithFormat: @"%s/Library/PrivateFrameworks/DevToolsFoundation.framework", argv[1]];
228-
229-
t_dev_tools_bundle = [NSBundle bundleWithPath: t_dev_tools_path];
230-
t_success = [t_dev_tools_bundle load];
231-
232-
//NSLog(@"DevTools %d", t_success);
233-
}
240+
241+
int t_xcode_version = getXcodeVersion(argv[1]);
242+
243+
// In Xcode 8.3 the Xcode.app/Contents/OtherFrameworks/DevToolsFoundation.framework is no longer present
244+
// In fact it is not needed anyway
245+
if (t_xcode_version < 830)
246+
{
247+
NSBundle *t_dev_tools_bundle;
248+
t_dev_tools_bundle = nil;
249+
if (t_success)
250+
{
251+
NSString *t_dev_tools_path;
252+
t_dev_tools_path = [NSString stringWithFormat: @"%s/../OtherFrameworks/DevToolsFoundation.framework", argv[1]];
253+
254+
if (![[NSFileManager defaultManager] fileExistsAtPath: t_dev_tools_path])
255+
t_dev_tools_path = [NSString stringWithFormat: @"%s/Library/PrivateFrameworks/DevToolsFoundation.framework", argv[1]];
256+
257+
t_dev_tools_bundle = [NSBundle bundleWithPath: t_dev_tools_path];
258+
t_success = [t_dev_tools_bundle load];
259+
260+
//NSLog(@"DevTools %d", t_success);
261+
}
262+
}
234263

235264
if (t_success)
236265
{

0 commit comments

Comments
 (0)