Skip to content

Commit

Permalink
Revert "Fix building for visionOS, iOS, & tvOS with xcodebuild integr…
Browse files Browse the repository at this point in the history
…ation (#57)"

This reverts commit 3cebee7.
  • Loading branch information
stackotter authored Jan 17, 2025
1 parent b1c7bff commit 4a4b9d4
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 493 deletions.
24 changes: 2 additions & 22 deletions Sources/swift-bundler/Bundler/DarwinBundler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ enum DarwinBundler: Bundler {
return .failure(.missingDarwinPlatformVersion(context.platform))
}

// Whether a universal application binary (arm64 and x86_64) will be created.
let universal = command.arguments.universal || command.arguments.architectures.count > 1

// Whether or not we are building with xcodebuild instead of swiftpm.
let isUsingXcodeBuild = XcodeBuildManager.isUsingXcodeBuild(for: command)

return .success(
Context(
isXcodeBuild: command.builtWithXcode || isUsingXcodeBuild,
isXcodeBuild: command.builtWithXcode,
universal: universal,
standAlone: command.arguments.standAlone,
platform: applePlatform,
Expand Down Expand Up @@ -147,7 +142,6 @@ enum DarwinBundler: Bundler {
}

let sign: () -> Result<Void, DarwinBundlerError> = {
// if credentials are supplied for codesigning, use them.
if let codeSigningContext = additionalContext.codeSigningContext {
return CodeSigner.signAppBundle(
bundle: appBundle,
Expand All @@ -157,20 +151,7 @@ enum DarwinBundler: Bundler {
return .failedToCodesign(error)
}
} else {

if context.platform != .macOS {
// otherwise codesign using an adhoc signature only on embedded.
return CodeSigner.signAppBundle(
bundle: appBundle,
identityId: "-",
entitlements: nil
).mapError { error in
return .failedToCodesign(error)
}
} else {
// on macOS we can skip codesigning for running locally.
return .success()
}
return .success()
}
}

Expand Down Expand Up @@ -250,7 +231,6 @@ enum DarwinBundler: Bundler {
at source: URL, to destination: URL
) -> Result<Void, DarwinBundlerError> {
log.info("Copying executable")

do {
try FileManager.default.copyItem(at: source, to: destination)
return .success()
Expand Down
14 changes: 3 additions & 11 deletions Sources/swift-bundler/Bundler/DynamicLibraryBundler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ enum DynamicLibraryBundler {
log.info("Copying dynamic library '\(name)'")

// Copy and rename the library
let outputLibrary: URL
if name.prefix(3).contains("lib") {
// do not add a 'lib' prefix to the dynamic library if it's already prefixed with 'lib'.
outputLibrary = outputDirectory.appendingPathComponent("\(name).dylib")
} else {
// add a 'lib' prefix to the dynamic library if it's not already prefixed with 'lib'.
outputLibrary = outputDirectory.appendingPathComponent("lib\(name).dylib")
}

let outputLibrary = outputDirectory.appendingPathComponent("lib\(name).dylib")
do {
try FileManager.default.copyItem(
at: library,
Expand Down Expand Up @@ -287,8 +279,8 @@ enum DynamicLibraryBundler {
contents
.filter { $0.pathExtension == "dylib" }
.map { library in
let name = library.deletingPathExtension().lastPathComponent
return (name: name, file: library)
let name = library.deletingPathExtension().lastPathComponent.dropFirst(3)
return (name: String(name), file: library)
}
}

Expand Down

This file was deleted.

57 changes: 0 additions & 57 deletions Sources/swift-bundler/Bundler/SimulatorManager/OSVersion.swift

This file was deleted.

26 changes: 0 additions & 26 deletions Sources/swift-bundler/Bundler/SimulatorManager/SimUtils.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,6 @@ enum SimulatorManager {
}
}

/// Lists all available simulators per OS.
/// - Parameter platform: Filters the simulators by platform.
/// - Returns: A list of available simulators matching the platform, or a failure if an error occurs.
static func listAvailableOSSimulators(
for platform: Platform
) -> Result<
[OSSimulator], SimulatorManagerError
> {
return Process.create(
"/usr/bin/xcrun",
arguments: [
"simctl", "list", "devices", "available", "--json",
]
).getOutputData().mapError { error in
return .failedToRunSimCTL(error)
}.andThen { data in
JSONDecoder().decode(SimulatorList.self, from: data)
.mapError(SimulatorManagerError.failedToDecodeJSON)
}.map { simulatorList in
var osSimulators: [OSSimulator] = []
for (runtime, platformSimulators) in simulatorList.devices {
switch platform {
case .iOS, .iOSSimulator:
if runtime.hasPrefix("com.apple.CoreSimulator.SimRuntime.iOS") {
if !platformSimulators.isEmpty {
let version = SimUtils.getOSVersionForRuntime(runtime)
osSimulators.append(.init(OS: version, simulators: platformSimulators))
}
}
case .visionOS, .visionOSSimulator:
if runtime.hasPrefix("com.apple.CoreSimulator.SimRuntime.xrOS") {
if !platformSimulators.isEmpty {
let version = SimUtils.getOSVersionForRuntime(runtime)
osSimulators.append(.init(OS: version, simulators: platformSimulators))
}
}
case .tvOS, .tvOSSimulator:
if runtime.hasPrefix("com.apple.CoreSimulator.SimRuntime.tvOS") {
if !platformSimulators.isEmpty {
let version = SimUtils.getOSVersionForRuntime(runtime)
osSimulators.append(.init(OS: version, simulators: platformSimulators))
}
}
default:
break
}
}

return osSimulators
}
}

/// Boots a simulator. If it's already running, nothing is done.
/// - Parameter id: The name or id of the simulator to start.
/// - Returns: A failure if an error occurs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,7 @@ enum SwiftPackageManager {
product: product,
buildContext: buildContext
).andThen { arguments in

let pipe = Pipe()
let process: Process

var xcbeautify: Process?
let xcbeautifyCmd = Process.locate("xcbeautify")
switch xcbeautifyCmd
{
case .success(let cmd):
xcbeautify = Process.create(
cmd,
arguments: [
"--disable-logging"
],
directory: buildContext.packageDirectory,
runSilentlyWhenNotVerbose: false
)
case .failure(_):
#if os(macOS)
let helpMsg = "brew install xcbeautify"
#else
let helpMsg = "mint install cpisciotta/xcbeautify"
#endif
log.warning("""
xcbeautify was not found, for pretty build output please intall it with:\n
\(helpMsg)
""")
}

process = Process.create(
let process = Process.create(
"swift",
arguments: arguments,
directory: buildContext.packageDirectory,
Expand All @@ -136,18 +107,6 @@ enum SwiftPackageManager {
])
}

// pipe swiftpm output to xcbeautify.
if let xcbeautify = xcbeautify {
process.standardOutput = pipe
xcbeautify.standardInput = pipe
}

do {
try xcbeautify?.run()
} catch {
log.warning("xcbeautify error: \(error)")
}

return process.runAndWait().mapError { error in
.failedToRunSwiftBuild(
command: "swift \(arguments.joined(separator: " "))",
Expand Down

This file was deleted.

Loading

0 comments on commit 4a4b9d4

Please sign in to comment.