Skip to content

Configuring and Installing Frash

cmoski edited this page Sep 14, 2010 · 31 revisions

First, I’d like to say what great work comex has done on frash! As this small how-to is likely very incomplete and extremely beta, please feel free to add any modifications or correct any issues.

A Quick Note: The dev team asks that any sort of distribution framework not be used with frash at this point. As this codebase is in a very alpha stage, only if you have the requisite experience to compile, debug, and submit useful feedback to the Frash project, should you do so.

The reasoning behind this document is that although someone may not be well versed in compiling iPhone plugins of any sort, they may be solid developers looking for a way to contribute.

Before we begin, lets get a few pre-requites out of the way..

Things you’ll need:

  1. XCode 3.2.2 with iPhone SDK 3.2 Final or access to an XCode 3.2.2 installation
  2. GIT For OS X
  3. ldid and ldid2 (download)
  4. Snow Leopard 10.6.4
  5. An Android Image of libflashplayer.so (Froyo) placed in the frash directory (MD5-128: 92BDB647E57E00ECBC5FDCAFC51A184E, SHA1-160: 216CC00C86D3F3D79C84B3BF119F5CE6C9863711 — Just what I used, others may be different. File size: 8226 KB, armeabi variant)
  6. Jailbroken Apple iPad
  7. Cydia Installed
  8. RSync Installed
  9. SSH Client Installed

I. XCode & GIT Installation

Even if you have the latest version of XCode, you still probably don’t have the proper SDK files. You can obtain these one of two ways…

The first way is to find a developer with an old version of XCode installed, and take his /Developer/Platforms/iPhoneOS.platform/Developer/SDKs folder. This will give you specifically iPhoneOS3.1.3.sdk and iPhoneSimulator3.1.3.sdk, both of which we need for this process.

The second way is to simply uninstall your current version of XCode. You can do this by running the following in a terminal prompt:
sudo /Developer/Library/uninstall-devtools --mode=all
Now, simply install the older version of XCode linked above, and you’ll be good to go.

After you’ve installed the new version of XCode, you’ll need to install git and restart your shell environment.

You can test git by simply running the command ‘git’ in a shell prompt. Git is a source control system like SVN you’ll need to download the latest flash source.

In the new version of XCode, Apple removed all 3x SDKs, so you can no longer compile the plugin.

II. Hacking XCode

Now that you’ve installed XCode, you need to configure it so that it allows us to compile something useful without an Apple certificate. (Original)

The first step to this is to replace the code signing mechanism that XCode uses..


  • Open /Developer/Platforms/iPhoneOS.platform/Info.plist

  • Replace all occurrences of XCiPhoneOSCodeSignContext by XCCodeSignContext. There should be two of them, one around line 46 and another around line 79.

  • Save the file and restart Xcode.

Now that we’ve changed the XCode signing mechanism, we need to replace the actual application it uses to sign the code.

This application is ldid and ldid2. ldid2 is a script which calls ldid with special parameters required for signing iPad applications and post 3.1.x applications. Take the ldid and ldid2 that you downloaded from the requirements section, and place it in /usr/local/bin. (cp ldid* /usr/local/bin).

Now that ldid and ldid2 are in place, we need to ensure that they have proper executable access. In your terminal, type the following:

  1. chmod +x /usr/local/bin/ldid
  2. chmod +x /usr/local/bin/ldid2

Great, we’re almost done configuring XCode. We will now replace XCode’s default signing package codesign with ldid2.

Open up /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/Resources/iPhoneCodeSign.xcspec, and change CommandLine = “/usr/bin/codesign” to CommandLine = “/usr/local/bin/ldid2”;

Now that we’ve configured the certificate signing, we need to go through and properly set up XCode to build dynamic libraries for the iPad.
This requires adding a profile to XCode. Ensure that while adding this profile, you are keeping with the proper formatting of the document. Take a look at the existing blocks to assess how it is formatted, and be sure to keep it within the proper brackets. The original tutorial can be found here

Edit /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSProductTypes.xcspec and add the following profile:
// Dynamic library
{ Type = ProductType;
Identifier = com.apple.product-type.library.dynamic;
Class = PBXDynamicLibraryProductType;
Name = “Dynamic Library”;
Description = “Dynamic library”;
IconNamePrefix = “TargetPlugin”;
DefaultTargetName = “Dynamic Library”;
DefaultBuildProperties = {
FULL_PRODUCT_NAME = “$(EXECUTABLE_NAME)”;
MACH_O_TYPE = “mh_dylib”;
REZ_EXECUTABLE = YES;
EXECUTABLE_SUFFIX = “.$(EXECUTABLE_EXTENSION)”;
EXECUTABLE_EXTENSION = “dylib”;
PUBLIC_HEADERS_FOLDER_PATH = “/usr/local/include”;
PRIVATE_HEADERS_FOLDER_PATH = “/usr/local/include”;
INSTALL_PATH = “/usr/local/lib”;
DYLIB_INSTALL_NAME_BASE = “$(INSTALL_PATH)”;
LD_DYLIB_INSTALL_NAME = “$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)”;
DYLIB_COMPATIBILITY_VERSION = “1”;
DYLIB_CURRENT_VERSION = “1”;
FRAMEWORK_FLAG_PREFIX = “-framework”;
LIBRARY_FLAG_PREFIX = “-l”;
LIBRARY_FLAG_NOSPACE = YES;
STRIP_STYLE = “debugging”;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
CODE_SIGNING_ALLOWED = YES;
};
PackageTypes = (
com.apple.package-type.mach-o-dylib // default
);
},

