Skip to content

Commit f51d8fb

Browse files
committed
Merge branch 'bsneed/warnings_fix'
2 parents abac8c7 + 26dbfed commit f51d8fb

File tree

9 files changed

+58
-45
lines changed

9 files changed

+58
-45
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
/*.xcodeproj
66
xcuserdata/
77
DerivedData/
8+
9+
.vscode/

Package.resolved

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

Sources/CreateXCFramework/Command.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ struct Command: ParsableCommand {
7878
// we've applied the xcconfig to everything, but some dependencies (*cough* swift-nio)
7979
// have build errors, so we remove it from targets we're not building
8080
if self.options.stackEvolution == false {
81-
try project.enableDistribution(targets: productNames, xcconfig: AbsolutePath(package.distributionBuildXcconfig.path).relative(to: AbsolutePath(package.rootDirectory.path)))
81+
try project.enableDistribution(targets: productNames, xcconfig: AbsolutePath(validating: package.distributionBuildXcconfig.path).relative(to: AbsolutePath(validating: package.rootDirectory.path)))
8282
}
8383

8484
// save the project
85-
try project.save(to: generator.projectPath)
85+
try project.save(to: try generator.projectPath())
8686

8787
// start building
88-
let builder = XcodeBuilder(project: project, projectPath: generator.projectPath, package: package, options: self.options)
88+
let builder = XcodeBuilder(project: project, projectPath: try generator.projectPath(), package: package, options: self.options)
8989

9090
// clean first
9191
if self.options.clean {

Sources/CreateXCFramework/PackageInfo.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct PackageInfo {
8484
self.rootDirectory = Foundation.URL(fileURLWithPath: options.packagePath, isDirectory: true).absoluteURL
8585
self.buildDirectory = self.rootDirectory.appendingPathComponent(options.buildPath, isDirectory: true).absoluteURL
8686

87-
let root = AbsolutePath(self.rootDirectory.path)
87+
let root = try AbsolutePath(validating: self.rootDirectory.path)
8888

8989
self.toolchain = try UserToolchain(destination: try .hostDestination())
9090

@@ -252,13 +252,6 @@ struct PackageInfo {
252252
return target
253253
}
254254

255-
256-
// MARK: - Helpers
257-
258-
private var absoluteRootDirectory: AbsolutePath {
259-
AbsolutePath(self.rootDirectory.path)
260-
}
261-
262255
}
263256

264257

Sources/CreateXCFramework/ProjectGenerator.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct ProjectGenerator {
2121

2222
let package: PackageInfo
2323

24-
var projectPath: AbsolutePath {
25-
let dir = AbsolutePath(self.package.projectBuildDirectory.path)
24+
func projectPath() throws -> AbsolutePath {
25+
let dir = try AbsolutePath(validating: self.package.projectBuildDirectory.path)
2626
#if swift(>=5.7)
27-
return XcodeProject.makePath(outputDir: dir, projectName: self.package.manifest.displayName)
27+
return try XcodeProject.makePath(outputDir: dir, projectName: self.package.manifest.displayName)
2828
#else
2929
return buildXcodeprojPath(outputDir: dir, projectName: self.package.manifest.displayName)
3030
#endif
@@ -46,14 +46,14 @@ struct ProjectGenerator {
4646
return
4747
}
4848

49-
try makeDirectories(self.projectPath)
49+
try makeDirectories(self.projectPath())
5050

51-
let path = AbsolutePath(self.package.distributionBuildXcconfig.path)
51+
let path = try AbsolutePath(validating: self.package.distributionBuildXcconfig.path)
5252
try open(path) { stream in
5353
if let absolutePath = self.package.overridesXcconfig?.path {
5454
stream (
5555
"""
56-
#include "\(AbsolutePath(absolutePath).relative(to: AbsolutePath(path.dirname)).pathString)"
56+
#include "\(try AbsolutePath(validating: absolutePath).relative(to: AbsolutePath(validating: path.dirname)).pathString)"
5757
5858
"""
5959
)
@@ -72,7 +72,7 @@ struct ProjectGenerator {
7272
/// This is basically a copy of Xcodeproj.generate()
7373
///
7474
func generate () throws -> Xcode.Project {
75-
let path = self.projectPath
75+
let path = try self.projectPath()
7676
try makeDirectories(path)
7777

7878
// Generate the contents of project.xcodeproj (inside the .xcodeproj).
@@ -83,7 +83,7 @@ struct ProjectGenerator {
8383
extraDirs: [],
8484
extraFiles: [],
8585
options: XcodeprojOptions (
86-
xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { AbsolutePath($0) },
86+
xcconfigOverrides: (self.package.overridesXcconfig?.path).flatMap { try AbsolutePath(validating: $0) },
8787
useLegacySchemeGenerator: true
8888
),
8989
fileSystem: localFileSystem,

Sources/CreateXCFramework/Zipper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct Zipper {
5858

5959
func checksum (file: Foundation.URL) throws -> Foundation.URL {
6060
#if swift(>=5.7)
61-
let sum = try checksum(forBinaryArtifactAt: AbsolutePath(file.path))
61+
let sum = try checksum(forBinaryArtifactAt: AbsolutePath(validating: file.path))
6262
#elseif swift(>=5.6)
6363
let sum = try self.package.workspace.checksum(forBinaryArtifactAt: AbsolutePath(file.path))
6464
#else

Sources/Xcodeproj/SchemesGenerator.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ public final class SchemesGenerator {
208208
209209
"""
210210

211-
let file = AbsolutePath(scheme.filename, relativeTo: schemesDir)
211+
let file = try AbsolutePath(validating: scheme.filename, relativeTo: schemesDir)
212212
try fs.writeFileContents(file, bytes: stream.bytes)
213213
}
214214

215215
private func disableSchemeAutoCreation() throws {
216-
let workspacePath = AbsolutePath("../../project.xcworkspace", relativeTo: schemesDir)
216+
let workspacePath = try AbsolutePath(validating: "../../project.xcworkspace", relativeTo: schemesDir)
217217

218218
// Write the settings file to disable automatic scheme creation.
219219
var stream = BufferedOutputByteStream()
@@ -227,12 +227,12 @@ public final class SchemesGenerator {
227227
</dict>
228228
</plist>
229229
"""
230-
let settingsPlist = AbsolutePath("xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath)
230+
let settingsPlist = try AbsolutePath(validating: "xcshareddata/WorkspaceSettings.xcsettings", relativeTo: workspacePath)
231231
try fs.createDirectory(settingsPlist.parentDirectory, recursive: true)
232232
try fs.writeFileContents(settingsPlist, bytes: stream.bytes)
233233

234234
// Write workspace contents file.
235-
let contentsFile = AbsolutePath("contents.xcworkspacedata", relativeTo: workspacePath)
235+
let contentsFile = try AbsolutePath(validating: "contents.xcworkspacedata", relativeTo: workspacePath)
236236
stream = BufferedOutputByteStream()
237237
stream <<< """
238238
<?xml version="1.0" encoding="UTF-8"?>

Sources/Xcodeproj/generate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import struct TSCUtility.BuildFlags
2323

2424
public struct XcodeprojOptions {
2525
/// The build flags.
26-
public var flags: BuildFlags
26+
public var flags: PackageModel.BuildFlags
2727

2828
/// If provided, a path to an xcconfig file to be included by the project.
2929
///
@@ -46,7 +46,7 @@ public struct XcodeprojOptions {
4646
public var manifestLoader: ManifestLoader?
4747

4848
public init(
49-
flags: BuildFlags = BuildFlags(),
49+
flags: PackageModel.BuildFlags = PackageModel.BuildFlags(),
5050
xcconfigOverrides: AbsolutePath? = nil,
5151
isCodeCoverageEnabled: Bool? = nil,
5252
useLegacySchemeGenerator: Bool? = nil,
@@ -64,9 +64,9 @@ public struct XcodeprojOptions {
6464

6565
public enum XcodeProject {
6666
// Determine the path of the .xcodeproj wrapper directory.
67-
public static func makePath(outputDir: AbsolutePath, projectName: String) -> AbsolutePath {
67+
public static func makePath(outputDir: AbsolutePath, projectName: String) throws -> AbsolutePath {
6868
let xcodeprojName = "\(projectName).xcodeproj"
69-
return AbsolutePath(xcodeprojName, relativeTo: outputDir)
69+
return try AbsolutePath(validating: xcodeprojName, relativeTo: outputDir)
7070
}
7171

7272
/// Generates an Xcode project and all needed support files. The .xcodeproj
@@ -146,7 +146,7 @@ public enum XcodeProject {
146146
///// For framework targets, generate target.c99Name_Info.plist files in the
147147
///// directory that Xcode project is generated
148148
let name = target.infoPlistFileName
149-
try open(AbsolutePath(name, relativeTo: xcodeprojPath)) { print in
149+
try open(AbsolutePath(validating: name, relativeTo: xcodeprojPath)) { print in
150150
print("""
151151
<?xml version="1.0" encoding="UTF-8"?>
152152
<plist version="1.0">
@@ -246,7 +246,7 @@ public enum XcodeProject {
246246
// -Package so its name doesn't collide with any products or target with
247247
// same name.
248248
let schemeName = "\(graph.rootPackages[0].manifest.displayName)-Package.xcscheme" // TODO: use identity instead?
249-
try open(AbsolutePath(schemeName, relativeTo: schemesDir)) { stream in
249+
try open(AbsolutePath(validating: schemeName, relativeTo: schemesDir)) { stream in
250250
legacySchemeGenerator(
251251
container: schemeContainer,
252252
graph: graph,

Sources/Xcodeproj/pbxproj.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public func xcodeProject(
429429

430430
// Assign the deployment target if the package is using the newer manifest version.
431431
if package.manifest.toolsVersion >= .v5 {
432-
for supportedPlatform in target.platforms.derived {
432+
for supportedPlatform in target.platforms.declared {
433433
let version = supportedPlatform.version.versionString
434434
switch supportedPlatform.platform {
435435
case .macOS:

0 commit comments

Comments
 (0)