Skip to content

Commit 2a5d82a

Browse files
authored
Add Xcode project support with xcconfig-based build settings (#211)
1 parent 379451e commit 2a5d82a

15 files changed

Lines changed: 893 additions & 100 deletions

.github/workflows/compatibility_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
- name: Run tests against Apple's AttributeGraph on macOS via Xcode
4343
run: |
4444
xcodebuild test \
45+
-workspace .swiftpm/xcode/package.xcworkspace \
4546
-scheme OpenAttributeGraph-Package \
4647
-sdk macosx \
4748
-destination "platform=macOS" \

.github/workflows/ios.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
- name: Build in debug mode on iOS
4242
run: |
4343
xcodebuild build \
44+
-workspace .swiftpm/xcode/package.xcworkspace \
4445
-scheme OpenAttributeGraph-Package \
4546
-configuration Debug \
4647
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}" \
@@ -51,6 +52,7 @@ jobs:
5152
- name: Build and run tests in debug mode with coverage on iOS Simulator
5253
run: |
5354
xcodebuild test \
55+
-workspace .swiftpm/xcode/package.xcworkspace \
5456
-scheme OpenAttributeGraph-Package \
5557
-configuration Debug \
5658
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}" \

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
release:
10+
name: Build and Publish Release
11+
runs-on: macos-15
12+
permissions:
13+
contents: write
14+
env:
15+
GH_TOKEN: ${{ github.token }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Setup Xcode
21+
uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main
22+
with:
23+
xcode-version: "16.4"
24+
- name: Checkout Swift headers
25+
uses: ./.github/actions/checkout-swift-headers
26+
- name: Build XCFramework
27+
run: ./Scripts/build_xcframework.sh
28+
- name: Compute Checksum
29+
id: checksum
30+
run: |
31+
echo "checksum=$(swift package compute-checksum .build/Xcode/Frameworks/OpenAttributeGraph.xcframework.zip)" >> $GITHUB_OUTPUT
32+
- name: Collect Build Info
33+
id: build_info
34+
run: |
35+
echo "xcode_version=$(xcodebuild -version | head -1)" >> $GITHUB_OUTPUT
36+
echo "swift_version=$(swift --version 2>&1 | head -1)" >> $GITHUB_OUTPUT
37+
- name: Generate Release Notes
38+
id: release_notes
39+
run: |
40+
TAG_NAME="${GITHUB_REF#refs/tags/}"
41+
# Find the previous tag
42+
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sed -n '2p')
43+
REPO="${GITHUB_REPOSITORY}"
44+
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/OpenAttributeGraph.xcframework.zip"
45+
46+
{
47+
echo 'body<<RELEASE_NOTES_EOF'
48+
49+
# Binary Target section first
50+
echo "## Binary Target"
51+
echo ""
52+
echo '```swift'
53+
echo '.binaryTarget('
54+
echo ' name: "OpenAttributeGraph",'
55+
echo " url: \"${DOWNLOAD_URL}\","
56+
echo " checksum: \"${{ steps.checksum.outputs.checksum }}\""
57+
echo ')'
58+
echo '```'
59+
echo ""
60+
61+
# Build info
62+
echo "## Build Info"
63+
echo ""
64+
echo "- ${{ steps.build_info.outputs.xcode_version }}"
65+
echo "- ${{ steps.build_info.outputs.swift_version }}"
66+
echo ""
67+
68+
# What's Changed section
69+
if [ -n "$PREV_TAG" ]; then
70+
echo "## What's Changed"
71+
git log "${PREV_TAG}..HEAD" --pretty=format:"* %s by @%an in ${GITHUB_SERVER_URL}/${REPO}/commit/%H" --no-merges
72+
echo ""
73+
echo ""
74+
echo "**Full Changelog**: ${GITHUB_SERVER_URL}/${REPO}/compare/${PREV_TAG}...${TAG_NAME}"
75+
else
76+
echo "## What's Changed"
77+
git log --pretty=format:"* %s by @%an in ${GITHUB_SERVER_URL}/${REPO}/commit/%H" --no-merges
78+
echo ""
79+
fi
80+
81+
echo 'RELEASE_NOTES_EOF'
82+
} >> "$GITHUB_OUTPUT"
83+
- name: Create Release
84+
uses: ncipollo/release-action@v1
85+
with:
86+
body: ${{ steps.release_notes.outputs.body }}
87+
allowUpdates: true
88+
artifacts: ".build/Xcode/Frameworks/OpenAttributeGraph.xcframework.zip"
89+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/xcframework.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: XCFramework
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build_xcframework:
11+
name: Build XCFramework
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [macos-15]
16+
xcode-version: ["16.4"] # Swift 6.1.2
17+
runs-on: ${{ matrix.os }}
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Setup Xcode
23+
uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main
24+
with:
25+
xcode-version: ${{ matrix.xcode-version }}
26+
- name: Checkout Swift headers
27+
uses: ./.github/actions/checkout-swift-headers
28+
- name: Build XCFramework
29+
run: ./Scripts/build_xcframework.sh
30+
- name: Upload XCFramework
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: OpenAttributeGraph.xcframework.zip
34+
path: .build/Xcode/Frameworks/OpenAttributeGraph.xcframework.zip

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Configs/Common.xcconfig

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Common.xcconfig
2+
// Shared build settings for OpenAttributeGraph
3+
4+
// MARK: - Deployment Targets
5+
6+
MACOSX_DEPLOYMENT_TARGET = 15.0
7+
IPHONEOS_DEPLOYMENT_TARGET = 18.0
8+
XROS_DEPLOYMENT_TARGET = 2.0
9+
10+
// MARK: - Platform
11+
12+
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx xros xrsimulator
13+
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES
14+
TARGETED_DEVICE_FAMILY = 1,2,7
15+
SDKROOT = auto
16+
17+
// MARK: - C/C++ Language
18+
19+
GCC_C_LANGUAGE_STANDARD = gnu17
20+
CLANG_CXX_LANGUAGE_STANDARD = gnu++20
21+
CLANG_ENABLE_MODULES = YES
22+
23+
// MARK: - C/C++ Flags
24+
25+
// -ftyped-memory-operations: Rewrite malloc() to malloc_type_malloc() for type-isolated allocation buckets (xzone malloc)
26+
// -ftyped-cxx-new-delete: Rewrite operator new/delete to typed variants
27+
OTHER_CFLAGS = $(inherited) -ftyped-memory-operations
28+
OTHER_CPLUSPLUSFLAGS = $(inherited) -ftyped-memory-operations -ftyped-cxx-new-delete
29+
30+
// MARK: - C/C++ Preprocessor
31+
32+
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) OPENATTRIBUTEGRAPH=1
33+
GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = $(inherited) OPENATTRIBUTEGRAPH=1 DEBUG=1
34+
35+
// MARK: - Header Search Paths
36+
37+
SYSTEM_HEADER_SEARCH_PATHS = $(inherited) Checkouts/swift/include Checkouts/swift/stdlib/include Checkouts/swift/stdlib/public/SwiftShims
38+
39+
// MARK: - Swift
40+
41+
SWIFT_VERSION = 5.0
42+
OTHER_SWIFT_FLAGS = $(inherited) -enable-experimental-feature Extern -enable-upcoming-feature InternalImportsByDefault
43+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) OPENATTRIBUTEGRAPH OPENATTRIBUTEGRAPH_RELEASE_2024 OPENATTRIBUTEGRAPH_SUPPORT_2021_API OPENATTRIBUTEGRAPH_SUPPORT_2022_API OPENATTRIBUTEGRAPH_SUPPORT_2023_API OPENATTRIBUTEGRAPH_SUPPORT_2024_API
44+
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = $(inherited) DEBUG OPENATTRIBUTEGRAPH OPENATTRIBUTEGRAPH_RELEASE_2024 OPENATTRIBUTEGRAPH_SUPPORT_2021_API OPENATTRIBUTEGRAPH_SUPPORT_2022_API OPENATTRIBUTEGRAPH_SUPPORT_2023_API OPENATTRIBUTEGRAPH_SUPPORT_2024_API
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// OpenAttributeGraph.xcconfig
2+
// Framework target build settings
3+
4+
#include "Common.xcconfig"
5+
6+
// MARK: - Product
7+
8+
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUIProject.OpenAttributeGraph
9+
PRODUCT_NAME = $(TARGET_NAME:c99extidentifier)
10+
11+
// MARK: - Module
12+
// NOTE: The SPM module.modulemap defines a non-framework module (OpenAttributeGraphCxx),
13+
// which is not suitable for Xcode framework builds. The build_xcframework.sh
14+
// post-processing injects the correct framework module map for distribution.
15+
16+
// MARK: - Header Search Paths
17+
18+
HEADER_SEARCH_PATHS = $(inherited) Sources/Platform/include Sources/Utilities/include Sources/OpenAttributeGraphCxx/include
19+
USER_HEADER_SEARCH_PATHS = $(inherited) Sources/OpenAttributeGraphCxx
20+
USE_HEADERMAP = NO
21+
22+
// MARK: - Swift
23+
24+
SWIFT_INCLUDE_PATHS = $(inherited) Sources/OpenAttributeGraphCxx/include
25+
SWIFT_INSTALL_MODULE = YES
26+
SWIFT_INSTALL_OBJC_HEADER = NO
27+
OTHER_SWIFT_FLAGS = $(inherited) -no-verify-emitted-module-interface
28+
29+
// MARK: - Library Evolution
30+
31+
BUILD_LIBRARY_FOR_DISTRIBUTION = YES
32+
SKIP_INSTALL = NO
33+
34+
// MARK: - Framework
35+
36+
GENERATE_INFOPLIST_FILE = YES
37+
CURRENT_PROJECT_VERSION = 1
38+
MARKETING_VERSION = 1.0
39+
// OAGVersion.c defines OpenAttributeGraphVersionNumber/String manually,
40+
// so disable Xcode's auto-generated version object to avoid duplicate symbols.
41+
// VERSIONING_SYSTEM = apple-generic
42+
DYLIB_COMPATIBILITY_VERSION = 1
43+
DYLIB_CURRENT_VERSION = 1
44+
DYLIB_INSTALL_NAME_BASE = @rpath
45+
INSTALL_PATH = $(LOCAL_LIBRARY_DIR)/Frameworks
46+
// Module verifier disabled: public headers use double-quoted includes and
47+
// reference internal paths not available in the framework context.
48+
ENABLE_MODULE_VERIFIER = NO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// OpenAttributeGraphTests.xcconfig
2+
// Test target build settings
3+
4+
#include "Common.xcconfig"
5+
6+
PRODUCT_BUNDLE_IDENTIFIER = org.OpenSwiftUIProject.OpenAttributeGraphTests

0 commit comments

Comments
 (0)