Skip to content

Commit 5dfdf69

Browse files
committed
Fix for explicit module build
Disambiguate the modf call to the C version and add a header search path.
1 parent 2660c1f commit 5dfdf69

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ let SwiftFirebase =
219219
cxxSettings: [
220220
.define("INTERNAL_EXPERIMENTAL"),
221221
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
222+
.headerSearchPath("../../third_party/firebase-development/usr/include"),
222223
],
223224
swiftSettings: [
224225
.interoperabilityMode(.Cxx),

Sources/FirebaseFirestore/Timestamp+Swift.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ extension Timestamp: Codable {
5050
extension Date {
5151
internal func firestoreTimestamp() -> Timestamp {
5252
var secondsDouble: Double = 0.0
53-
var fraction = modf(timeIntervalSince1970, &secondsDouble)
53+
#if canImport(Darwin.C)
54+
var fraction = Darwin.C.modf(timeIntervalSince1970, &secondsDouble)
55+
#elseif canImport(SwiftGlibc)
56+
var fraction = SwiftGlibc.modf(timeIntervalSince1970, &secondsDouble)
57+
#elseif canImport(ucrt)
58+
var fraction = ucrt.modf(timeIntervalSince1970, &secondsDouble)
59+
#elseif canImport(SwiftAndroid)
60+
var fraction = SwiftAndroid.modf(timeIntervalSince1970, &secondsDouble)
61+
#else
62+
#error("Unsupported platform")
63+
#endif
5464

5565
// Re-implementation of https://github.com/firebase/firebase-ios-sdk/blob/master/Firestore/Source/API/FIRTimestamp.m#L50
5666
if (fraction < 0) {

0 commit comments

Comments
 (0)