Skip to content

Bundle: add SPI for FHS style bundles for testing #2079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2019
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
8 changes: 8 additions & 0 deletions Foundation/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import CoreFoundation
open class Bundle: NSObject {
private var _bundle : CFBundle!

internal static var _supportsFHSStyle: Bool {
#if DEPLOYMENT_RUNTIME_OBJC
return false
#else
return _CFBundleSupportsFHSBundles()
#endif
}

private static var _mainBundle : Bundle = {
return Bundle(cfBundle: CFBundleGetMainBundle())
}()
Expand Down
14 changes: 6 additions & 8 deletions TestFoundation/TestBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ class BundlePlayground {

static var allApplicable: [Layout] {
let layouts: [Layout] = [ .flat, .fhsInstalled, .fhsFreestanding ]

#if DEPLOYMENT_RUNTIME_OBJC
let supportsFHS = false
#else
let supportsFHS = _CFBundleSupportsFHSBundles()
#endif

if supportsFHS {

#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
if Bundle._supportsFHSStyle {
return layouts
} else {
return layouts.filter { !$0.isFHS }
}
#else
return layouts.filter { !$0.isFHS }
#endif
}
var isFHS: Bool {
return self == .fhsInstalled || self == .fhsFreestanding
Expand Down