diff --git a/.gitignore b/.gitignore index 13cac52d..32b12e53 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,10 @@ build/ .ag_repo/ .oag_repo/ .claude + +# Tuist +Derived/ +Tuist/.build/ +*.xcodeproj +*.xcworkspace +*.xcframework diff --git a/Example/.gitignore b/Example/.gitignore new file mode 100644 index 00000000..ffa2309b --- /dev/null +++ b/Example/.gitignore @@ -0,0 +1,6 @@ +## Tuist generated files +*.xcodeproj +*.xcworkspace +Derived/ +build/ +.build diff --git a/Example/Project.swift b/Example/Project.swift new file mode 100644 index 00000000..6849a3a1 --- /dev/null +++ b/Example/Project.swift @@ -0,0 +1,18 @@ +import ProjectDescription + +let project = Project( + name: "Example", + targets: [ + .target( + name: "Example", + destinations: [.mac], + product: .commandLineTool, + bundleId: "org.OpenSwiftUIProject.OpenAttributeGraph.Example", + deploymentTargets: .macOS("15.0"), + sources: ["Sources/**"], + dependencies: [ + .external(name: "OpenAttributeGraph"), + ] + ), + ] +) diff --git a/Example/Sources/main.swift b/Example/Sources/main.swift new file mode 100644 index 00000000..2ed4c8da --- /dev/null +++ b/Example/Sources/main.swift @@ -0,0 +1,4 @@ +import OpenAttributeGraph + +let _ = Graph() +print("OpenAttributeGraph Example: Graph created successfully") diff --git a/Example/Tuist.swift b/Example/Tuist.swift new file mode 100644 index 00000000..abf9ffd0 --- /dev/null +++ b/Example/Tuist.swift @@ -0,0 +1,5 @@ +import ProjectDescription + +let tuist = Tuist( + project: .tuist() +) diff --git a/Example/Tuist/Package.swift b/Example/Tuist/Package.swift new file mode 100644 index 00000000..47233079 --- /dev/null +++ b/Example/Tuist/Package.swift @@ -0,0 +1,10 @@ +// swift-tools-version: 6.1 + +import PackageDescription + +let package = Package( + name: "ExampleDependencies", + dependencies: [ + .package(path: "../../"), + ] +) diff --git a/OpenAttributeGraph.xcodeproj/project.pbxproj b/OpenAttributeGraph.xcodeproj/project.pbxproj deleted file mode 100644 index 4fab947a..00000000 --- a/OpenAttributeGraph.xcodeproj/project.pbxproj +++ /dev/null @@ -1,343 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 77; - objects = { - -/* Begin PBXBuildFile section */ - OAG0000010000000000000001 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = OAG0000020000000000000001 /* libz.tbd */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - OAG0000020000000000000001 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; - OAG0000030000000000000001 /* OpenAttributeGraph.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OpenAttributeGraph.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - OAG00000C0000000000000001 /* Common.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Common.xcconfig; sourceTree = ""; }; - OAG00000C0000000000000002 /* OpenAttributeGraph.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenAttributeGraph.xcconfig; sourceTree = ""; }; - OAG00000C0000000000000003 /* OpenAttributeGraphTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenAttributeGraphTests.xcconfig; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ - 277F10582F4EF9460061C27D /* Exceptions for "OpenAttributeGraphCxx" folder in "OpenAttributeGraph" target */ = { - isa = PBXFileSystemSynchronizedBuildFileExceptionSet; - membershipExceptions = ( - include/OpenAttributeGraphCxx/Vector/vector.tpp, - include/SwiftBridging/README.md, - ); - target = OAG0000080000000000000001 /* OpenAttributeGraph */; - }; - OAG00000D0000000000000001 /* Exceptions for "Platform" folder in "OpenAttributeGraph" target */ = { - isa = PBXFileSystemSynchronizedBuildFileExceptionSet; - membershipExceptions = ( - README.md, - ); - target = OAG0000080000000000000001 /* OpenAttributeGraph */; - }; - OAG00000D0000000000000002 /* Exceptions for "Utilities" folder in "OpenAttributeGraph" target */ = { - isa = PBXFileSystemSynchronizedBuildFileExceptionSet; - membershipExceptions = ( - include/SwiftBridging/README.md, - README.md, - ); - target = OAG0000080000000000000001 /* OpenAttributeGraph */; - }; -/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ - -/* Begin PBXFileSystemSynchronizedRootGroup section */ - OAG0000040000000000000001 /* Platform */ = { - isa = PBXFileSystemSynchronizedRootGroup; - exceptions = ( - OAG00000D0000000000000001 /* Exceptions for "Platform" folder in "OpenAttributeGraph" target */, - ); - name = Platform; - path = Sources/Platform; - sourceTree = ""; - }; - OAG0000040000000000000002 /* Utilities */ = { - isa = PBXFileSystemSynchronizedRootGroup; - exceptions = ( - OAG00000D0000000000000002 /* Exceptions for "Utilities" folder in "OpenAttributeGraph" target */, - ); - name = Utilities; - path = Sources/Utilities; - sourceTree = ""; - }; - OAG0000040000000000000003 /* OpenAttributeGraphCxx */ = { - isa = PBXFileSystemSynchronizedRootGroup; - exceptions = ( - 277F10582F4EF9460061C27D /* Exceptions for "OpenAttributeGraphCxx" folder in "OpenAttributeGraph" target */, - ); - name = OpenAttributeGraphCxx; - path = Sources/OpenAttributeGraphCxx; - sourceTree = ""; - }; - OAG0000040000000000000004 /* OpenAttributeGraph */ = { - isa = PBXFileSystemSynchronizedRootGroup; - name = OpenAttributeGraph; - path = Sources/OpenAttributeGraph; - sourceTree = ""; - }; -/* End PBXFileSystemSynchronizedRootGroup section */ - -/* Begin PBXFrameworksBuildPhase section */ - OAG0000050000000000000001 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - OAG0000010000000000000001 /* libz.tbd in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - OAG0000060000000000000001 = { - isa = PBXGroup; - children = ( - OAG0000040000000000000001 /* Platform */, - OAG0000040000000000000002 /* Utilities */, - OAG0000040000000000000003 /* OpenAttributeGraphCxx */, - OAG0000040000000000000004 /* OpenAttributeGraph */, - OAG00000B0000000000000001 /* Configs */, - OAG0000060000000000000003 /* Frameworks */, - OAG0000060000000000000002 /* Products */, - ); - sourceTree = ""; - }; - OAG0000060000000000000002 /* Products */ = { - isa = PBXGroup; - children = ( - OAG0000030000000000000001 /* OpenAttributeGraph.framework */, - ); - name = Products; - sourceTree = ""; - }; - OAG0000060000000000000003 /* Frameworks */ = { - isa = PBXGroup; - children = ( - OAG0000020000000000000001 /* libz.tbd */, - ); - name = Frameworks; - sourceTree = ""; - }; - OAG00000B0000000000000001 /* Configs */ = { - isa = PBXGroup; - children = ( - OAG00000C0000000000000001 /* Common.xcconfig */, - OAG00000C0000000000000002 /* OpenAttributeGraph.xcconfig */, - OAG00000C0000000000000003 /* OpenAttributeGraphTests.xcconfig */, - ); - path = Configs; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - OAG0000070000000000000001 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - OAG0000080000000000000001 /* OpenAttributeGraph */ = { - isa = PBXNativeTarget; - buildConfigurationList = OAG000009000000000000000A /* Build configuration list for PBXNativeTarget "OpenAttributeGraph" */; - buildPhases = ( - OAG0000070000000000000001 /* Headers */, - OAG00000A0000000000000001 /* Process Headers */, - OAG0000050000000000000002 /* Sources */, - OAG0000050000000000000001 /* Frameworks */, - OAG0000050000000000000003 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - fileSystemSynchronizedGroups = ( - OAG0000040000000000000001 /* Platform */, - OAG0000040000000000000002 /* Utilities */, - OAG0000040000000000000003 /* OpenAttributeGraphCxx */, - OAG0000040000000000000004 /* OpenAttributeGraph */, - ); - name = OpenAttributeGraph; - packageProductDependencies = ( - ); - productName = OpenAttributeGraph; - productReference = OAG0000030000000000000001 /* OpenAttributeGraph.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - OAG0000060000000000000000 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastUpgradeCheck = 1640; - TargetAttributes = { - OAG0000080000000000000001 = { - CreatedOnToolsVersion = 16.4; - }; - }; - }; - buildConfigurationList = OAG0000090000000000000001 /* Build configuration list for PBXProject "OpenAttributeGraph" */; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = OAG0000060000000000000001; - minimizedProjectReferenceProxies = 1; - preferredProjectObjectVersion = 77; - productRefGroup = OAG0000060000000000000002 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - OAG0000080000000000000001 /* OpenAttributeGraph */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - OAG0000050000000000000003 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - OAG00000A0000000000000001 /* Process Headers */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "$(SRCROOT)/Scripts/Xcode/process_headers_inputs.xcfilelist", - ); - inputPaths = ( - "$(SRCROOT)/Scripts/Xcode/process_headers.sh", - ); - name = "Process Headers"; - outputFileListPaths = ( - "$(SRCROOT)/Scripts/Xcode/process_headers_outputs.xcfilelist", - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nScripts/Xcode/process_headers.sh\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - OAG0000050000000000000002 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - OAG0000090000000000000002 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = OAG00000C0000000000000001 /* Common.xcconfig */; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - OAG0000090000000000000003 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = OAG00000C0000000000000001 /* Common.xcconfig */; - buildSettings = { - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_NO_COMMON_BLOCKS = YES; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SWIFT_COMPILATION_MODE = wholemodule; - }; - name = Release; - }; - OAG0000090000000000000004 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = OAG00000C0000000000000002 /* OpenAttributeGraph.xcconfig */; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - LD_RUNPATH_SEARCH_PATHS = ( - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = ( - "@executable_path/../Frameworks", - "@loader_path/Frameworks", - ); - }; - name = Debug; - }; - OAG0000090000000000000005 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = OAG00000C0000000000000002 /* OpenAttributeGraph.xcconfig */; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - LD_RUNPATH_SEARCH_PATHS = ( - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = ( - "@executable_path/../Frameworks", - "@loader_path/Frameworks", - ); - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - OAG0000090000000000000001 /* Build configuration list for PBXProject "OpenAttributeGraph" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - OAG0000090000000000000002 /* Debug */, - OAG0000090000000000000003 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - OAG000009000000000000000A /* Build configuration list for PBXNativeTarget "OpenAttributeGraph" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - OAG0000090000000000000004 /* Debug */, - OAG0000090000000000000005 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = OAG0000060000000000000000 /* Project object */; -} diff --git a/OpenAttributeGraph.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/OpenAttributeGraph.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a6..00000000 --- a/OpenAttributeGraph.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Project.swift b/Project.swift new file mode 100644 index 00000000..b7065df8 --- /dev/null +++ b/Project.swift @@ -0,0 +1,68 @@ +import ProjectDescription + +// MARK: - Constants + +let destinations: Destinations = [.iPhone, .iPad, .mac, .appleVision] + +// MARK: - Project + +let project = Project( + name: "OpenAttributeGraph", + settings: .settings( + configurations: [ + .debug(name: "Debug", xcconfig: "Configs/Common.xcconfig"), + .release(name: "Release", xcconfig: "Configs/Common.xcconfig"), + ], + defaultSettings: .none + ), + targets: [ + .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", + name: "Process Headers", + inputPaths: [ + "$(SRCROOT)/Scripts/Xcode/process_headers.sh", + ], + inputFileListPaths: [ + "Scripts/Xcode/process_headers_inputs.xcfilelist", + ], + outputPaths: [], + outputFileListPaths: [ + "Scripts/Xcode/process_headers_outputs.xcfilelist", + ] + ), + ], + dependencies: [ + .sdk(name: "z", type: .library), + ], + settings: .settings( + base: [ + "DEFINES_MODULE": "NO", + ], + configurations: [ + .debug(name: "Debug", xcconfig: "Configs/OpenAttributeGraph.xcconfig"), + .release(name: "Release", xcconfig: "Configs/OpenAttributeGraph.xcconfig"), + ], + defaultSettings: .none + ) + ), + ] +) diff --git a/README.md b/README.md index 08a5ec5d..d26ffd01 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,28 @@ The project requires Swift toolchain headers for compilation. They are included git submodule update --init ``` +### Xcode (via Tuist) + +This project uses [Tuist](https://tuist.dev) to generate the Xcode project for framework builds. + +1. Install Tuist (if not already installed): + ```shell + # via mise + mise install tuist + # or via Homebrew + brew install tuist + ``` + +2. Generate the Xcode project: + ```shell + tuist generate + ``` + +3. Build using the generated workspace: + ```shell + xcodebuild build -workspace OpenAttributeGraph.xcworkspace -scheme OpenAttributeGraph -destination 'generic/platform=iOS Simulator' + ``` + ## License See LICENSE file - MIT diff --git a/Scripts/build_xcframework.sh b/Scripts/build_xcframework.sh index a2d87d5f..603ded86 100755 --- a/Scripts/build_xcframework.sh +++ b/Scripts/build_xcframework.sh @@ -8,6 +8,13 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" BUILD_DIR="$PROJECT_ROOT/.build/Xcode" SCHEME="OpenAttributeGraph" +# Generate Xcode project via Tuist +pushd "$PROJECT_ROOT" > /dev/null +tuist generate --no-open +popd > /dev/null + +XCODEPROJ="$PROJECT_ROOT/OpenAttributeGraph.xcodeproj" + # Copy and modify modulemap for framework distribution mkdir -p "$BUILD_DIR/Archives" "$BUILD_DIR/Frameworks" cat > "$BUILD_DIR/module.modulemap" << 'EOF' @@ -34,23 +41,23 @@ done echo "Building xcframework for $SCHEME (debug info: $DEBUG_INFO)" -# Archive for each platform using the xcodeproj +# Archive for each platform using the Tuist-generated xcodeproj xcodebuild archive \ - -project "$PROJECT_ROOT/OpenAttributeGraph.xcodeproj" \ + -project "$XCODEPROJ" \ -scheme "$SCHEME" \ -destination "generic/platform=macOS" \ -archivePath "$BUILD_DIR/Archives/$SCHEME-macOS.xcarchive" \ ENABLE_USER_SCRIPT_SANDBOXING=NO xcodebuild archive \ - -project "$PROJECT_ROOT/OpenAttributeGraph.xcodeproj" \ + -project "$XCODEPROJ" \ -scheme "$SCHEME" \ -destination "generic/platform=iOS" \ -archivePath "$BUILD_DIR/Archives/$SCHEME-iOS.xcarchive" \ ENABLE_USER_SCRIPT_SANDBOXING=NO xcodebuild archive \ - -project "$PROJECT_ROOT/OpenAttributeGraph.xcodeproj" \ + -project "$XCODEPROJ" \ -scheme "$SCHEME" \ -destination "generic/platform=iOS Simulator" \ -archivePath "$BUILD_DIR/Archives/$SCHEME-iOS-Simulator.xcarchive" \ diff --git a/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp index 5fc61462..280223cf 100644 --- a/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp +++ b/Sources/OpenAttributeGraphCxx/Graph/GraphDescription.cpp @@ -16,6 +16,8 @@ CFTypeRef OAGGraphDescription(OAGGraphRef graph, CFDictionaryRef options) { OAG::precondition_failure("invalidated graph"); } return OAG::Graph::description(&graph->context.get_graph(), (__bridge NSDictionary*)options); + #else + return nullptr; #endif } diff --git a/Tuist.swift b/Tuist.swift new file mode 100644 index 00000000..abf9ffd0 --- /dev/null +++ b/Tuist.swift @@ -0,0 +1,5 @@ +import ProjectDescription + +let tuist = Tuist( + project: .tuist() +) diff --git a/Tuist/Package.swift b/Tuist/Package.swift new file mode 100644 index 00000000..85b0f148 --- /dev/null +++ b/Tuist/Package.swift @@ -0,0 +1,15 @@ +// swift-tools-version: 6.1 +import PackageDescription + +#if TUIST +import ProjectDescription + +let packageSettings = PackageSettings( + productTypes: [:] +) +#endif + +let package = Package( + name: "OpenAttributeGraphDeps", + dependencies: [] +) diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..82eb7c50 --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +tuist = "4.156.0"