diff --git a/CHANGELOG.md b/CHANGELOG.md index ab7b1ab8c8..e69fd5b585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ x.y.z Release notes (yyyy-MM-dd) ============================================================= ### Enhancements * Add additional `observe` methods for Objects and RealmCollections which take a `PartialKeyPath` type key path parameter. +* The release package once again contains Xcode 13 binaries for iOS. ### Fixed * `Map` did not conform to `Codable`. ([Cocoa #7418](https://github.com/realm/realm-cocoa/pull/7418), since v10.8.0) diff --git a/Jenkinsfile.releasability b/Jenkinsfile.releasability index 16bd4bd499..cb3e18491b 100644 --- a/Jenkinsfile.releasability +++ b/Jenkinsfile.releasability @@ -1,4 +1,4 @@ -xcodeVersions = ['12.2', '12.4', '12.5.1'] +xcodeVersions = ['12.2', '12.4', '12.5.1', '13.0'] platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst'] carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos'] platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst'] diff --git a/RealmSwift/BSON.swift b/RealmSwift/BSON.swift index 98432d4429..1318cc0388 100644 --- a/RealmSwift/BSON.swift +++ b/RealmSwift/BSON.swift @@ -379,18 +379,20 @@ extension MinKey: BSON { /// Return this BSON as a `Decimal128` if possible. /// This will coerce numeric cases (e.g. `.double`) into a `Decimal128` if such coercion would be lossless. public func asDecimal128() -> Decimal128? { + let str: String switch self { case let .decimal128(d): return d case let .int64(i): - return try? Decimal128(string: String(i)) + str = String(i) case let .int32(i): - return try? Decimal128(string: String(i)) + str = String(i) case let .double(d): - return try? Decimal128(string: String(d)) + str = String(d) default: return nil } + return try? Decimal128(string: str) } /// Return this BSON as a `T` if possible, otherwise nil. diff --git a/RealmSwift/Decimal128.swift b/RealmSwift/Decimal128.swift index 0c78d53f43..978eb1e4a2 100644 --- a/RealmSwift/Decimal128.swift +++ b/RealmSwift/Decimal128.swift @@ -87,12 +87,12 @@ public final class Decimal128: RLMDecimal128, Decodable { /// The mininum value for Decimal128 public static var min: Decimal128 { - __minimumDecimalNumber as! Self + unsafeDowncast(__minimumDecimalNumber, to: Self.self) } /// The maximum value for Decimal128 public static var max: Decimal128 { - __maximumDecimalNumber as! Self + unsafeDowncast(__maximumDecimalNumber, to: Self.self) } } @@ -201,7 +201,7 @@ extension Decimal128 { /// The magnitude of this Decimal128. public var magnitude: Magnitude { - self.__magnitude as! Magnitude + unsafeDowncast(self.__magnitude, to: Magnitude.self) } /// Adds two decimal128 values and produces their sum. @@ -210,7 +210,7 @@ extension Decimal128 { /// - lhs: The first Decimal128 value to add. /// - rhs: The second Decimal128 value to add. public static func + (lhs: Decimal128, rhs: Decimal128) -> Decimal128 { - lhs.decimalNumber(byAdding: rhs) as! Decimal128 + unsafeDowncast(lhs.decimalNumber(byAdding: rhs), to: Decimal128.self) } /// Subtracts one Decimal128 value from another and produces their difference. @@ -219,7 +219,7 @@ extension Decimal128 { /// - lhs: A Decimal128 value. /// - rhs: The Decimal128 value to subtract from `lhs`. public static func - (lhs: Decimal128, rhs: Decimal128) -> Decimal128 { - lhs.decimalNumber(bySubtracting: rhs) as! Decimal128 + unsafeDowncast(lhs.decimalNumber(bySubtracting: rhs), to: Decimal128.self) } /// Multiplies two Decimal128 values and produces their product. @@ -228,7 +228,7 @@ extension Decimal128 { /// - lhs: The first value to multiply. /// - rhs: The second value to multiply. public static func * (lhs: Decimal128, rhs: Decimal128) -> Decimal128 { - lhs.decimalNumberByMultiplying(by: rhs) as! Decimal128 + unsafeDowncast(lhs.decimalNumberByMultiplying(by: rhs), to: Decimal128.self) } /// Returns the quotient of dividing the first Decimal128 value by the second. @@ -237,7 +237,7 @@ extension Decimal128 { /// - lhs: The Decimal128 value to divide. /// - rhs: The Decimal128 value to divide `lhs` by. `rhs` must not be zero. public static func / (lhs: Decimal128, rhs: Decimal128) -> Decimal128 { - lhs.decimalNumberByDividing(by: rhs) as! Decimal128 + unsafeDowncast(lhs.decimalNumberByDividing(by: rhs), to: Decimal128.self) } } @@ -250,8 +250,8 @@ extension Decimal128 { /// /// - Parameter other: The Decimal128 value to calculate the distance to. /// - Returns: The distance from this value to `other`. - public func distance(to other: Decimal128) -> Stride { - other - self + public func distance(to other: Decimal128) -> Decimal128 { + unsafeDowncast(other.decimalNumber(bySubtracting: self), to: Decimal128.self) } /// Returns a Decimal128 that is offset the specified distance from this value. @@ -263,7 +263,7 @@ extension Decimal128 { /// - Parameter n: The distance to advance this Decimal128. /// - Returns: A Decimal128 that is offset from this value by `n`. public func advanced(by n: Decimal128) -> Decimal128 { - self + n + unsafeDowncast(decimalNumber(byAdding: n), to: Decimal128.self) } } diff --git a/RealmSwift/ObjectiveCSupport+BSON.swift b/RealmSwift/ObjectiveCSupport+BSON.swift index c471203ead..231cd1c432 100644 --- a/RealmSwift/ObjectiveCSupport+BSON.swift +++ b/RealmSwift/ObjectiveCSupport+BSON.swift @@ -165,7 +165,7 @@ public extension ObjectiveCSupport { return convertBson(object: value) } return .null - }.map { $0 == .null ? nil : $0 }) + }.map { (v: AnyBSON) -> AnyBSON? in v == .null ? nil : v }) case .UUID: guard let val = bson as? NSUUID else { return nil diff --git a/build.sh b/build.sh index 2c30db3951..10998bef27 100755 --- a/build.sh +++ b/build.sh @@ -649,8 +649,7 @@ case "$COMMAND" in export ASAN_OPTIONS='check_initialization_order=true:detect_stack_use_after_return=true' fi xcrun swift package resolve - find .build -name views.cpp -delete - xcrun swift test --configuration "$(echo "$CONFIGURATION" | tr "[:upper:]" "[:lower:]")" $SANITIZER + xcrun swift test -Xcc -g0 --configuration "$(echo "$CONFIGURATION" | tr "[:upper:]" "[:lower:]")" $SANITIZER exit 0 ;; diff --git a/examples/installation/build.sh b/examples/installation/build.sh index 11eecadf98..68c5823a0d 100755 --- a/examples/installation/build.sh +++ b/examples/installation/build.sh @@ -106,7 +106,7 @@ xctest() { ) elif [[ $NAME == SwiftPackageManager* ]]; then if [ -n "$sha" ]; then - sed -i '' 's@branch = "master"@branch = "'"$sha"'"@' "$DIRECTORY/$NAME.xcodeproj/project.pbxproj" + ex '+%s@branch = "master"@branch = "'"$sha"'"@' -scwq "$DIRECTORY/$NAME.xcodeproj/project.pbxproj" fi elif [[ $LANG == swift* ]]; then download_zip_if_needed swift @@ -133,7 +133,9 @@ xctest() { local scheme=(-scheme "$NAME") # Ensure that dynamic framework tests try to use the correct version of the prebuilt libraries. - sed -i '' 's@/realm-swift-latest@/realm-swift-latest/'"${REALM_XCODE_VERSION}"'@' "$DIRECTORY/$NAME.xcodeproj/project.pbxproj" + if grep '/realm-swift-latest' "$DIRECTORY/$NAME.xcodeproj/project.pbxproj"; then + ex '+%s@/realm-swift-latest@/realm-swift-latest/'"${REALM_XCODE_VERSION}"'@' -scwq "$DIRECTORY/$NAME.xcodeproj/project.pbxproj" + fi xcodebuild "${project[@]}" "${scheme[@]}" clean build "${destination[@]}" "${code_signing_flags[@]}" if [[ $PLATFORM != watchos ]]; then diff --git a/scripts/package_examples.rb b/scripts/package_examples.rb index 7d5231f6cd..6abfd74a9b 100755 --- a/scripts/package_examples.rb +++ b/scripts/package_examples.rb @@ -44,7 +44,7 @@ def replace_framework(example, path) "examples/tvos/swift", ] -xcode_versions = %w(12.2 12.4 12.5.1) +xcode_versions = %w(12.2 12.4 12.5.1 13.0) # Remove reference to Realm.xcodeproj from all example workspaces. base_examples.each do |example|