From b09fd5a75a9b1532d95c82f3fe1c6b22fc5f976e Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 23 Jun 2025 03:12:39 +0800 Subject: [PATCH 1/3] Bump to Swift 6.1 toolchain --- .github/workflows/compatibility_tests.yml | 2 +- .github/workflows/ios.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- Package.swift | 2 +- README.md | 4 ++++ 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 0e127baf..060c4b52 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -14,7 +14,7 @@ jobs: matrix: include: - os: macos-15 - xcode-version: "16.0" # Swift 6.0 + xcode-version: "16.3" # Swift 6.1 runs-on: ${{ matrix.os }} env: OPENGRAPH_WERROR: 1 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index f6cb8b81..30a80ba9 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] # Swift 6.0 + xcode-version: ["16.3"] # Swift 6.1 ios-version: ["18.0"] include: - ios-version: "18.0" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 0dac6b2b..5eafe098 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [macos-15] - xcode-version: ["16.0"] # Swift 6.0 + xcode-version: ["16.3"] # Swift 6.1 runs-on: ${{ matrix.os }} env: OPENGRAPH_WERROR: 1 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 27ddcacb..7915536c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ["6.0"] + swift_version: ["6.1"] runs-on: ubuntu-22.04 env: OPENGRAPH_WERROR: 1 diff --git a/Package.swift b/Package.swift index 34561526..02a70812 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.1 // The swift-tools-version declares the minimum version of Swift required to build this package. import Foundation diff --git a/README.md b/README.md index 3bf306df..1db2f5ae 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ The project is for the following purposes: Currently, this project is in early development. +## Build + +The current suggested toolchain to build the project is Swift 6.1 / Xcode 16.3. + ## Credits OpenGraph_SPI's Data, Graph, Vector and more is modified based on [Compute](https://github.com/jcmosc/Compute)'s implementations. From 0d44ba0be7cb0919b5aebdcad3bed7f7414071a6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 24 Jun 2025 00:27:03 +0800 Subject: [PATCH 2/3] Remove OG_COUNTED_BY usage --- Sources/OpenGraph_SPI/include/OGGraph.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/OpenGraph_SPI/include/OGGraph.h b/Sources/OpenGraph_SPI/include/OGGraph.h index b8f2a029..396de253 100644 --- a/Sources/OpenGraph_SPI/include/OGGraph.h +++ b/Sources/OpenGraph_SPI/include/OGGraph.h @@ -103,9 +103,10 @@ OG_EXPORT OG_REFINED_FOR_SWIFT void OGGraphSetNeedsUpdate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.setNeedsUpdate(self:)); +// TODO: Add OG_COUNTED_BY later https://github.com/OpenSwiftUIProject/OpenGraph/issues/130 OG_EXPORT OG_REFINED_FOR_SWIFT -bool OGGraphAnyInputsChanged(const OGAttribute *inputs OG_COUNTED_BY(count), size_t count); +bool OGGraphAnyInputsChanged(const OGAttribute *inputs, size_t count); OG_EXTERN_C_END From 30a9319b666220cf912577c96a56168b5db7f0e0 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 24 Jun 2025 00:58:06 +0800 Subject: [PATCH 3/3] Fix OG_COUNTED_BY issue on Linux and macOS --- Package.resolved | 4 ++-- Sources/OpenGraph_SPI/include/OGBase.h | 6 +++++- Sources/OpenGraph_SPI/include/OGGraph.h | 10 +++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index b6ea544c..546f2ef5 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "ad1e5434846a92c0dac225a6a8db318f8511f8c5743706cc40109d7f9ae5a10e", + "originHash" : "50661037ace32d27f5b63e569f8fa2ccff6d3226fa694da9fc389c49efd15ddd", "pins" : [ { "identity" : "darwinprivateframeworks", @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "d115c29b7468940969b0c2f5cb0d612a28563a02" + "revision" : "7be91d10c9151add127dbd2e92595553d084efdb" } }, { diff --git a/Sources/OpenGraph_SPI/include/OGBase.h b/Sources/OpenGraph_SPI/include/OGBase.h index 65c157b3..f77340a2 100644 --- a/Sources/OpenGraph_SPI/include/OGBase.h +++ b/Sources/OpenGraph_SPI/include/OGBase.h @@ -43,6 +43,10 @@ #define OG_CONSTEXPR #endif +#if __has_include() // Fix conflict define issue of the SDK +#include +#define OG_COUNTED_BY(N) __counted_by(N) +#else #if !defined(__counted_by) #if __has_attribute(__counted_by__) #define __counted_by(N) __attribute__((__counted_by__(N))) @@ -50,8 +54,8 @@ #define __counted_by(N) #endif #endif - #define OG_COUNTED_BY(N) __counted_by(N) +#endif #include "OGSwiftSupport.h" #include "OGTargetConditionals.h" diff --git a/Sources/OpenGraph_SPI/include/OGGraph.h b/Sources/OpenGraph_SPI/include/OGGraph.h index 396de253..909c384f 100644 --- a/Sources/OpenGraph_SPI/include/OGGraph.h +++ b/Sources/OpenGraph_SPI/include/OGGraph.h @@ -103,10 +103,18 @@ OG_EXPORT OG_REFINED_FOR_SWIFT void OGGraphSetNeedsUpdate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.setNeedsUpdate(self:)); -// TODO: Add OG_COUNTED_BY later https://github.com/OpenSwiftUIProject/OpenGraph/issues/130 +#if OG_TARGET_OS_DARWIN +OG_EXPORT +OG_REFINED_FOR_SWIFT +bool OGGraphAnyInputsChanged(const OGAttribute *inputs OG_COUNTED_BY(count), size_t count); +#else +// __counted_by__ is supported with Swift 6.1+ toolchain's clang on Linux. +// But it required the count to be declared first which is not required on Apple clang. +// See https://github.com/OpenSwiftUIProject/OpenGraph/issues/130 OG_EXPORT OG_REFINED_FOR_SWIFT bool OGGraphAnyInputsChanged(const OGAttribute *inputs, size_t count); +#endif OG_EXTERN_C_END