Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,54 @@ jobs:
- name: Build in debug mode
run: swift build -c debug -Xcc -Wno-elaborated-enum-base

compute_tuist_macos_build:
name: Build generated project with Compute (source) on macOS
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
os: [macos-15]
xcode-version: ["26.6"]
runs-on:
- ${{ matrix.os }}
- xcode-26.6
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Setup Xcode
uses: OpenSwiftUIProject/setup-xcode@v2
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Set up mise
uses: jdx/mise-action@v2
with:
install: false
cache: false
- name: Set up Tuist cache
run: |
source Scripts/Tuist/common.sh
tuist_ci_setup
shell: bash
- name: Generate workspace with Compute
run: Scripts/setup.sh --compute
shell: bash
- name: Build OpenAttributeGraphShims with Compute
run: |
source Scripts/Tuist/common.sh
tuist_xcodebuild \
"${RUNNER_TEMP:-/tmp}/openattributegraph-compute-tuist-macos-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}.xcresult" \
build \
-workspace OpenAttributeGraph.xcworkspace \
-scheme OpenAttributeGraphShims \
-configuration Debug \
-destination "platform=macOS" \
-derivedDataPath .build-tuist-compute \
CODE_SIGNING_ALLOWED=NO
shell: bash

compute_macos_build:
name: Build with Compute (binary) on macOS
strategy:
Expand Down
1 change: 1 addition & 0 deletions Configs/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES
TARGETED_DEVICE_FAMILY = 1,2,7
SDKROOT = auto
ONLY_ACTIVE_ARCH[config=Debug] = YES

// MARK: - C/C++ Language

Expand Down
10 changes: 8 additions & 2 deletions Example/Project.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import ProjectDescription

let openAttributeGraphModuleSearchSettings: SettingsDictionary = [
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @loader_path",
"SWIFT_INCLUDE_PATHS": "$(inherited) $(SRCROOT)/../Sources/OpenAttributeGraphCxx/include",
]

let project = Project(
name: "Example",
targets: [
Expand All @@ -12,8 +17,9 @@ let project = Project(
sources: ["Sources/**"],
dependencies: [
.sdk(name: "c++", type: .library),
.external(name: "OpenAttributeGraph"),
]
.project(target: "OpenAttributeGraph", path: ".."),
],
settings: .settings(base: openAttributeGraphModuleSearchSettings)
),
]
)
18 changes: 0 additions & 18 deletions Example/Tuist.swift

This file was deleted.

15 changes: 0 additions & 15 deletions Example/Tuist/Package.resolved

This file was deleted.

17 changes: 0 additions & 17 deletions Example/Tuist/Package.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Example/mise.toml

This file was deleted.

11 changes: 0 additions & 11 deletions Example/setup.sh

This file was deleted.

160 changes: 145 additions & 15 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,110 @@ import ProjectDescription
// MARK: - Constants

let destinations: Destinations = [.iPhone, .iPad, .mac, .appleVision]
let useComputeBackend = Environment.openattributegraphCompute.getBoolean(default: false)
let platformTargetName = "OpenAttributeGraphPlatform"
let utilitiesTargetName = "OpenAttributeGraphUtilities"
let commonConfigurations: [Configuration] = [
.debug(name: "Debug", xcconfig: "Configs/Common.xcconfig"),
.release(name: "Release", xcconfig: "Configs/Common.xcconfig"),
]
let nativeHeaderSearchSettings: SettingsDictionary = [
"HEADER_SEARCH_PATHS": "$(inherited) $(SRCROOT)/Sources/Platform/include $(SRCROOT)/Sources/Utilities/include $(SRCROOT)/Sources/OpenAttributeGraphCxx/include",
"USER_HEADER_SEARCH_PATHS": "$(inherited) $(SRCROOT)/Sources/OpenAttributeGraphCxx",
]
let cxxInteropSettings: SettingsDictionary = [
"GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) SWIFT_TESTING=1",
"OTHER_SWIFT_FLAGS": "$(inherited) -cxx-interoperability-mode=default -Xcc -std=c++20",
"SWIFT_INCLUDE_PATHS": "$(inherited) $(SRCROOT)/Sources/Platform/include $(SRCROOT)/Sources/Utilities/include $(SRCROOT)/Sources/OpenAttributeGraphCxx/include",
]
let openAttributeGraphShimsDependencies: [TargetDependency] = useComputeBackend
? [
.external(name: "Compute"),
.sdk(name: "c++", type: .library),
.sdk(name: "Demangle", type: .swiftLibrary),
]
: [
.target(name: "OpenAttributeGraph"),
]
let openAttributeGraphShimsSettings: SettingsDictionary = useComputeBackend
? [
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "$(inherited) OPENATTRIBUTEGRAPH_COMPUTE",
]
: [:]

func commonSettings(base: SettingsDictionary = [:]) -> Settings {
.settings(
base: base,
configurations: commonConfigurations,
defaultSettings: .none
)
}

// MARK: - Project

