Skip to content

Commit 862fa16

Browse files
committed
Adding functions for tidepool study
1 parent da34ae4 commit 862fa16

5 files changed

Lines changed: 120420 additions & 6 deletions

File tree

Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "LoopAlgorithmToPython",
8+
defaultLocalization: "no",
89
platforms: [
910
.macOS(.v13),
1011
.iOS(.v15),
@@ -30,6 +31,9 @@ let package = Package(
3031
),
3132
.testTarget(
3233
name: "LoopAlgorithmToPythonTests",
33-
dependencies: ["LoopAlgorithmToPython"]),
34+
dependencies: ["LoopAlgorithmToPython"],
35+
resources: [
36+
.process("TestData")
37+
])
3438
]
3539
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import class Foundation.Bundle
2+
import class Foundation.ProcessInfo
3+
import struct Foundation.URL
4+
5+
private class BundleFinder {}
6+
7+
extension Foundation.Bundle {
8+
/// Returns the resource bundle associated with the current Swift module.
9+
static let module: Bundle = {
10+
let bundleName = "LoopAlgorithmToPython_LoopAlgorithmToPythonTests"
11+
12+
let overrides: [URL]
13+
#if DEBUG
14+
// The 'PACKAGE_RESOURCE_BUNDLE_PATH' name is preferred since the expected value is a path. The
15+
// check for 'PACKAGE_RESOURCE_BUNDLE_URL' will be removed when all clients have switched over.
16+
// This removal is tracked by rdar://107766372.
17+
if let override = ProcessInfo.processInfo.environment["PACKAGE_RESOURCE_BUNDLE_PATH"]
18+
?? ProcessInfo.processInfo.environment["PACKAGE_RESOURCE_BUNDLE_URL"] {
19+
overrides = [URL(fileURLWithPath: override)]
20+
} else {
21+
overrides = []
22+
}
23+
#else
24+
overrides = []
25+
#endif
26+
27+
print("BUNDLEFILE")
28+
29+
let candidates = overrides + [
30+
// Bundle should be present here when the package is linked into an App.
31+
Bundle.main.resourceURL,
32+
33+
// Bundle should be present here when the package is linked into a framework.
34+
Bundle(for: BundleFinder.self).resourceURL,
35+
36+
// For command-line tools.
37+
Bundle.main.bundleURL,
38+
]
39+
40+
for candidate in candidates {
41+
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
42+
print(bundlePath)
43+
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
44+
print("BUNDLE:", bundle)
45+
return bundle
46+
}
47+
}
48+
fatalError("unable to find bundle named LoopAlgorithmToPython_LoopAlgorithmToPythonTests")
49+
}()
50+
}

0 commit comments

Comments
 (0)