Also add the following profile to /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSPackageTypes.xcspec:

// Mach-O dynamic library { Type = PackageType; Identifier = com.apple.package-type.mach-o-dylib; Name = “Mach-O Dynamic Library”; Description = “Mach-O dynamic library”; DefaultBuildSettings = { EXECUTABLE_PREFIX = ""; EXECUTABLE_SUFFIX = ""; EXECUTABLE_NAME = “$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)”; EXECUTABLE_PATH = “$(EXECUTABLE_NAME)”; }; ProductReference = { FileType = compiled.mach-o.dylib; Name = “$(EXECUTABLE_NAME)”; IsLaunchable = NO; }; },

Save all open files and restart XCode.

III. Getting The Source

Pop open the terminal, and navigate to your desktop (cd ~/Desktop) and lets start a GIT checkout. The main repoistory is at comex’s frash master, however we’ll be using a branch made by kangaroo which fixes a few problems with the main repository for this somewhat over alliterative example.

comex’s branch:
git clone http://github.com/comex/frash.git

Kangaroos Branch:
git clone http://github.com/kangaroo/frash.git

GIT will run and make a ‘clone’ or a copy of the codebase to your local computer.

Now that you have a codebase copied, there are a few files you need to go scavenge for to make a local copy.. Make sure you’re at the ~/Desktop/frash directory, as in our example. Type in the following:

cp -a /System/Library/Frameworks/IOSurface.framework/Versions/A/Headers Player2/IOSurface
cp -a /System/Library/Frameworks/IOSurface.framework/Versions/A/Headers food/IOSurface
cp -a /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ food/IOKit
cp -a /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ Player2/IOKit
ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk /var/sdk
export PATH=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/usr/local/bin:$PATH

The first few commands copy the versions of the SDK that were installed by XCode to your local tree.

The link command (ln) creates a symbolic link, defining the iPhoneOS.platform 3.1.3 SDK as your primary SDK for linking, as definined in the make files. If you encounter compile errors, check to make sure /var/sdk exists (ls /var/sdk)

The last one adds the developer directory to your path, as well as /usr/bin to your path as well as /usr/local/bin

IV. The Right Key to Unlock The Door…

Now that we’ve completed XCode configuration, we need to create a self signed key which allows us to sign our code with some signature.. Any signature..

Use spotlight to find keychain access. Click KeyChain Access, Certificate Assistant, Create a Certificate.
Under Name, type iPhone Developer (case sensitive)
Under Identity Type: Self Signed Root
Under Certificate Type: Code Signing

Now hit continue. This will create a certificate for iPhone Developer. The repoistory and XCode project is pre-configured to accept a certificate with this exact common name.

We’re done with certificates.. You may have to modify the certificate in use if you are using a different repository.

Note: This is the lazy way to go to allow a self signed certificate used in Kangaroo’s repository to compile without error, and the fastest way to get it ‘up and running.’ Signing is certainly not a requirement, as ldid2 fundamentally takes the place of this signing process near the end of the build.

V. Compiling

Each command listed here must be run from the main repository directory.

Type the following (please note any errors):

  1. make -C rpc
  2. make -C utils
  3. make -C libgcc
  4. make -C food
  5. xcodebuild -alltargets -project Player2/Player2.xcodeproj

If all goes smoothly, you should now have a fully functioning, and built frash installation. The only thing left is to install it!

VI. The Installation

Copy and paste the following installation script (thanks Kangaroo!) in a file called install2 in your frash directory.

Make sure to chmod +x install2, and MAKE SURE ‘libflashplayer.so’ is located in your frash directory.

