← Back to TTTAttributedLabel/TTTAttributedLabel

How to Deploy & Use TTTAttributedLabel/TTTAttributedLabel

TTTAttributedLabel Deployment and Usage Guide

Prerequisites

  • iOS 8+ / tvOS 9+ - Minimum deployment target for the library
  • Xcode 7+ - Required development environment
  • Objective-C - The library is written in Objective-C
  • CocoaPods - Recommended dependency manager (optional but preferred)

Installation

Using CocoaPods (Recommended)

  1. Install CocoaPods if not already installed:

    sudo gem install cocoapods
    
  2. Create a Podfile in your project directory if it doesn't exist:

    pod init
    
  3. Add the following line to your Podfile:

    pod 'TTTAttributedLabel'
    
  4. Install the pod:

    pod install
    
  5. Open your project using the generated .xcworkspace file instead of .xcodeproj.

Manual Installation

  1. Download the source code from the repository:

    git clone https://github.com/TTTAttributedLabel/TTTAttributedLabel.git
    
  2. Add TTTAttributedLabel.h and TTTAttributedLabel.m files to your Xcode project.

  3. Ensure the files are added to your target in the "Build Phases" section.

Configuration

No additional configuration files or environment variables are required for TTTAttributedLabel. The library is designed as a drop-in replacement for UILabel and works out of the box.

Accessibility Configuration

For custom accessibility behavior, create a subclass and override the accessibilityElements method:

@interface CustomTTTAttributedLabel : TTTAttributedLabel
@end

@implementation CustomTTTAttributedLabel
- (NSArray *)accessibilityElements {
    // Custom accessibility implementation
}
@end

Build & Run

Development

  1. Open your project in Xcode using the .xcworkspace file (if using CocoaPods).

  2. Import the header in your view controller:

    #import <TTTAttributedLabel/TTTAttributedLabel.h>
    
  3. Create and configure the label:

    TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
    label.font = [UIFont systemFontOfSize:14];
    label.textColor = [UIColor darkGrayColor];
    label.numberOfLines = 0;
    
  4. Set text with attributes:

    NSString *text = @"Lorem ipsum dolor sit amet";
    [label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
        NSRange boldRange = [[mutableAttributedString string] rangeOfString:@"ipsum dolor" options:NSCaseInsensitiveSearch];
        
        UIFont *boldSystemFont = [UIFont boldSystemFontOfSize:14];
        CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
        if (font) {
            [mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:boldRange];
            CFRelease(font);
        }
        
        return mutableAttributedString;
    }];
    

Production

For production builds, ensure:

  1. All link detection and attributed string configurations are tested
  2. Accessibility features are properly configured for VoiceOver support
  3. Performance is validated with long text content

Deployment

TTTAttributedLabel is a library component, not a standalone application. Deploy your application containing TTTAttributedLabel to:

  • App Store - Standard iOS app distribution
  • Enterprise Distribution - For internal company apps
  • TestFlight - For beta testing

No special deployment steps are required for the library itself.

Troubleshooting

Common Issues and Solutions

1. Label not displaying attributed text

Issue: Text appears plain without attributes Solution: Ensure you're using setText: or setText:afterInheritingLabelAttributesAndConfiguringWithBlock: instead of attributedText property.

2. Link detection not working

Issue: URLs, phone numbers, or addresses aren't detected automatically Solution: Set the enabledTextCheckingTypes property:

label.enabledTextCheckingTypes = NSTextCheckingTypeLink | NSTextCheckingTypePhoneNumber | NSTextCheckingTypeAddress;

3. Memory leaks with Core Text

Issue: Memory warnings or leaks when using Core Text APIs Solution: Always release Core Text objects:

CTFontRef font = CTFontCreateWithName(...);
// Use font
CFRelease(font);

4. Accessibility elements not working

Issue: VoiceOver doesn't read links correctly Solution: Ensure you're using version 1.10.0 or later, and configure accessibility elements if needed.

5. Build errors with CocoaPods

Issue: "No such module 'TTTAttributedLabel'" Solution: Run pod install and open the .xcworkspace file, not .xcodeproj.

6. Text not inheriting label attributes

Issue: Custom attributes aren't being applied Solution: Use the afterInheritingLabelAttributesAndConfiguringWithBlock: method to ensure proper attribute inheritance.