Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import Foundation
public struct FileResource: Hashable, Sendable {
public let relativePath: String
public let bundle: Bundle
public let url: URL

public init(relativePath: String, bundle: Bundle) {
self.relativePath = relativePath
self.bundle = bundle
}

public var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
}

public var path: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public struct FontResource: Equatable, Sendable {
public let symbolicTraits: CTFontSymbolicTraits
public let relativePath: String
public let bundle: Bundle
public let url: URL

public init(
fontName: String,
Expand All @@ -26,10 +27,7 @@ public struct FontResource: Equatable, Sendable {
self.symbolicTraits = symbolicTraits
self.relativePath = relativePath
self.bundle = bundle
}

public var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
}

public var path: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ class DefaultTypeDeclarationGenerator: TypeDeclarationGenerator {
func generate(resourceTypeName: String, accessLevel: String?) -> String {
let accessLevel = accessLevel.map({ $0 + " " }) ?? ""

// let url = URL(filePath: "Library", relativeTo: URL(fileURLWithPath: "/System"))
// print(url.path(percentEncoded: false)) // iOS18: Library, iOS26: /System/Library
// print(url.standardizedFileURL.path(percentEncoded: false)) // All: /System/Library
return """
\(accessLevel)struct \(resourceTypeName): Hashable, Sendable {
\(accessLevel)let relativePath: String
\(accessLevel)let bundle: Bundle
\(accessLevel)let url: URL

\(accessLevel)init(relativePath: String, bundle: Bundle) {
self.relativePath = relativePath
self.bundle = bundle
}

\(accessLevel)var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
.standardizedFileURL
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class DefaultTypeDeclarationGenerator: TypeDeclarationGenerator {
func generate(resourceTypeName: String, accessLevel: String?) -> String {
let accessLevel = accessLevel.map({ $0 + " " }) ?? ""

// let url = URL(filePath: "Library", relativeTo: URL(fileURLWithPath: "/System"))
// print(url.path(percentEncoded: false)) // iOS18: Library, iOS26: /System/Library
// print(url.standardizedFileURL.path(percentEncoded: false)) // All: /System/Library
return """
\(accessLevel)struct \(resourceTypeName): Equatable, Sendable {
\(accessLevel)let fontName: String
Expand All @@ -12,6 +15,7 @@ class DefaultTypeDeclarationGenerator: TypeDeclarationGenerator {
\(accessLevel)let symbolicTraits: CTFontSymbolicTraits
\(accessLevel)let relativePath: String
\(accessLevel)let bundle: Bundle
\(accessLevel)let url: URL

\(accessLevel)init(
fontName: String,
Expand All @@ -27,10 +31,7 @@ class DefaultTypeDeclarationGenerator: TypeDeclarationGenerator {
self.symbolicTraits = symbolicTraits
self.relativePath = relativePath
self.bundle = bundle
}

\(accessLevel)var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
.standardizedFileURL
}

Expand Down
7 changes: 3 additions & 4 deletions Tests/XCResourceCommandTests/Commands/FilesToSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ private enum Fixture {
public struct FileResource: Hashable, Sendable {
public let relativePath: String
public let bundle: Bundle
public let url: URL

public init(relativePath: String, bundle: Bundle) {
self.relativePath = relativePath
self.bundle = bundle
}

public var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
.standardizedFileURL
}

public var path: String {
Expand Down
7 changes: 3 additions & 4 deletions Tests/XCResourceCommandTests/Commands/FontsToSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ private enum Fixture {
public let symbolicTraits: CTFontSymbolicTraits
public let relativePath: String
public let bundle: Bundle
public let url: URL

public init(
fontName: String,
Expand All @@ -34,10 +35,8 @@ private enum Fixture {
self.symbolicTraits = symbolicTraits
self.relativePath = relativePath
self.bundle = bundle
}

public var url: URL {
return URL(filePath: relativePath, relativeTo: bundle.resourceURL).standardizedFileURL
self.url = URL(filePath: relativePath, relativeTo: bundle.resourceURL)\
.standardizedFileURL
}

public var path: String {
Expand Down
Loading