#!/bin/sh
IP=“your-ipads-ip”
set -e
pushd icu
for i in libicudata.42.1.dylib libicuio.42.1.dylib; do install_name_tool -change ../lib/libicudata.42.1.dylib libicudata.42.1.dylib $i; done
popd
rsync -avz food/food{,.sb,.plist,_wrapper} utils/lib{c,}utils.dylib icu/*.dylib libflashplayer.so libgcc/libgccstuff.dylib oem.cfg root@$IP:/var/mobile/frash/
rsync -avz Frash.webplugin/ root@$IP:‘/System/Library/Internet\ Plug-Ins/Frash.webplugin’
rsync -avz Player2/build/Release-iphoneos/Plugin.dylib root@$IP:‘/System/Library/Internet\ Plug-Ins/Frash.webplugin/’

This script works as of July 6th, 2010 and may not work with later builds! PLEASE ALWAYS USE INSTALL.SH PROVIDED WITH THE BUILD! THIS IS AN ALTERNATIVE ONLY

Please be sure to replace your iPad’s IP with the one listed in the script. Also make sure you’ve installed RSYNC from Cydia, as the command will fail.

After this script runs, ensure that on your iPad, ‘/System/Library/LaunchDaemons/food.plist’ exists. If not, copy it from /var/mobile/frash. You can verify this by executing the following twice: launchctl load /System/Library/LaunchDaemons/food.plist

If the daemon has loaded properly, the first time you execute this command you should see no output. The second time it should tell you that the port is in use. The daemon is now started properly, and you’ve installed Frash!

Reboot the iPad.

VII. A Word On Directory Paths

If you are tempted to copy these files over by SFTP, be very careful to maintain all of the symlinks. Very bad things could occur if you ignore the symlinks on the libraries, and your installation of Frash just won’t work.

Also, you can use the launchctl command to test that the daemon is loading properly. Also verify that the plugin is located in /System/Library/Internet Plug-Ins/Frash.webplugin/, and that the plugin file is present in that directory.

VIII. Appendix

Q: What is the proper structure of /var/mobile/frash?
A:
-rwxrwxrwx 1 root staff 138256 Jul 5 21:54 food*
-rwxrwxrwx 1 root staff 736 Jul 5 21:51 food.plist*
-rwxrwxrwx 1 root staff 1181 Jul 5 21:51 food.sb*
-rwxrwxrwx 1 root staff 14324 Jul 5 21:54 food_wrapper*
-rwxrwxrwx 1 root staff 58232 Jul 5 21:52 libcutils.dylib*
-rwxrwxrwx 1 root staff 8422664 Jul 5 21:57 libflashplayer.so*
-rwxrwxrwx 1 root staff 45372 Jul 5 21:53 libgccstuff.dylib*
-rwxrwxrwx 1 root staff 16015524 Jul 6 00:10 libicudata.42.1.dylib*
lrwxr-xr-x 1 root staff 21 Jul 5 21:51 libicudata.42.dylib → libicudata.42.1.dylib*
lrwxr-xr-x 1 root staff 21 Jul 5 21:51 libicudata.dylib → libicudata.42.1.dylib*
-rwxrwxrwx 1 root staff 2271060 Jul 5 21:51 libicui18n.42.1.dylib*
lrwxr-xr-x 1 root staff 21 Jul 5 21:51 libicui18n.42.dylib → libicui18n.42.1.dylib*
lrwxr-xr-x 1 root staff 21 Jul 5 21:51 libicui18n.dylib → libicui18n.42.1.dylib*
-rwxrwxrwx 1 root staff 49368 Jul 6 00:10 libicuio.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicuio.42.dylib → libicuio.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicuio.dylib → libicuio.42.1.dylib*
-rwxrwxrwx 1 root staff 315456 Jul 5 21:51 libicule.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicule.42.dylib → libicule.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicule.dylib → libicule.42.1.dylib*
-rwxrwxrwx 1 root staff 57744 Jul 5 21:51 libiculx.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libiculx.42.dylib → libiculx.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libiculx.dylib → libiculx.42.1.dylib*
-rwxrwxrwx 1 root staff 134600 Jul 5 21:51 libicutu.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicutu.42.dylib → libicutu.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicutu.dylib → libicutu.42.1.dylib*
-rwxrwxrwx 1 root staff 1491120 Jul 5 21:51 libicuuc.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicuuc.42.dylib → libicuuc.42.1.dylib*
lrwxr-xr-x 1 root staff 19 Jul 5 21:51 libicuuc.dylib → libicuuc.42.1.dylib*
-rwxrwxrwx 1 root staff 297192 Jul 5 21:53 libutils.dylib*
-rwxrwxrwx 1 root staff 743 Jul 5 21:51 oem.cfg*

Q: What is the structure of /System/Library/Internet Plug-Ins/Frash.webplugin?
A:
-rwxrwxrwx 1 root staff 1397 Jul 5 21:51 Info.plist*
-rwxr-xr-x 1 root staff 53168 Jul 6 00:07 Plugin.dylib*
-rwxrwxrwx 1 root staff 21225 Jul 5 21:51 logo.jpg*

Q: Why do I get a black screen?
A: The most common reason for this is that for some reason, the food daemon is not loadable. Please see the section on ensuring that the plist is in place in the startup daemons folder.

Q: Where is the debug spew?
A: Grab the syslog daemon, and check /var/log/syslog.

Q: I have architecture not available issues..
A: As far as I can tell, XCode has changed something about it handles architectures in the newer versions. I’ve only seen these errors when attempting to use the latest version of XCode. My best suggestion would be to downgrade XCode for the build..

Q: Compile Error: target specifies product type ‘com.apple.product-type.library.dynamic’, but there’s no such product type for the ‘iphoneos’ platform..
A: In this case, please see the Hacking XCode section and ensure that /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSProductTypes.xcspec and /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSPackageTypes.xcspec are modified correctly. This is XCode complaining that it doesn’t know how to build the player2 plugin as XCode isn’t configured by default to build any sort of iPhone Plugin.

Q: Unexpected Error?
A: Please ensure your running the correct armeabi varient of libflashplayer.so and it is placed in /var/mobile/frash. See MD5 sum at the beginning of this document.

Thanks to everyone working on Frash!
cmoski