let project = Project(
name: "OpenAttributeGraph",
settings: .settings(
configurations: [
.debug(name: "Debug", xcconfig: "Configs/Common.xcconfig"),
.release(name: "Release", xcconfig: "Configs/Common.xcconfig"),
],
configurations: commonConfigurations,
defaultSettings: .none
),
targets: [
.target(
name: platformTargetName,
destinations: destinations,
product: .staticLibrary,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.Platform",
sources: ["Sources/Platform/**/*.c"],
headers: .headers(public: ["Sources/Platform/include/platform/**"]),
settings: commonSettings(base: nativeHeaderSearchSettings)
),
.target(
name: utilitiesTargetName,
destinations: destinations,
product: .staticLibrary,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.Utilities",
sources: ["Sources/Utilities/**/*.cpp"],
headers: .headers(public: ["Sources/Utilities/include/Utilities/**"]),
dependencies: [
.target(name: platformTargetName),
],
settings: commonSettings(
base: nativeHeaderSearchSettings.merging([
"PRODUCT_MODULE_NAME": "Utilities",
])
)
),
.target(
name: "OpenAttributeGraphCxx",
destinations: destinations,
product: .staticLibrary,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.Cxx",
sources: [
"Sources/OpenAttributeGraphCxx/**/*.c",
"Sources/OpenAttributeGraphCxx/**/*.cpp",
"Sources/OpenAttributeGraphCxx/**/*.mm",
],
headers: .headers(
public: [
"Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/**",
"Sources/OpenAttributeGraphCxx/include/OpenAttributeGraphCxx/**",
]
),
dependencies: [
.target(name: platformTargetName),
.target(name: utilitiesTargetName),
.sdk(name: "z", type: .library),
],
settings: commonSettings(base: nativeHeaderSearchSettings)
),
.target(
name: "OpenAttributeGraph",
destinations: destinations,
product: .framework,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph",
sources: [
"Sources/Platform/**",
"Sources/Utilities/**",
"Sources/OpenAttributeGraphCxx/**",
"Sources/OpenAttributeGraph/**",
],
headers: .headers(
project: [
"Sources/OpenAttributeGraphCxx/include/**",
"Sources/Platform/include/**",
"Sources/Utilities/include/**",
]
),
scripts: [
.pre(
path: "Scripts/Xcode/process_headers.sh",
Expand All @@ -51,11 +124,13 @@ let project = Project(
),
],
dependencies: [
.sdk(name: "z", type: .library),
.target(name: "OpenAttributeGraphCxx"),
.sdk(name: "c++", type: .library),
],
settings: .settings(
base: [
"DEFINES_MODULE": "NO",
"OTHER_LDFLAGS": "$(inherited) -force_load $(BUILT_PRODUCTS_DIR)/libOpenAttributeGraphCxx.a",
],
configurations: [
.debug(name: "Debug", xcconfig: "Configs/OpenAttributeGraph.xcconfig"),
Expand All @@ -64,5 +139,60 @@ let project = Project(
defaultSettings: .none
)
),
.target(
name: "OpenAttributeGraphShims",
destinations: destinations,
product: .staticFramework,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.Shims",
sources: ["Sources/OpenAttributeGraphShims/**"],
dependencies: openAttributeGraphShimsDependencies,
settings: commonSettings(base: openAttributeGraphShimsSettings)
),
.target(
name: "UtilitiesTests",
destinations: destinations,
product: .unitTests,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.UtilitiesTests",
sources: ["Tests/UtilitiesTests/**/*.swift"],
dependencies: [
.target(name: utilitiesTargetName),
],
settings: commonSettings(base: cxxInteropSettings)
),
.target(
name: "OpenAttributeGraphCxxTests",
destinations: destinations,
product: .unitTests,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.CxxTests",
sources: ["Tests/OpenAttributeGraphCxxTests/**/*.swift"],
dependencies: [
.target(name: "OpenAttributeGraphCxx"),
],
settings: commonSettings(base: cxxInteropSettings)
),
.target(
name: "OpenAttributeGraphShimsTests",
destinations: destinations,
product: .unitTests,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.ShimsTests",
sources: ["Tests/OpenAttributeGraphShimsTests/**/*.swift"],
dependencies: [
.target(name: "OpenAttributeGraphShims"),
],
settings: commonSettings()
),
.target(
name: "OpenAttributeGraphCompatibilityTests",
destinations: destinations,
product: .unitTests,
bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.CompatibilityTests",
sources: ["Tests/OpenAttributeGraphCompatibilityTests/**/*.swift"],
dependencies: [
.target(name: "OpenAttributeGraph"),
.external(name: "Numerics"),
.external(name: "RealModule"),
],
settings: commonSettings()
),
]
)
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,31 @@ git submodule update --init
### Xcode (via Tuist)

This project uses [Tuist](https://tuist.dev) to generate the Xcode project for framework builds.
The root workspace contains separate `OpenAttributeGraph` and `Example` projects.
The root `Package.swift` defines the public SwiftPM package, while `Tuist/Package.swift` defines
the external dependencies used only by the generated workspace.

1. Install Tuist (if not already installed):
1. Run the root setup script. It installs the pinned Tuist version from the root `mise.toml` and generates the workspace:
```shell
# via mise
mise install tuist
# or via Homebrew
brew install tuist
Scripts/setup.sh
```

2. Generate the Xcode project:
By default, `OpenAttributeGraphShims` embeds the local `OpenAttributeGraph` implementation.
To use the source Compute package instead, select the environment from `mise.compute.toml`:
```shell
tuist generate
Scripts/setup.sh --compute
```

3. Build using the generated workspace:
2. Build using the generated workspace:
```shell
xcodebuild build -workspace OpenAttributeGraph.xcworkspace -scheme OpenAttributeGraph -destination 'generic/platform=iOS Simulator'
```

To verify the Compute-backed shims generated by `--compute`:
```shell
xcodebuild build -workspace OpenAttributeGraph.xcworkspace -scheme OpenAttributeGraphShims -destination 'platform=macOS'
```

## License

See LICENSE file - MIT
Expand Down
Loading
Loading