From a44d8e8a04bd8d840f01b8ca0c39fd9c7b814db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=87=E1=85=A7=E1=86=BC=E1=84=8E?= =?UTF-8?q?=E1=85=A1=E1=86=AB?= Date: Thu, 14 Aug 2025 12:32:41 +0900 Subject: [PATCH 1/2] Add removeAll() method to WeakMapTable --- Sources/WeakMapTable/WeakMapTable.swift | 7 +++++++ Tests/WeakMapTableTests/WeakMapTableTests.swift | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Sources/WeakMapTable/WeakMapTable.swift b/Sources/WeakMapTable/WeakMapTable.swift index b5e74c1..e996334 100644 --- a/Sources/WeakMapTable/WeakMapTable.swift +++ b/Sources/WeakMapTable/WeakMapTable.swift @@ -68,6 +68,13 @@ final public class WeakMapTable where Key: AnyObject { } } + public func removeAll() { + self.lock.lock() + defer { + self.lock.unlock() + } + self.dictionary.removeAll() + } // MARK: Getting and Setting Values without Locking diff --git a/Tests/WeakMapTableTests/WeakMapTableTests.swift b/Tests/WeakMapTableTests/WeakMapTableTests.swift index 344ad89..e1cb70e 100644 --- a/Tests/WeakMapTableTests/WeakMapTableTests.swift +++ b/Tests/WeakMapTableTests/WeakMapTableTests.swift @@ -81,6 +81,23 @@ final class WeakMapTableTests: XCTestCase { XCTAssertNil(weakKey) XCTAssertNil(weakValue) } + + func testRemoveAll() { + let map = WeakMapTable() + let key = KeyObject() + weak var weakValue: ValueObject? + + _ = { + let value = ValueObject() + map.setValue(value, forKey: key) + weakValue = value + + map.removeAll() + }() + + XCTAssertNil(map.value(forKey: key)) + XCTAssertNil(weakValue) + } } private final class KeyObject { From c8d4ae2005dafee3735463a8621deb32cdee9ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=B5=E1=84=87=E1=85=A7=E1=86=BC=E1=84=8E?= =?UTF-8?q?=E1=85=A1=E1=86=AB?= Date: Fri, 15 Aug 2025 03:29:16 +0900 Subject: [PATCH 2/2] Migrate to Apple Silicon runner and update Xcode version - Updated CI to run on macOS 15 ARM64 (Apple Silicon) runners - Changed default simulator devices to ARM-compatible ones - Updated Xcode to 16.4 for latest SDK support --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51e9b88..f3d5f66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,24 +8,24 @@ on: jobs: test: - runs-on: macOS-latest + runs-on: macos-15-arm64 # Apple Silicon strategy: matrix: env: - sdk: iphonesimulator - destination: platform=iOS Simulator,name=iPhone 12 Pro,OS=latest + destination: platform=iOS Simulator,name=iPhone 15 Pro,OS=latest - sdk: macosx - destination: arch=x86_64 + destination: arch=arm64 - sdk: appletvsimulator - destination: platform=tvOS Simulator,name=Apple TV,OS=latest + destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Select Xcode 12.4 - run: sudo xcode-select -s /Applications/Xcode_12.4.app + - name: Select Xcode 16.4 + run: sudo xcode-select -s /Applications/Xcode_16.4.app - name: Generate Xcode Project run: swift package generate-xcodeproj --enable-code-coverage