Skip to content

Commit 59340e1

Browse files
authored
Merge pull request #2079 from compnerd/FHS
Bundle: add SPI for FHS style bundles for testing
2 parents ef6f96e + 4395b5f commit 59340e1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Foundation/Bundle.swift

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import CoreFoundation
1212
open class Bundle: NSObject {
1313
private var _bundle : CFBundle!
1414

15+
internal static var _supportsFHSStyle: Bool {
16+
#if DEPLOYMENT_RUNTIME_OBJC
17+
return false
18+
#else
19+
return _CFBundleSupportsFHSBundles()
20+
#endif
21+
}
22+
1523
private static var _mainBundle : Bundle = {
1624
return Bundle(cfBundle: CFBundleGetMainBundle())
1725
}()

TestFoundation/TestBundle.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ class BundlePlayground {
4343

4444
static var allApplicable: [Layout] {
4545
let layouts: [Layout] = [ .flat, .fhsInstalled, .fhsFreestanding ]
46-
47-
#if DEPLOYMENT_RUNTIME_OBJC
48-
let supportsFHS = false
49-
#else
50-
let supportsFHS = _CFBundleSupportsFHSBundles()
51-
#endif
52-
53-
if supportsFHS {
46+
47+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
48+
if Bundle._supportsFHSStyle {
5449
return layouts
5550
} else {
5651
return layouts.filter { !$0.isFHS }
5752
}
53+
#else
54+
return layouts.filter { !$0.isFHS }
55+
#endif
5856
}
5957
var isFHS: Bool {
6058
return self == .fhsInstalled || self == .fhsFreestanding

0 commit comments

Comments
 (0)