diff --git a/Package.resolved b/Package.resolved index 1d2a4d9..1bd3732 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/apple/swift-asn1.git", "state": { "branch": null, - "revision": "805deae27a7506dcad043604c00a9dc52d465dcb", - "version": "0.7.0" + "revision": "df5d2fcd22e3f480e3ef85bf23e277a4a0ef524d", + "version": "1.2.0" } }, { @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/apple/swift-certificates.git", "state": { "branch": null, - "revision": "35a7df2d9d71c401a47de9be2e3de629a01370c2", - "version": "0.4.1" + "revision": "83640c8097acaec17c9835a083e89678cb0f2b66", + "version": "1.3.0" } }, { @@ -42,16 +42,16 @@ "repositoryURL": "https://github.com/apple/swift-crypto.git", "state": { "branch": null, - "revision": "33a20e650c33f6d72d822d558333f2085effa3dc", - "version": "2.5.0" + "revision": "629f0b679d0fd0a6ae823d7f750b9ab032c00b80", + "version": "3.0.0" } }, { "package": "swift-driver", "repositoryURL": "https://github.com/apple/swift-driver.git", "state": { - "branch": "release/5.9", - "revision": "1b2b851ae4718caffa5f18fd1861bc0ddd1791a3", + "branch": "release/5.10", + "revision": "b461fd4fc51be8e1f2a3f4a2184b664b8846b46f", "version": null } }, @@ -59,8 +59,8 @@ "package": "llbuild", "repositoryURL": "https://github.com/apple/swift-llbuild.git", "state": { - "branch": "release/5.9", - "revision": "d73a305d6e5a82e4bf3bf1727da3d1376e87efab", + "branch": "release/5.10", + "revision": "fd7c2e0d9279edd023ced6b0a590f8407f5472f9", "version": null } }, @@ -68,8 +68,8 @@ "package": "SwiftPM", "repositoryURL": "https://github.com/apple/swift-package-manager.git", "state": { - "branch": "release/5.9", - "revision": "732d5406df67b64d266c5689454cf52aecbb4d57", + "branch": "release/5.10", + "revision": "b5f8ad931b7a40b81f64765fa08c2751164759b4", "version": null } }, @@ -86,8 +86,8 @@ "package": "swift-tools-support-core", "repositoryURL": "https://github.com/apple/swift-tools-support-core.git", "state": { - "branch": "release/5.9", - "revision": "5665fc7641ce1a971ad06faaa476862b222ef44b", + "branch": "release/5.10", + "revision": "90bdc2a157ebacc5d3de0c83e085d05d22ca5fa0", "version": null } }, diff --git a/Package.swift b/Package.swift index 1fe1e6d..ba212fc 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -7,7 +7,23 @@ let dependencies: [Package.Dependency] let versionedTargets: [Target] let versionedDependencies: [Target.Dependency] -#if swift(>=5.9) +#if swift(>=5.10) +dependencies = [ + .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.3"), + .package(url: "https://github.com/apple/swift-package-manager.git", branch: "release/5.10"), +// .package(url: "https://github.com/apple/swift-tools-support-core.git", branch: "release/5.10"), +] +versionedTargets = [ + .target( + name: "Xcodeproj", + dependencies: [ + .product(name: "SwiftPM-auto", package: "swift-package-manager"), +// .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), + ] + ) +] +versionedDependencies = ["Xcodeproj"] +#elseif swift(>=5.9) dependencies = [ .package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.2.3")), .package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.9")), @@ -58,7 +74,11 @@ versionedDependencies = [] #endif let platforms: [SupportedPlatform] -#if swift(>=5.6) +#if swift(>=5.10) +platforms = [ + .macOS(.v12), +] +#elseif swift(>=5.6) platforms = [ .macOS(.v11), ] @@ -83,8 +103,8 @@ let package = Package( targets: versionedTargets + [ .target(name: "CreateXCFramework", dependencies: versionedDependencies + [ .product(name: "ArgumentParser", package: "swift-argument-parser"), - .product(name: "SwiftPM-auto", package: "SwiftPM"), - .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), + .product(name: "SwiftPM-auto", package: "swift-package-manager"), +// .product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"), ]), .testTarget(name: "CreateXCFrameworkTests", dependencies: [ "CreateXCFramework" ]), ], diff --git a/Sources/CreateXCFramework/PackageInfo.swift b/Sources/CreateXCFramework/PackageInfo.swift index 5147997..4fc88b5 100644 --- a/Sources/CreateXCFramework/PackageInfo.swift +++ b/Sources/CreateXCFramework/PackageInfo.swift @@ -84,13 +84,13 @@ struct PackageInfo { self.rootDirectory = Foundation.URL(fileURLWithPath: options.packagePath, isDirectory: true).absoluteURL self.buildDirectory = self.rootDirectory.appendingPathComponent(options.buildPath, isDirectory: true).absoluteURL - let root = try AbsolutePath(validating: self.rootDirectory.path) + let root = try TSCBasic.AbsolutePath(validating: self.rootDirectory.path) self.toolchain = try UserToolchain(destination: try .hostDestination()) #if swift(>=5.7) let loader = ManifestLoader(toolchain: self.toolchain) - self.workspace = try Workspace(forRootPackage: root, customManifestLoader: loader) + self.workspace = try Workspace(forRootPackage: root.absPath, customManifestLoader: loader) #elseif swift(>=5.6) let resources = ToolchainConfiguration(swiftCompilerPath: self.toolchain.swiftCompilerPath) let loader = ManifestLoader(toolchain: resources) @@ -106,12 +106,12 @@ struct PackageInfo { #endif #if swift(>=5.6) - self.graph = try workspace.loadPackageGraph(rootPath: root, observabilityScope: self.observabilitySystem.topScope) + self.graph = try workspace.loadPackageGraph(rootPath: root.absPath, observabilityScope: self.observabilitySystem.topScope) let workspace = self.workspace let scope = observabilitySystem.topScope self.manifest = try tsc_await { workspace.loadRootManifest( - at: root, + at: root.absPath, observabilityScope: scope, completion: $0 ) diff --git a/Sources/CreateXCFramework/ProjectGenerator.swift b/Sources/CreateXCFramework/ProjectGenerator.swift index dc2b9c8..c52284d 100644 --- a/Sources/CreateXCFramework/ProjectGenerator.swift +++ b/Sources/CreateXCFramework/ProjectGenerator.swift @@ -86,7 +86,7 @@ struct ProjectGenerator { xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { try AbsolutePath(validating: $0) }, useLegacySchemeGenerator: true ), - fileSystem: localFileSystem, + fileSystem: reallyLocalFileSystem, observabilityScope: self.package.observabilitySystem.topScope ) #else diff --git a/Sources/CreateXCFramework/Zipper.swift b/Sources/CreateXCFramework/Zipper.swift index 338e7c5..ce4da8d 100644 --- a/Sources/CreateXCFramework/Zipper.swift +++ b/Sources/CreateXCFramework/Zipper.swift @@ -113,8 +113,8 @@ struct Zipper { } #if swift(>=5.7) - private func checksum(forBinaryArtifactAt path: AbsolutePath) throws -> String { - let fileSystem = localFileSystem + private func checksum(forBinaryArtifactAt path: TSCBasic.AbsolutePath) throws -> String { + let fileSystem = TSCBasic.localFileSystem let checksumAlgorithm = SHA256() let archiver = ZipArchiver(fileSystem: fileSystem) diff --git a/Sources/Xcodeproj/Converters.swift b/Sources/Xcodeproj/Converters.swift new file mode 100644 index 0000000..15ddac2 --- /dev/null +++ b/Sources/Xcodeproj/Converters.swift @@ -0,0 +1,14 @@ +import Foundation +import TSCBasic +import Basics + +//public typealias AbsolutePath = TSCBasic.AbsolutePath +public var reallyLocalFileSystem = TSCBasic.localFileSystem + +extension TSCBasic.AbsolutePath { + public var absPath: Basics.AbsolutePath { try! Basics.AbsolutePath(validating: self.pathString) } +} + +extension Basics.AbsolutePath { + public var absPath: TSCBasic.AbsolutePath { try! TSCBasic.AbsolutePath(validating: self.pathString) } +} diff --git a/Sources/Xcodeproj/SchemesGenerator.swift b/Sources/Xcodeproj/SchemesGenerator.swift index 44dab48..30a39e8 100644 --- a/Sources/Xcodeproj/SchemesGenerator.swift +++ b/Sources/Xcodeproj/SchemesGenerator.swift @@ -44,7 +44,7 @@ public final class SchemesGenerator { private let graph: PackageGraph private let container: String - private let schemesDir: AbsolutePath + private let schemesDir: AbsolutePath private let isCodeCoverageEnabled: Bool private let fs: FileSystem @@ -208,12 +208,12 @@ public final class SchemesGenerator { """ - let file = try AbsolutePath(validating: scheme.filename, relativeTo: schemesDir) + let file = try AbsolutePath(validating: scheme.filename, relativeTo: schemesDir) try fs.writeFileContents(file, bytes: stream.bytes) } private func disableSchemeAutoCreation() throws { - let workspacePath = try AbsolutePath(validating: "../../project.xcworkspace", relativeTo: schemesDir) + let workspacePath = try AbsolutePath(validating: "../../project.xcworkspace", relativeTo: schemesDir) // Write the settings file to disable automatic scheme creation. var stream = BufferedOutputByteStream() @@ -227,12 +227,12 @@ public final class SchemesGenerator { """ - let settingsPlist = try AbsolutePath(validating: "xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath) + let settingsPlist = try AbsolutePath(validating: "xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath) try fs.createDirectory(settingsPlist.parentDirectory, recursive: true) try fs.writeFileContents(settingsPlist, bytes: stream.bytes) // Write workspace contents file. - let contentsFile = try AbsolutePath(validating: "contents.xcworkspacedata", relativeTo: workspacePath) + let contentsFile = try AbsolutePath(validating: "contents.xcworkspacedata", relativeTo: workspacePath) stream = BufferedOutputByteStream() stream <<< """ diff --git a/Sources/Xcodeproj/generate.swift b/Sources/Xcodeproj/generate.swift index 6db6cd8..5fce1cd 100644 --- a/Sources/Xcodeproj/generate.swift +++ b/Sources/Xcodeproj/generate.swift @@ -20,7 +20,7 @@ import SourceControl import TSCBasic import struct TSCUtility.BuildFlags - +public typealias AbsolutePath = TSCBasic.AbsolutePath public struct XcodeprojOptions { /// The build flags. public var flags: PackageModel.BuildFlags @@ -28,7 +28,7 @@ public struct XcodeprojOptions { /// If provided, a path to an xcconfig file to be included by the project. /// /// This allows the client to override settings defined in the project itself. - public var xcconfigOverrides: AbsolutePath? + public var xcconfigOverrides: AbsolutePath? /// Whether code coverage should be enabled in the generated scheme. public var isCodeCoverageEnabled: Bool @@ -64,9 +64,9 @@ public struct XcodeprojOptions { public enum XcodeProject { // Determine the path of the .xcodeproj wrapper directory. - public static func makePath(outputDir: AbsolutePath, projectName: String) throws -> AbsolutePath { + public static func makePath(outputDir: AbsolutePath, projectName: String) throws -> AbsolutePath { let xcodeprojName = "\(projectName).xcodeproj" - return try AbsolutePath(validating: xcodeprojName, relativeTo: outputDir) + return try AbsolutePath(validating: xcodeprojName, relativeTo: outputDir) } /// Generates an Xcode project and all needed support files. The .xcodeproj @@ -88,8 +88,8 @@ public enum XcodeProject { // Note that the output directory might be completely separate from the // path of the root package (which is where the sources live). - let srcroot = graph.rootPackages[0].path - + let srcroot = try AbsolutePath(validating: graph.rootPackages[0].path.pathString) + // Determine the path of the scheme directory (it's inside the .xcodeproj). let schemesDir = xcodeprojPath.appending(components: "xcshareddata", "xcschemes") @@ -97,16 +97,16 @@ public enum XcodeProject { try makeDirectories(xcodeprojPath) try makeDirectories(schemesDir) - let extraDirs: [AbsolutePath] - var extraFiles = [AbsolutePath]() + let extraDirs: [AbsolutePath] + var extraFiles = [AbsolutePath]() if options.addExtraFiles { // Find the paths of any extra directories that should be added as folder // references in the project. extraDirs = try findDirectoryReferences(path: srcroot) - - if try repositoryProvider.workingCopyExists(at: srcroot) { - let workingCheckout = try repositoryProvider.openWorkingCopy(at: srcroot) + let basicSRCRoot = try Basics.AbsolutePath(validating: srcroot.pathString) + if try repositoryProvider.workingCopyExists(at: basicSRCRoot) { + let workingCheckout = try repositoryProvider.openWorkingCopy(at: basicSRCRoot) extraFiles = try getExtraFilesFor(package: graph.rootPackages[0], in: workingCheckout) } } else { @@ -146,7 +146,7 @@ public enum XcodeProject { ///// For framework targets, generate target.c99Name_Info.plist files in the ///// directory that Xcode project is generated let name = target.infoPlistFileName - try open(AbsolutePath(validating: name, relativeTo: xcodeprojPath)) { print in + try open(AbsolutePath(validating: name, relativeTo: xcodeprojPath)) { print in print(""" @@ -202,7 +202,7 @@ public enum XcodeProject { /// /// This method doesn't rewrite the file in case the new and old contents of /// file are same. - static func open(_ path: AbsolutePath, body: ((String) -> Void) throws -> Void) throws { + static func open(_ path: AbsolutePath, body: ((String) -> Void) throws -> Void) throws { let stream = BufferedOutputByteStream() try body { line in stream <<< line @@ -211,17 +211,17 @@ public enum XcodeProject { // If the file exists with the identical contents, we don't need to rewrite it. // // This avoids unnecessarily triggering Xcode reloads of the project file. - if let contents = try? localFileSystem.readFileContents(path), contents == stream.bytes { + if let contents = try? TSCBasic.localFileSystem.readFileContents(path), contents == stream.bytes { return } // Write the real file. - try localFileSystem.writeFileContents(path, bytes: stream.bytes) + try TSCBasic.localFileSystem.writeFileContents(path, bytes: stream.bytes) } /// Finds directories that will be added as blue folder /// Excludes hidden directories, Xcode projects and reserved directories - static func findDirectoryReferences(path: AbsolutePath) throws -> [AbsolutePath] { + static func findDirectoryReferences(path: AbsolutePath) throws -> [AbsolutePath] { let rootDirectories = try walk(path, recursively: false) return rootDirectories.filter({ @@ -229,7 +229,7 @@ public enum XcodeProject { if $0.suffix == ".playground" { return false } if $0.basename.hasPrefix(".") { return false } if PackageBuilder.predefinedTestDirectories.contains($0.basename) { return false } - return localFileSystem.isDirectory($0) + return TSCBasic.localFileSystem.isDirectory($0) }) } @@ -246,7 +246,7 @@ public enum XcodeProject { // -Package so its name doesn't collide with any products or target with // same name. let schemeName = "\(graph.rootPackages[0].manifest.displayName)-Package.xcscheme" // TODO: use identity instead? - try open(AbsolutePath(validating: schemeName, relativeTo: schemesDir)) { stream in + try open(AbsolutePath(validating: schemeName, relativeTo: schemesDir)) { stream in legacySchemeGenerator( container: schemeContainer, graph: graph, @@ -278,27 +278,29 @@ public enum XcodeProject { container: schemeContainer, schemesDir: schemesDir, isCodeCoverageEnabled: options.isCodeCoverageEnabled, - fs: localFileSystem + fs: TSCBasic.localFileSystem ).generate() } } // Find and return non-source files in the source directories and root that should be added // as a reference to the project. - static func getExtraFilesFor(package: ResolvedPackage, in workingCheckout: WorkingCheckout) throws -> [AbsolutePath] { + static func getExtraFilesFor(package: ResolvedPackage, in workingCheckout: WorkingCheckout) throws -> [AbsolutePath] { let srcroot = package.path - var extraFiles = findNonSourceFiles(path: srcroot, toolsVersion: package.manifest.toolsVersion, recursively: false) + let basicSRCRoot = try AbsolutePath(validating: package.path.pathString) + var extraFiles = findNonSourceFiles(path: basicSRCRoot, toolsVersion: package.manifest.toolsVersion, recursively: false) for target in package.targets { let sourcesDirectory = target.sources.root - if localFileSystem.isDirectory(sourcesDirectory) { - let sourcesExtraFiles = findNonSourceFiles(path: sourcesDirectory, toolsVersion: package.manifest.toolsVersion, recursively: true) + let basicSourcesDirectory = try AbsolutePath(validating: sourcesDirectory.pathString) + if TSCBasic.localFileSystem.isDirectory(sourcesDirectory) { + let sourcesExtraFiles = findNonSourceFiles(path: basicSourcesDirectory, toolsVersion: package.manifest.toolsVersion, recursively: true) extraFiles.append(contentsOf: sourcesExtraFiles) } } // Return if we can't determine if the files are git ignored. - guard let isIgnored = try? workingCheckout.areIgnored(extraFiles) else { + guard let isIgnored = try? workingCheckout.areIgnored(extraFiles.map { try Basics.AbsolutePath(validating: $0.pathString) }) else { return [] } extraFiles = extraFiles.enumerated().filter({ !isIgnored[$0.offset] }).map({ $0.element }) @@ -310,14 +312,14 @@ public enum XcodeProject { /// - parameters: /// - path: The path of the directory to get the files from /// - recursively: Specifies if the directory at `path` should be searched recursively - static func findNonSourceFiles(path: AbsolutePath, toolsVersion: ToolsVersion, recursively: Bool) -> [AbsolutePath] { + static func findNonSourceFiles(path: AbsolutePath, toolsVersion: ToolsVersion, recursively: Bool) -> [AbsolutePath] { let filesFromPath: RecursibleDirectoryContentsGenerator? if recursively { filesFromPath = try? walk(path, recursing: { path in // Ignore any git submodule that we might encounter. let gitPath = path.appending(component: ".git") - if localFileSystem.exists(gitPath) { + if TSCBasic.localFileSystem.exists(gitPath) { return false } return recursively @@ -327,7 +329,7 @@ public enum XcodeProject { } return filesFromPath?.filter({ - if !localFileSystem.isFile($0) { return false } + if !TSCBasic.localFileSystem.isFile($0) { return false } if $0.basename.hasPrefix(".") { return false } if $0.basename == "Package.resolved" { return false } if let `extension` = $0.extension, SupportedLanguageExtension.validExtensions(toolsVersion: toolsVersion).contains(`extension`) { diff --git a/Sources/Xcodeproj/pbxproj.swift b/Sources/Xcodeproj/pbxproj.swift index 4f244b7..ad368cd 100644 --- a/Sources/Xcodeproj/pbxproj.swift +++ b/Sources/Xcodeproj/pbxproj.swift @@ -21,7 +21,7 @@ import PackageLoading /// Errors encounter during Xcode project generation public enum ProjectGenerationError: Swift.Error { /// The given xcconfig override file does not exist - case xcconfigOverrideNotFound(path: AbsolutePath) + case xcconfigOverrideNotFound(path: AbsolutePath) } /// Generates the contents of the `project.pbxproj` for the package graph. The @@ -32,10 +32,10 @@ public enum ProjectGenerationError: Swift.Error { /// is the path of the root package in the package graph, independent of the /// directory to which the .xcodeproj is being generated. public func pbxproj( - xcodeprojPath: AbsolutePath, + xcodeprojPath: AbsolutePath, graph: PackageGraph, - extraDirs: [AbsolutePath], - extraFiles: [AbsolutePath], + extraDirs: [AbsolutePath], + extraFiles: [AbsolutePath], options: XcodeprojOptions, fileSystem: FileSystem, observabilityScope: ObservabilityScope @@ -59,10 +59,10 @@ public func pbxproj( fileprivate let invalidXcodeModuleNames = Set(["Modules", "Headers", "Versions"]) public func xcodeProject( - xcodeprojPath: AbsolutePath, + xcodeprojPath: AbsolutePath, graph: PackageGraph, - extraDirs: [AbsolutePath], - extraFiles: [AbsolutePath], + extraDirs: [AbsolutePath], + extraFiles: [AbsolutePath], options: XcodeprojOptions, fileSystem: FileSystem, observabilityScope: ObservabilityScope @@ -103,7 +103,7 @@ public func xcodeProject( // directory (note that those two directories might or might be the same). // The effect is to make any `projectDir`-relative path be relative to the // source root directory, i.e. the path of the root package. - project.projectDir = sourceRootDir.relative(to: xcodeprojPath.parentDirectory).pathString + project.projectDir = sourceRootDir.relative(to: xcodeprojPath.parentDirectory.absPath).pathString // Configure the project settings. let projectSettings = project.buildSettings @@ -193,7 +193,7 @@ public func xcodeProject( // Create a file reference for the .xcconfig file (with a path relative // to the group). xcconfigOverridesFileRef = xcconfigsGroup.addFileReference( - path: xcconfigPath.relative(to: sourceRootDir).pathString, + path: xcconfigPath.relative(to: sourceRootDir.absPath).pathString, name: xcconfigPath.basename) // We don't assign the file reference as the xcconfig file reference of @@ -227,13 +227,13 @@ public func xcodeProject( // To avoid creating multiple groups for the same path, we keep a mapping // of the paths we've seen and the corresponding groups we've created. - var srcPathsToGroups: [AbsolutePath: Xcode.Group] = [:] + var srcPathsToGroups: [AbsolutePath: Xcode.Group] = [:] // Private helper function to make a group (or return an existing one) for // a particular path, including any intermediate groups that may be needed. // A name can be specified, if different from the last path component (any // custom name does not apply to any intermediate groups). - func makeGroup(for path: AbsolutePath, named name: String? = nil) -> Xcode.Group { + func makeGroup(for path: AbsolutePath, named name: String? = nil) -> Xcode.Group { // Check if we already have a group. if let group = srcPathsToGroups[path] { // We do, so we just return it without creating anything. @@ -256,7 +256,7 @@ public func xcodeProject( // Add a mapping from the project dir to the main group, as a backstop for // any paths that get that far (which does not happen in standard package // layout). - srcPathsToGroups[sourceRootDir] = project.mainGroup + srcPathsToGroups[sourceRootDir.absPath] = project.mainGroup // Private helper function that creates a source group for one or more // targets (which could be regular targets, tests, etc). If there is a @@ -299,10 +299,10 @@ public func xcodeProject( .addGroup(path: (path == "." ? "" : path), pathBase: .projectDir, name: name) // Associate the group with the target's root path. - srcPathsToGroups[target.sources.root] = group + srcPathsToGroups[target.sources.root.absPath] = group } - return sourcesGroup ?? srcPathsToGroups[targets[0].sources.root] + return sourcesGroup ?? srcPathsToGroups[targets[0].sources.root.absPath] } let (rootModules, testModules) = { () -> ([ResolvedTarget], [ResolvedTarget]) in @@ -363,7 +363,7 @@ public func xcodeProject( // Add "blue folders" for any other directories at the top level (note that // they are not guaranteed to be direct children of the root directory). for extraDir in extraDirs { - project.mainGroup.addFileReference(path: extraDir.relative(to: sourceRootDir).pathString, pathBase: .projectDir) + project.mainGroup.addFileReference(path: extraDir.absPath.relative(to: sourceRootDir).pathString, pathBase: .projectDir) } for extraFile in extraFiles { @@ -380,7 +380,7 @@ public func xcodeProject( // Mapping of targets to the path of their modulemap path, if they one. // It also records if the modulemap is generated by SwiftPM. - var modulesToModuleMap: [ResolvedTarget: (path: AbsolutePath, isGenerated: Bool)] = [:] + var modulesToModuleMap: [ResolvedTarget: (path: AbsolutePath, isGenerated: Bool)] = [:] // Go through all the targets, creating targets and adding file references // to the group tree (the specific top-level group under which they are @@ -449,7 +449,7 @@ public func xcodeProject( } let infoPlistFilePath = xcodeprojPath.appending(component: target.infoPlistFileName) - targetSettings.common.INFOPLIST_FILE = infoPlistFilePath.relative(to: sourceRootDir).pathString + targetSettings.common.INFOPLIST_FILE = infoPlistFilePath.relative(to: sourceRootDir.absPath).pathString // The generated Info.plist has $(CURRENT_PROJECT_VERSION) as value for the CFBundleVersion key. // CFBundleVersion is required for apps to e.g. be submitted to the app store. // So we need to set it to some valid value in the project settings. @@ -560,7 +560,7 @@ public func xcodeProject( // Find or make a group for the parent directory of the source file. // We know that there will always be one, because we created groups // for the source directories of all the targets. - let group = makeGroup(for: sourceFile.parentDirectory) + let group = makeGroup(for: sourceFile.parentDirectory.absPath) // Create a reference for the source file. We don't set its file // type; rather, we let Xcode determine it based on the suffix. @@ -581,10 +581,10 @@ public func xcodeProject( clangTarget.type == .library, fileSystem.isDirectory(clangTarget.includeDir) { let includeDir = clangTarget.includeDir - let includeGroup = makeGroup(for: includeDir) + let includeGroup = makeGroup(for: includeDir.absPath) // FIXME: Support C++ headers. for header in try walk(includeDir, fileSystem: fileSystem) where header.extension == "h" { - let group = makeGroup(for: header.parentDirectory) + let group = makeGroup(for: header.parentDirectory.absPath) group.addFileReference(path: header.basename) } @@ -594,14 +594,14 @@ public func xcodeProject( // Generate a modulemap for clangTarget (if not provided by user) and // add to the build settings. - var moduleMapPath: AbsolutePath? + var moduleMapPath: AbsolutePath? // If the modulemap is generated (as opposed to user provided). var isGenerated = false // If user provided the modulemap no need to generate. if case .custom(let path) = clangTarget.moduleMapType { - moduleMapPath = path + moduleMapPath = path.absPath } else if includeGroup.subitems.contains(where: { $0.path == clangTarget.c99name + ".h" }) { // If an umbrella header exists, enable Xcode's builtin module's feature rather than generating // a custom module map. This increases the compatibility of generated Xcode projects. @@ -617,7 +617,7 @@ public func xcodeProject( let path = xcodeprojPath.appending(components: "GeneratedModuleMap", clangTarget.c99name, moduleMapFilename) try fileSystem.createDirectory(path.parentDirectory, recursive: true) let moduleMapGenerator = ModuleMapGenerator(targetName: clangTarget.name, moduleName: clangTarget.c99name, publicHeadersDir: clangTarget.includeDir, fileSystem: fileSystem) - try moduleMapGenerator.generateModuleMap(type: generatedModuleMapType, at: path) + try moduleMapGenerator.generateModuleMap(type: generatedModuleMapType, at: path.absPath) moduleMapPath = path isGenerated = true } @@ -684,12 +684,12 @@ public func xcodeProject( assert(dependency.underlyingTarget is ClangTarget) xcodeTarget.buildSettings.common.OTHER_SWIFT_FLAGS += [ "-Xcc", - "-fmodule-map-file=$(SRCROOT)/\(moduleMap.path.relative(to: sourceRootDir).pathString)", + "-fmodule-map-file=$(SRCROOT)/\(moduleMap.path.relative(to: sourceRootDir.absPath).pathString)", ] // Workaround for a interface generation bug. if moduleMap.isGenerated { xcodeTarget.buildSettings.common.HEADER_SEARCH_PATHS += [ - "$(SRCROOT)/\(moduleMap.path.parentDirectory.relative(to: sourceRootDir).pathString)" + "$(SRCROOT)/\(moduleMap.path.parentDirectory.relative(to: sourceRootDir.absPath).pathString)" ] } } @@ -757,7 +757,7 @@ private extension SupportedLanguageExtension { } private extension ResolvedTarget { - func fileType(forSource source: RelativePath) throws -> String { + func fileType(forSource source: TSCBasic.RelativePath) throws -> String { switch underlyingTarget { case is SwiftTarget: // SwiftModules only has one type of source so just always return this.