Skip to content
Merged
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
7 changes: 0 additions & 7 deletions Sources/Foundation/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ open class Bundle: NSObject {
self.init(path: url.path)
}

#if os(Windows)
@available(Windows, deprecated, message: "Not yet implemented.")
public init(for aClass: AnyClass) {
NSUnimplemented()
}
#else
public init(for aClass: AnyClass) {
let pointerInImageOfClass = _getTypeContextDescriptor(of: aClass)
guard let imagePath = _CFBundleCopyLoadedImagePathForAddress(pointerInImageOfClass)?._swiftObject else {
Expand All @@ -138,7 +132,6 @@ open class Bundle: NSObject {
let bundle = _CFBundleCreateWithExecutableURLIfMightBeBundle(kCFAllocatorSystemDefault, url._cfObject)?.takeRetainedValue()
_bundleStorage = bundle ?? CFBundleGetMainBundle()
}
#endif

public init?(identifier: String) {
super.init()
Expand Down
9 changes: 6 additions & 3 deletions Tests/Foundation/Tests/TestBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,11 @@ class TestBundle : XCTestCase {
let maybeURL = Bundle.main.executableURL
XCTAssertNotNil(maybeURL)
guard let url = maybeURL else { return }

XCTAssertEqual(url.path, ProcessInfo.processInfo._processPath)

let path = url.withUnsafeFileSystemRepresentation {
String(cString: $0!)
}
XCTAssertEqual(path, ProcessInfo.processInfo._processPath)
}
#endif

Expand All @@ -585,7 +588,7 @@ class TestBundle : XCTestCase {
("test_bundleForClass", testExpectedToFailOnWindows(test_bundleForClass, "Functionality not yet implemented on Windows. SR-XXXX")),
]

#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT && !os(Windows)
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
tests.append(contentsOf: [
("test_mainBundleExecutableURL", test_mainBundleExecutableURL),
("test_bundleReverseBundleLookup", test_bundleReverseBundleLookup),
Expand Down