FRAppliance 200

From AwkwardTV
Jump to: navigation, search


This is an update to FRAppliance_101 to make it compatible with the Take 2 update. The instructions were copied over from that page and updated to meet the new requirements. The code provided was mainly written by EricIII in his Hello World and ATVFiles projects. This is designed for Take 2 only. The headers linked in this document are not backwards compatible to 1.0 or 1.1.


Preparing the Environment

These steps only need to be performed once.

  1. Install Xcode and especially the Mac OS X 10.4 Universal (10.4u) SDK.
  2. Copy the BackRow.framework and iPhotoAccess.framework from /System/Library/PrivateFrameworks on the Apple TV to some place on your computer. I recommend placing these in the same folder your project folder will be created.

Installing the Headers

The headers need to be placed in the appropriate location for the compiler to find them. BackRow.framework depends on some private headers inside QuartzComposer.framework, so we have to put headers in there too.

  1. Open the BackRow.framework folder, and in there extract BRPrivateHeaders20 ( to the PrivateHeaders folder. (The ZIP file contains a PrivateHeaders folder, so just move that there.)
  2. In /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Quartz.framework/Frameworks/QuartzComposer.framework, extract QCPrivateHeaders ( to the PrivateHeaders folder (same deal as above).
  3. In /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Quartz.framework/Frameworks/QuartzComposer.framework/Headers/QuartzComposer.h, add this line to the end:
    #import <QuartzComposer/QuartzComposerPrivate.h>

Warning: I am new to development on OS X. The Private Headers in the were generated using class-dump. In order to get the project to compile, I had to modify the generated files. I fixed what I could, and the rest I just commented out. The commented out part might be problem later on.

Creating the Plugin

Now the fun stuff starts, actually creating the plugin.

Making the Project

Launch Xcode, and create a new Cocoa Bundle project (File > New Project...). Name it "HelloWorld".

At this point, you have an empty project with no code. You now need to specify the frameworks to link to.

Adding Frameworks

In the Frameworks and Libraries group, drag BackRow.framework and iPhotoAccess.framework to the Linked Frameworks group. In the dialog that pops up, make sure "Copy items into destination group's folder" is unchecked and choose a Reference Type of "Default". In "Add to Targets," the HelloWorld target should be checked. Click "Add".

At this point, you should have three frameworks listed underneath "Linked Frameworks:" BackRow.framework, iPhotoAccess.framework, and Cocoa.framework.

Creating the Plugin

Open InfoPlist.strings (for English) and add the following lines:

 CFBundleName = "Hello, World!";

The CFBundleName is the label that will be given in the main menu.

The Main Appliance Class

Now you are finally write some code! Right click on the Classes group and choose Add > New File..., under Cocoa add an Objective-C class and give it a name of "HelloWorldAppliance". Check "Also create HelloWorldAppliance.h", make sure you're adding to project HelloWorldTest, and the HelloWorld target is checked. Click on "Finish".

Open HelloWorldAppliance.h and change it so that your HelloWorldAppliance class inherits from BRBaseAppliance. Change "NSObject" in the line beginning with "@interface" to read "BRBaseAppliance".

 @interface HelloWorldAppliance : BRBaseAppliance {

You also need to add the following line to the header, just underneath the existing "#import" line:

 #import <BackRow/BackRow.h>

Open HelloWorldAppliance.m now, and in order to bypass the plugin whitelist, you must put the following code in the HelloWorldAppliance implementation. Add this code before the @end line:

// Override to allow FrontRow to load custom appliance plugins
+ (NSString *) className {
    // this function creates an NSString from the contents of the
    // struct objc_class, which means using this will not call this
    // function recursively, and it'll also return the *real* class
    // name.
    NSString * className = NSStringFromClass( self );
	// new method based on the BackRow NSException subclass, which conveniently provides us a backtrace
	// method!
	NSRange result = [[BRBacktracingException backtrace] rangeOfString:@"(in BackRow)"];
	if(result.location != NSNotFound) {
		NSLog(@"+[%@ className] called for whitelist check, so I'm lying, m'kay?", className);
		className = @"RUIDVDAppliance";
	return className;

When the menu item is selected, the -controllerForIdentifier: method is called on your BRBaseAppliance subclass. This method needs to return a controller for your display. (Note: I'll write more on how the displays actually work in the future, but it's essentially a stack of controllers that are pushed to go deeper in the hierarchy and popped to go back.)

The following implementation uses the BRAlertController class to display a simple "Hello, World" message when the item is selected.

- (id)controllerForIdentifier:(id)identifier {
	BRAlertController *alert = [BRAlertController alertOfType:0
               titled:@"Hello, World!"
               primaryText:@"Hello from my first Apple TV plugin!"
	return alert;

This section of code reads the categories. Categories are what appear in the right menu. The following code creates the categories. This just creates a menu option "Display". If applianceCategories is empty it will crash You need to populate the categories array with at least 1 value.

-(id)applianceCategories {
	NSMutableArray *categories = [NSMutableArray array];

        // manually create a category
	BRApplianceCategory *category = [BRApplianceCategory categoryWithName:[BRLocalizedStringManager appliance:self localizedStringForKey:@"Current" inFile:nil]  identifier:@"Display" preferredOrder:100];
	[categories addObject:category];
	return categories;

Building the Plugin

This isn't very hard, but you have to set some settings first.

Build Settings

Before you can properly build, you must adjust some build settings to build for the Apple TV environment.

Under the "Targets" group on the left side of the Xcode project window, right click on the "HelloWorld" target and choose "Get Info."

On the "Properties" tab, change Identifier to something unique, such as "". Change the Creator to "fnrw", and set Principal Class to "HelloWorldAppliance" (this must match the BRAppliance subclass for your plugin). Note: As of the Apple TV 1.1 update, the bundle identifier must begin with "" See June 20 2007 Patch (aka the YouTube Patch) for details.

On the "Build" tab, set configuration to "All Configurations" and then set the build settings as follows:

In the "Architectures" collection, double click on the Architectures setting and make sure only Intel is checked. This is a value of "i386".

In "Build Locations," make sure the SDK Path is set to "/Developer/SDKs/MacOSX10.4u.sdk" (it should be by default).

In "Linking," make sure ZeroLink is unchecked.

In "Packaging," set the Wrapper Extension to "frappliance".

In "Language" (underneath "GNU C/C++ Compiler 4.0"), make sure "Enable Objective-C Exceptions" is checked.


At this point, you can just click Build to build the plugin. The compiled version will appear in build/Debug/HelloWorldTest.frappliance in your project folder. The whitelist workaround causes some warnings when building, but those can be ignored.

Running the Plugin

To run it, just copy the built version to /System/Library/CoreServices/ on the Apple TV. I really recommend at least creating a symlink to the frappliance in the frontrow home directory, if not directly mounting the project from your development system, but both are beyond the scope of the tutorial.

After it's in place on the Apple TV, you need to restart Finder (either with killall Finder if you have killall installed, otherwise use ps awx|grep Finder to get the PID and then kill PID.)

Now when you choose the "Hello, World!" menu item on the Apple TV, you should see the message!


If you've successfully made it this far, you've created your first plugin!

Submit it to so that others can find it.

A completed xcode project can be found at This is set up for the two frameworks are in the same folder as the HelloWorld project folder.

Revision History

  • March 05, 2008
    • Created.