Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion BuildHelper/BuildHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1600;
LastUpgradeCheck = 2640;
TargetAttributes = {
63A746952AFDD742003FA3AC = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -244,6 +244,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand Down Expand Up @@ -301,6 +302,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63A746952AFDD742003FA3AC"
BuildableName = "BuildHelper.app"
BlueprintName = "BuildHelper"
ReferencedContainer = "container:BuildHelper.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
queueDebuggingEnableBacktraceRecording = "Yes">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63A746952AFDD742003FA3AC"
BuildableName = "BuildHelper.app"
BlueprintName = "BuildHelper"
ReferencedContainer = "container:BuildHelper.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63A746952AFDD742003FA3AC"
BuildableName = "BuildHelper.app"
BlueprintName = "BuildHelper"
ReferencedContainer = "container:BuildHelper.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 3 additions & 1 deletion Example/SwiftHotReloadExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1600;
LastUpgradeCheck = 2640;
TargetAttributes = {
63980F422AEA8DA50099B122 = {
CreatedOnToolsVersion = 15.0.1;
Expand Down Expand Up @@ -232,6 +232,7 @@
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand Down Expand Up @@ -287,6 +288,7 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
LastUpgradeVersion = "2640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63980F702AEA93310099B122"
BuildableName = "SwiftHotReload.framework"
BlueprintName = "SwiftHotReload"
ReferencedContainer = "container:SwiftHotReload.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
queueDebuggingEnableBacktraceRecording = "Yes">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "63980F702AEA93310099B122"
BuildableName = "SwiftHotReload.framework"
BlueprintName = "SwiftHotReload"
ReferencedContainer = "container:SwiftHotReload.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Sources/Core/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public final actor Builder {
}
self.derivedData = derivedData
self.moduleCachePath = derivedData.appendingPathComponent("ModuleCache.noindex")
guard let confBuildDirAppRandomString = p.confBuildDirAppRandomString ?? p.env.estimatedConfigurationBuildRandomString else {
guard let confBuildDirAppRandomString = p.confBuildDirAppRandomString ?? p.env.estimatedConfigurationBuildRandomString ?? Env.host.estimatedConfigurationBuildRandomString else {
throw Error.missingRequiredEnvironments("confBuildDirAppRandomString")
}
guard let mainModule = p.mainModule ?? p.env.estimatedMainModule else {
Expand Down
35 changes: 31 additions & 4 deletions Sources/Core/Env.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@ public struct Env: Codable, Equatable, Sendable {

/// /Users/username
public var estimatedHomeDir: URL? {
(SIMULATOR_HOST_HOME ?? NSHomeDirectory()).map(URL.init(fileURLWithPath:))
URL(fileURLWithPath: SIMULATOR_HOST_HOME ?? NSHomeDirectory())
}
/// /Users/username/Library/Developer/Xcode/DerivedData/app-abcdefg0123456789/Build/Products/Debug-iphonesimulator
var estimatedBuilProductsDir: [URL] {
let a = DYLD_FRAMEWORK_PATH.filter {!$0.isEmpty}.map(URL.init(fileURLWithPath:))
let b = [(__XPC_DYLD_FRAMEWORK_PATH ?? __XPC_DYLD_LIBRARY_PATH ?? __XCODE_BUILT_PRODUCTS_DIR_PATHS ?? __XPC_DYLD_LIBRARY_PATH ?? PWD).map(URL.init(fileURLWithPath:))].compactMap {$0}
let c = LC_RPATHs.filter { $0.contains("/DerivedData/") && $0.contains("/Build/Products/") }.map { $0.replacingOccurrences(of: "/PackageFrameworks", with: "")
}.map(URL.init(fileURLWithPath:))
return a + b + c
let r = a + b + c
return r
// // for device, feed by BuildHelper
// func fallback() -> [URL] {
// guard let estimataedDerivedData, let estimatedConfigurationBuildRandomString else {return []}
// return [estimataedDerivedData
// .appendingPathComponent(estimatedConfigurationBuildRandomString)
// .appendingPathComponent("Build/Products")]
// // TODO
// }
// return !r.isEmpty ? r : (self != .host ? Env.host.estimatedBuilProductsDir : [])
}
/// /Users/username/Library/Developer/Xcode/DerivedData
public var estimataedDerivedData: URL? {
Expand All @@ -31,6 +41,7 @@ public struct Env: Codable, Equatable, Sendable {
.reversed().drop {$0 != "DerivedData"}.reversed()
.joined(separator: "/"))
}.first { $0.path.contains("DerivedData") }
?? (self != .host ? Env.host.estimataedDerivedData : nil) // for device, feed by BuildHelper
}
/// app-abcdefg0123456789
public var estimatedConfigurationBuildRandomString: String? {
Expand Down Expand Up @@ -59,6 +70,7 @@ public struct Env: Codable, Equatable, Sendable {
/// Debug
public var estimatedConfigurationPlatform: String? {
estimatedBuilProductsDir.first?.lastPathComponent
?? DTPlatformName.map {"Debug-\($0)"} // assuming Debug (non Release, and named Debug), assuming non-macOS (=has suffix)
}
/// iphonesimulator
var estimatedPlatform: String? {
Expand All @@ -70,7 +82,7 @@ public struct Env: Codable, Equatable, Sendable {
$0.components(separatedBy: "/")
.reversed().drop {$0 != "Platforms"}.dropFirst().reversed()
.joined(separator: "/")
}).map(URL.init(fileURLWithPath:))
}).flatMap {$0.isEmpty ? nil : URL(fileURLWithPath: $0)}
?? (self != .host ? Env.host.estimatedDeveloperDir : nil) // on iphoneos, developer dir is not available in env. use host env typically on macOS build helper
}

Expand Down Expand Up @@ -120,7 +132,22 @@ public struct Env: Codable, Equatable, Sendable {
/// Product app bundle on host
public var estimatedProductBundlePath: [URL] {
guard let CFBundleName else { return [] }
return estimatedBuilProductsDir.map { $0.appendingPathComponent(CFBundleName).appendingPathExtension("app") }
if !estimatedBuilProductsDir.isEmpty {
return estimatedBuilProductsDir.map {
$0.appendingPathComponent(CFBundleName).appendingPathExtension("app")
}
} else {
guard let estimataedDerivedData,
let configurationBuildRandomString = estimatedConfigurationBuildRandomString ?? Env.host.estimatedConfigurationBuildRandomString,
let configurationPlatform = estimatedConfigurationPlatform else { return [] }
return [estimataedDerivedData
.appendingPathComponent(configurationBuildRandomString)
.appendingPathComponent("Build/Products")
.appendingPathComponent(configurationPlatform)
].map {
$0.appendingPathComponent(CFBundleName).appendingPathExtension("app")
}
}
}

// Environment Variables
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/FileMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final actor FileMonitor {
NSLog("%@", "🍓 target file change detected")
lastTargetFileContent = content
Task { @MainActor in
await fileChangesSubject.send(Date())
fileChangesSubject.send(Date())
}

monitor = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/TargetSwiftFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct TargetSwiftFile {
}

init(_ file: URL) throws {
content = try String(contentsOf: file)
content = try String(contentsOf: file, encoding: .utf8)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ProxyReloader/Proxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ final actor Proxy {
try await loader.load(dylibPath: tmpDylibPath)
let urls: [URL] = receivedDylibFilesSubject.value + [tmpDylibPath]
Task { @MainActor in
await receivedDylibFilesSubject.send(urls)
receivedDylibFilesSubject.send(urls)
}
} catch {
NSLog("%@", "🍓 \(#function) line \(#line) error = \(error)")
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProxyReloader/ProxyReloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class ProxyReloader: ObservableObject {
}
}

public func setShouldConnectToBuilder(_ shouldConnectToBuilder: @escaping (String, String) async -> Bool) {
public func setShouldConnectToBuilder(_ shouldConnectToBuilder: @Sendable @escaping (String, String) async -> Bool) {
Task { await proxy.setShouldConnectToBuilder(shouldConnectToBuilder) }
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ProxyReloader/RuntimePeer.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#if DEBUG || os(macOS)
import Foundation
import MultipeerConnectivity
@preconcurrency import MultipeerConnectivity

struct RuntimePeer {
struct RuntimePeer: Sendable {
/// route for sending dylib
var session: MCSession
/// the destination peerID that will load the dylib on runtime
Expand Down
Loading