Flash for iPhone 4? Yes! Frash 0.02!

DISCLAIMER: The compiled binaries are based upon ALPHA code by COMEX. Code from the github repository can change minutely creating a significantly more stable version of code. DO NOT expect this compiled code to work on every Flash object or even be the slightest bit stable.

So, jailbreak for the iPhone 4 is out and comex seems to have gotten around to updating the Frash source on github for both iOS and iPhone 4. Hooray! I set out on a mission to compile it from scratch. Here I’ll detail the steps you need to produce to compile it and provide a pre-compiled binary for the less so technical (or lazy). This is essentially Frash version 0.02, but as noted before, the github repository can be updated at any time fixing any number of bugs.

As far as I know this will only work with armv7 devices, so: iPhone 3GS, iPod Touch 3G, iPad, iPhone 4. iOS4 / iPad 3.2.x only.

HOW TO INSTALL

1. Download the precompiled binary (Frash-0.02.deb | Mirror) and SFTP it to /tmp on your iPhone/iPad

2. SSH into your phone as root and type:

dpkg -i /tmp/Frash-0.02.deb

NOTE: If you had Frash 0.01 installed on your iPad, remove it first (look for it in Cydia packages). Also, I haven’t yet tested this on iPad, but it certainly works on iPhone 4 with iOS 4.0.1.

3. Reboot your device if you want, but you shouldn’t need to.

HOW TO COMPILE (ADVANCED USERS)

What you’ll need:

  • Mac OS X 10.6 with iPhone SDK 4.0 / 4.0.1 installed
  • git-osx-installer
  • libflashplayer.so from an Android 2.2 (Froyo) image (no link for this due to copyright issues, Google it!)
  • DebMaker-osx
  • ldid

Instructions:

1. Install git (just run the downloaded DMG) and check out the Frash git repository

git clone http://github.com/comex/frash.git
libflashplayer.so

2. Patch Xcode to compile Dynamic Libraries for iOS

a) Edit /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSProductTypes.xcspec

Make sure to place the code snippet in between the first “(” and the first “{“

    // 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
        );
    },

b) Edit /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSPackageTypes.xcspec

Make sure to place the code snippet in between the first “(” and the first “{“

    // 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;
        };
    },

3. Patch Xcode to allow compilation without a Provisioning Profile (i.e. not paying the $99 Apple tax)

a) Open /Developer/Platforms/iPhoneOS.platform/Info.plist and replace all instances of “XCiPhoneOSCodeSignContext” with “XCCodeSignContext”

4. Create a self-signed certificate to sign the Frash libraries

a) Open Applications > Utilities > Keychain Access

b) From the Keychain Access menu choose Certificate Assistant > Create a Certificate

c) Choose any name, set the type to “Self Signed Root”, check “Let me override defaults” and make it a “Code Signing” certificate

d) Specify any serial number, set the expiry to whatever you want. Longer than a year if you want to compile other iPhone libraries in the future.

e) Fill in any details for Certificate Information

f) Skip to the end of the wizard, using the default settings

5. Install ldid

a) Copy the ldid file to /usr/bin and make it executable (as root)

sudo cp ldid /usr/bin/
sudo chmod +x /usr/bin/ldid

6. Install DebMaker

a) Extract the DebMaker zip and extract dpkg-dep for later use

sudo cp DebMaker.app/Contents/Resources/dpkg-deb /usr/bin/
sudo chmod +x /usr/bin/dpkg-deb

7. Edit the default Xcode configuration for Frash

a) Open Player2/Player2.xcodeproj in Xcode

b) Make sure to switch the current configuration to Device 3.2 | Release

c) Open up “Get Info” for the Device 3.2 | Release configuration and  set the “Code Signing Identity” to the self-signed certificate made earlier and ensure the project is compiling for iPhone Device 3.2. Ignore warnings about setting to compile for armv6, keep it compiling for armv7.

d) Save the project and exit Xcode

8. Time to compile! Comex provides the build steps in the README for iPhone OS 3.2 but it needs to be changed slightly:

sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk /var/sdk
sudo export PATH=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
sudo cp -a /System/Library/Frameworks/IOSurface.framework/Versions/A/Headers Player2/IOSurface
sudo cp -a /System/Library/Frameworks/IOSurface.framework/Versions/A/Headers food/IOSurface
sudo cp -a /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/Headers food/CoreText
sudo cp -a /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ food/IOKit
sudo cp -a /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/Headers/ Player2/IOKit
sudo cp /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/Entitlements.plist .
sudo make -C rpc
sudo make -C utils
sudo make -C libgcc
sudo make -C food
sudo xcodebuild -alltargets -project Player2/Player2.xcodeproj

9. Now package it up into a deb

a) Edit DEBIAN/control and add a conflicts line to the end of the file. This will conflict with the Frash 0.01 deb released previously. You should remove that before installing this.

Conflicts: net.ozzapoo.frash

b) Place your copy of libflashplayer.so in the frash directory.

c) Modify fakeinstall to include libflashplayer.so by adding a line before “chown -R 501 iroot/var/mobile”

cp -a libflashplayer.so iroot/var/mobile/frash/

d) Make fakeinstall executable and run it as root. You should end up with a frash.deb file.

chmod +x fakeinstall
sudo ./fakeinstal
mv frash.deb Frash-0.02.deb

10. Hooray! Now follow the novice install section using the deb you just compiled (instead of the precompiled version, duh) to install Frash!

, , ,