Skip to content

Commit

Permalink
Syncing xcodeDev from un-sandboxed app to client for XCTests.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnno1962 committed Jul 21, 2022
1 parent 8b74d9e commit 6af967e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Sources/HotReloading/InjectionClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 02/24/2021.
// Copyright © 2021 John Holdsworth. All rights reserved.
//
// $Id: //depot/HotReloading/Sources/HotReloading/InjectionClient.swift#45 $
// $Id: //depot/HotReloading/Sources/HotReloading/InjectionClient.swift#46 $
//
// Client app side of HotReloading started by +load
// method in HotReloadingGuts/ClientBoot.mm
Expand Down Expand Up @@ -293,6 +293,10 @@ public class InjectionClient: SimpleSocket, InjectionReader {
.components(separatedBy: ",") as? NSMutableArray {
SwiftInjection.descriptorRefs = descriptorRefs
}
case .syncXcodeDev:
if let xcodeDev = readString() {
builder.xcodeDev = xcodeDev
}
default:
processOnMainThread(command: command, builder: builder)
}
Expand Down
11 changes: 8 additions & 3 deletions Sources/HotReloading/SwiftEval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 02/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/HotReloading/Sources/HotReloading/SwiftEval.swift#63 $
// $Id: //depot/HotReloading/Sources/HotReloading/SwiftEval.swift#64 $
//
// Basic implementation of a Swift "eval()" including the
// mechanics of recompiling a class and loading the new
Expand Down Expand Up @@ -473,9 +473,14 @@ public class SwiftEval: NSObject {
if sourceFile.contains("Spec.") {
let dylib = tmpfile+Self.quickDylib
do {
let platformLib = "__PLATFORM__/../../usr/lib"
let platformFrameworks = "__PLATFORM__/../../Library/Frameworks"
try link(dylib: dylib, compileCommand: compileCommand, contents: """
\(logsDir.path)/../../Build/Products/\(Self.quickFiles) \
__PLATFORM__/../../usr/lib/libXCTestSwiftSupport.dylib
\(platformLib)/libXCTestSwiftSupport.dylib \
-Xlinker -rpath \(platformLib) \
-framework XCTest -F \(platformFrameworks) \
-Xlinker -rpath \(platformFrameworks)
""")
speclib = dylib
} catch {
Expand Down Expand Up @@ -506,7 +511,7 @@ public class SwiftEval: NSObject {
if let devRange = Range(match.range(at: 2), in: compileCommand) {
xcodeDev = String(compileCommand[devRange])
}
if let pltRange = Range(match.range(at: 3), in: compileCommand) {
if let pltRange = Range(match.range(at: 4), in: compileCommand) {
platform = String(compileCommand[pltRange])
}
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/HotReloadingGuts/include/InjectionClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 06/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/HotReloading/Sources/HotReloadingGuts/include/InjectionClient.h#38 $
// $Id: //depot/HotReloading/Sources/HotReloadingGuts/include/InjectionClient.h#39 $
//
// Shared definitions between server and client.
//
Expand Down Expand Up @@ -99,6 +99,7 @@ typedef NS_ENUM(int, InjectionCommand) {
InjectionPseudoInject,
InjectionObjcClassRefs,
InjectionDescriptorRefs,
InjectionSyncXcodeDev,

InjectionInvalid = 1000,

Expand Down
3 changes: 2 additions & 1 deletion Sources/injectiond/InjectionServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by John Holdsworth on 06/11/2017.
// Copyright © 2017 John Holdsworth. All rights reserved.
//
// $Id: //depot/HotReloading/Sources/injectiond/InjectionServer.swift#45 $
// $Id: //depot/HotReloading/Sources/injectiond/InjectionServer.swift#46 $
//

import Cocoa
Expand Down Expand Up @@ -326,6 +326,7 @@ public class InjectionServer: SimpleSocket {
compileQueue.async {
if let dylib = try? self.builder?.rebuildClass(oldClass: nil,
classNameOrFile: source, extra: nil) {
self.sendCommand(.syncXcodeDev, with: self.builder.xcodeDev)
#if SWIFT_PACKAGE && false // for virtualised simulator
if let data = NSData(contentsOfFile: "\(dylib).dylib") {
commandQueue.sync {
Expand Down

0 comments on commit 6af967e

Please sign in to comment.