Skip to content

Commit 769e8d4

Browse files
heckjbripeticca
andauthored
extending the docs to explain how to use embedInCode (#9231)
Extends the PackageDescription documentation to explain how to use the .embedInCode rule for a resource. ### Motivation: The changelog originally included some detail, but it's missing from the documentation, so updating the API reference for PackageDescription to provide information about how to use .embedInCode. ### Modifications: Updated the .embedInCode documentation to show code blocks with an example of usage to illustrate how to use it. ### Result: Improved documentation for PackageDescription and the embedInCode resource rule --------- Co-authored-by: Bri Peticca <bripeticca@gmail.com>
1 parent ec430b8 commit 769e8d4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Sources/Runtimes/PackageDescription/Resource.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,20 @@ public struct Resource: Sendable {
9797

9898
/// Applies the embed rule to a resource at the given path.
9999
///
100-
/// You can use the embed rule to embed the contents of the resource into the executable code.
100+
/// Use the embed rule to embed the bytes that represent the contents of a resource into executable code.
101+
/// For example, if you embed the file `identifier.txt` that has the contents:
102+
/// ```
103+
/// Hello Swift
104+
/// ```
105+
///
106+
/// Package manager generates a PackageResources class with each embedded resource as a static property based on the name of the resource.
107+
/// For the example above, the code generated by Package Manager is equivalent to the following source:
108+
/// ```
109+
/// struct PackageResources {
110+
/// static let identifier_txt: [UInt8] = [72,101,108,108,111,32,83,119,105,102,116,10]
111+
/// }
112+
/// ```
113+
///
101114
/// - Parameter path: The path for a resource.
102115
/// - Returns: A `Resource` instance.
103116
@available(_PackageDescription, introduced: 5.9)

0 commit comments

Comments
 (0)