Skip to content
Merged
19 changes: 18 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
tests:
name: Test
name: Test (SwiftPM)
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_swift_versions: '["nightly-main"]'
Expand All @@ -18,6 +18,23 @@ jobs:
macos_xcode_versions: '["16.3"]'
macos_versions: '["sequoia"]'

cmake_build:
name: Build (CMake)
runs-on: ubuntu-latest
container: swiftlang/swift:nightly-main-noble
steps:
- name: Checkout Sources
uses: actions/checkout@v1
- name: Install Dependencies
shell: bash
run: apt update && apt install -y cmake ninja-build
- name: Configure Project
shell: bash
run: cmake -G 'Ninja' -B build -S . -DCMAKE_C_COMPILER=clang -DCMAKE_Swift_COMPILER=swiftc -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=YES
- name: Build Project
shell: bash
run: cmake --build build

soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ else()
message(STATUS "_SwiftFoundationICU_SourceDIR not provided, checking out local copy of swift-foundation-icu")
FetchContent_Declare(SwiftFoundationICU
GIT_REPOSITORY https://github.com/apple/swift-foundation-icu.git
GIT_TAG 0.0.9)
GIT_TAG main)
endif()

if (_SwiftCollections_SourceDIR)
Expand Down
19 changes: 1 addition & 18 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ let package = Package(
swiftSettings: [
.enableExperimentalFeature("VariadicGenerics"),
.enableExperimentalFeature("LifetimeDependence"),
.enableExperimentalFeature(
"InoutLifetimeDependence",
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
),
.enableExperimentalFeature(
"LifetimeDependenceMutableAccessors",
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
),
.enableExperimentalFeature("AddressableTypes"),
.enableExperimentalFeature("AllowUnsafeAttribute"),
.enableExperimentalFeature("BuiltinModule"),
Expand All @@ -167,16 +159,7 @@ let package = Package(
resources: [
.copy("Resources")
],
swiftSettings: [
.enableExperimentalFeature(
"InoutLifetimeDependence",
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
),
.enableExperimentalFeature(
"LifetimeDependenceMutableAccessors",
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
),
] + availabilityMacros + featureSettings + testOnlySwiftSettings
swiftSettings: availabilityMacros + featureSettings + testOnlySwiftSettings
),

// FoundationInternationalization
Expand Down
4 changes: 2 additions & 2 deletions Proposals/0028-locale-region-category.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Authors: [Tina Liu](https://github.com/itingliu)
* Review Manager: [Jeremy Schonfeld](https://github.com/jmschonfeld)
* Implementation: [https://github.com/swiftlang/swift-foundation/pull/1253]()
* Status: **Review: Jun 11, 2025...Jun 18, 2025**
* Reviews: [Pitch](https://forums.swift.org/t/pitch-category-support-for-locale-region/79240)
* Status: **Accepted**
* Reviews: [Pitch](https://forums.swift.org/t/pitch-category-support-for-locale-region/79240), [Review](https://forums.swift.org/t/review-sf-0028-locale-region-category/80415)

## Introduction

Expand Down
4 changes: 1 addition & 3 deletions Sources/FoundationEssentials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ endif()

if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android)
target_compile_options(FoundationEssentials PRIVATE
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -Xcc -Xfrontend -D_GNU_SOURCE>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend InoutLifetimeDependence>"
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend LifetimeDependenceMutableAccessors>")
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -Xcc -Xfrontend -D_GNU_SOURCE>")
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
endif()

Expand Down
11 changes: 0 additions & 11 deletions Sources/FoundationEssentials/Data/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2203,11 +2203,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
return try _representation.withUnsafeBytes(body)
}

#if compiler(>=6.2) && $LifetimeDependence
@available(FoundationSpan 6.2, *)
#if FOUNDATION_FRAMEWORK
@_disfavoredOverload
#endif // FOUNDATION_FRAMEWORK
public var bytes: RawSpan {
@lifetime(borrow self)
borrowing get {
Expand Down Expand Up @@ -2242,9 +2238,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
return _overrideLifetime(span, borrowing: self)
}
}
#endif

#if compiler(>=5.9) && $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
@available(FoundationSpan 6.2, *)
public var mutableBytes: MutableRawSpan {
@lifetime(&self)
Expand Down Expand Up @@ -2304,7 +2298,6 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
#endif
}
}
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors

@_alwaysEmitIntoClient
public func withContiguousStorageIfAvailable<ResultType>(_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws -> ResultType) rethrows -> ResultType? {
Expand Down Expand Up @@ -2979,7 +2972,6 @@ extension Data : Codable {
}

// TODO: remove once _overrideLifetime is public in the standard library
#if compiler(>=6.2) && $LifetimeDependence
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
/// a value identical to `dependent` with a lifetime dependency on the caller's
/// borrow scope of the `source` argument.
Expand Down Expand Up @@ -3011,9 +3003,7 @@ internal func _overrideLifetime<
) -> T {
dependent
}
#endif

#if compiler(>=5.9) && $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
/// Unsafely discard any lifetime dependency on the `dependent` argument.
/// Return a value identical to `dependent` with a lifetime dependency
/// on the caller's exclusive borrow scope of the `source` argument.
Expand All @@ -3030,4 +3020,3 @@ internal func _overrideLifetime<
) -> T {
dependent
}
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16 changes: 16 additions & 0 deletions Sources/FoundationEssentials/String/String+IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ dynamic public func _cfMakeStringFromBytes(_ bytes: UnsafeBufferPointer<UInt8>,
// Provide swift-corelibs-foundation with an entry point to convert some bytes into a String
return nil
}

dynamic package func _icuMakeStringFromBytes(_ bytes: UnsafeBufferPointer<UInt8>, encoding: String.Encoding) -> String? {
// Concrete implementation is provided by FoundationInternationalization.
return nil
}
#endif

@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
Expand Down Expand Up @@ -184,6 +189,17 @@ extension String {
}
}
self = bytes.withContiguousStorageIfAvailable(buildString) ?? Array(bytes).withUnsafeBufferPointer(buildString)
case .japaneseEUC:
// Here we catch encodings that are supported by Foundation Framework
// but are not supported by corelibs-foundation.
// We delegate conversion to ICU.
guard let string = (
bytes.withContiguousStorageIfAvailable({ _icuMakeStringFromBytes($0, encoding: encoding) }) ??
Array(bytes).withUnsafeBufferPointer({ _icuMakeStringFromBytes($0, encoding: encoding) })
) else {
return nil
}
self = string
#endif
default:
#if FOUNDATION_FRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ dynamic public func _cfStringEncodingConvert(string: String, using encoding: UIn
// Dynamically replaced by swift-corelibs-foundation to implement encodings that we do not have Swift replacements for, yet
return nil
}

dynamic package func _icuStringEncodingConvert(string: String, using encoding: String.Encoding, allowLossyConversion: Bool) -> Data? {
// Concrete implementation is provided by FoundationInternationalization.
return nil
}
#endif

@available(FoundationPreview 0.4, *)
Expand Down Expand Up @@ -249,6 +254,11 @@ extension String {
buffer.appendElement(value)
}
}
case .japaneseEUC:
// Here we catch encodings that are supported by Foundation Framework
// but are not supported by corelibs-foundation.
// We delegate conversion to ICU.
return _icuStringEncodingConvert(string: self, using: encoding, allowLossyConversion: allowLossyConversion)
#endif
default:
#if FOUNDATION_FRAMEWORK
Expand Down
Loading