### Introduction
[block]
Welcome to the documentation for TagLibiOS, a library for iOS developers to read and write metadata information in various audio files.
[block style=”note”]
[blockIcon]
**Note**: This documentation assumes that you’re already familiar with iOS development and have a basic understanding of working with audio files.
[/block]
[/block]
### Installation
[block]
To integrate TagLibiOS into your iOS project, you can use either CocoaPods or manually add the library files to your project.
#### CocoaPods
[block]
1. If you haven’t already, install CocoaPods on your system by running the following command in the terminal:
“`bash
$ gem install cocoapods
“`
2. Navigate to your project’s root directory in the terminal.
3. Create a Podfile by running the following command:
“`bash
$ pod init
“`
4. Open the Podfile using your preferred text editor and add the following line:
“`ruby
pod ‘TagLibiOS’
“`
5. Save the Podfile and run the following command:
“`bash
$ pod install
“`
6. Open the generated `.xcworkspace` file and start using TagLibiOS in your project.
[/block]
[blockIcon]
Be sure to use `.xcworkspace` instead of `.xcodeproj` to open your project from now on.
[/blockIcon]
[/block]
#### Manual Installation
[block]
To manually add TagLibiOS to your project, you will need to follow these steps:
1. [Download TagLibiOS](https://github.com/example/taglibios/releases) and extract the zip file.
2. Drag the `TagLibiOS.framework` folder into your Xcode project’s `Frameworks` folder.
3. Make sure to set the framework to be “Embedded” and “Sign on Copy” in your project’s build settings.
4. Import the library in your Swift or Objective-C file using:
“`swift
import TagLibiOS
“`
or
“`objective-c
@import TagLibiOS;
“`
5. You can now start using TagLibiOS in your project.
[/block]
[blockIcon]
[block]
**Important**: When manually installing the library, make sure to manually manage library updates and include the latest versions as they become available.
[/block]
[/blockIcon]
### Usage
[block]
To start using TagLibiOS in your project, follow the examples below.
#### Reading Metadata
[block]
To read metadata information from an audio file, you can use the following code snippet:
“`swift
if let filePath = Bundle.main.path(forResource: “sample”, ofType: “mp3”) {
if let tag = TagLibFile(path: filePath)?.tag {
print(“Title: \(tag.title ?? “”)”)
print(“Artist: \(tag.artist ?? “”)”)
print(“Album: \(tag.album ?? “”)”)
print(“Year: \(tag.year ?? “”)”)
// Include additional metadata fields as needed
}
}
“`
[/block]
[/block]
#### Writing Metadata
[block]
To write or modify metadata information in an audio file, you can use the following code snippet:
“`swift
if let filePath = Bundle.main.path(forResource: “sample”, ofType: “mp3”) {
if let file = TagLibFile(path: filePath) {
var tag = file.tag
tag.title = “New Title”
tag.artist = “New Artist”
tag.album = “New Album”
tag.year = “2022”
// Set additional metadata fields as needed
file.save()
}
}
“`
[blockIcon]
[block]
**Note**: Make sure you have write permissions for the audio file you are trying to modify.
[/block]
[/blockIcon]
### License
[block]
TagLibiOS is released under the [MIT License](https://github.com/example/taglibios/blob/master/LICENSE). See the [LICENSE](https://github.com/example/taglibios/blob/master/LICENSE) file for more information.
[/block]
### More Resources
[block]
For more information and examples, you can visit the [official GitHub repository](https://github.com/example/taglibios) of TagLibiOS.
If you encounter any issues or have questions, feel free to [open an issue](https://github.com/example/taglibios/issues) on the GitHub repository.
[/block]