---
title: "embedInCode(_:)"
framework: swift-package-manager
role: symbol
role_heading: Type Method
path: "swift-package-manager/documentation/packagedescription/resource/embedincode(_:)"
---

# embedInCode(_:)

Applies the embed rule to a resource at the given path.

## Declaration

```swift
static func embedInCode(_ path: String) -> Resource
```

## Parameters

- `path`: The path for a resource.

## Return Value

Return Value A Resource instance.

## Discussion

Discussion Use the embed rule to embed the bytes that represent the contents of a resource into executable code. For example,  if you embed the file identifier.txt that has the contents: Hello Swift Package manager generates a PackageResources class with each embedded resource as a static property based on the name of the resource. For the example above, the code generated by Package Manager is equivalent to the following source: struct PackageResources {     static let identifier_txt: [UInt8] = [72,101,108,108,111,32,83,119,105,102,116,10] }

## See Also

### Applying Rules

- [process(_:localization:)](swift-package-manager/documentation/packagedescription/resource/process(_:localization:).md)
- [Resource.Localization](swift-package-manager/documentation/packagedescription/resource/localization.md)
- [copy(_:)](swift-package-manager/documentation/packagedescription/resource/copy(_:).md)
