Page 2 of 15 FirstFirst 123456789101112 ... LastLast
Results 11 to 20 of 144
Discuss [XCode Template] for SDK and Open Toolchain API in firmware 2.0 at the iPhone Developer Exchange - Hackint0sh.org; With this wonderful tool, you can now update the open toolchain header from your SDK. ...
  1. #11
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    With this wonderful tool, you can now update the open toolchain header from your SDK. This works for the iPhone SDK

    http://www.hackint0sh.org/forum/show...ght=class-dump

    Updated: class-dump-x (It works for iPhone binary as well)
    http://iphone.freecoder.org/classdump_en.html

    For example, run this to dump all the header files for UIKit to your current directory.

    Code:
    class-dump -H /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit
    If you use this method to update the header files of open toolchain, some header files will have this at the start
    Code:
    #import "NSObject.h"
    and you have to change it to
    Code:
    #import <Foundation/NSObject.h>
    in order to remove the compiler missing file error.
    Last edited by javacom; 08-19-2008 at 10:32 AM. Reason: Updated: class-dump-x


  2. #12
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    In order to make use of the UITouch and UIEvent in the SDK for the open toolchain project, you can update the header file using the class-dump.

    Alternatively, you can add the following headers in order to use the touch handling events (such as touchesBegan, touchesMoved and touchesEnded methods etc) in the SDK

    Code:
    typedef unsigned int NSUInteger;
    #import <UIKit/UITouch.h>
    #import <UIKit/UIEvent.h>
    To demonstrate the use of these touch handling events such as double tap and swipe, here is a sample code for the open toolchain header. This has been tested under SDK beta3 and iPhone OS 2.0 5A240d (pwned)

    If you use SDK beta2 to compile, there will be error as Apple has changed the enum of UITouch in SDK beta3

    Code:
    /*
     HelloTouch.app
     main.m
    */
    
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    
    // include for the sdk compiler and open toolchain header
    
    #ifndef UIKIT_UIFont_UIColor_H
    #define UIKIT_UIFont_UIColor_H
    typedef float CGFloat;
    #import <UIKit/UIFont.h>
    #import <UIKit/UIColor.h>
    #endif
    
    
    #ifndef UIKIT_UISlider_H
    #define UIKIT_UISlider_H
    #import <UIKit/UISliderControl.h>
    @interface UISlider : UISliderControl
    @property float value;                                 // default 0.0. this value will be pinned to min/max
    @property float minimumValue;                          // default 0.0. the current value may change if outside new min value
    @property float maximumValue;                          // default 1.0. the current value may change if outside new max value
    
    @property(retain) UIImage *minimumValueImage;          // default is nil. image that appears to left of control (e.g. speaker off)
    @property(retain) UIImage *maximumValueImage;          // default is nil. image that appears to right of control (e.g. speaker max)
    @end
    #endif
    
    #ifndef UIKIT_UITouch_UIEvent_H
    #define UIKIT_UITouch_UIEvent_H
    typedef unsigned int NSUInteger;
    #import <UIKit/UITouch.h>
    #import <UIKit/UIEvent.h>
    #endif
    
    @interface HelloTouch : UIApplication
    {
    	UIWindow *window;
    	UIImageView *imgView[2];
    	UIView *mainView;
    	UISlider *slider;
    }
    - (void) handleSlider: (id)unused;
    @end
    
    @implementation  HelloTouch
    
    - (void) applicationDidFinishLaunching: (NSNotification *)aNotification
    {
    	[UIHardware _setStatusBarHeight:0.0f];
    	[self setStatusBarMode:2 duration:0.0f];
    	[self setStatusBarHidden:YES animated:NO];  // hide status bar
    
    	CGRect rect = [UIHardware fullScreenApplicationContentRect];
    	rect.origin.x = rect.origin.y = 0.0f;
    	window = [[UIWindow alloc] initWithContentRect: rect];
    	mainView = [[UIView alloc] initWithFrame:rect];
    	imgView[0] = [[UIImageView alloc] initWithImage:[UIImage imageAtPath:@"/System/Library/CoreServices/SpringBoard.app/Activate.png"]];
    	imgView[1] = [[UIImageView alloc] initWithImage:[UIImage imageAtPath:@"/System/Library/CoreServices/SpringBoard.app/applelogo.png"]];
    	[imgView[0] setBackgroundColor:[UIColor clearColor]];
    	[imgView[0] setOrigin:CGPointMake(112,0)];
    	[imgView[1] setOrigin:CGPointMake(125,178)];
    	[imgView[1] setBackgroundColor:[UIColor clearColor]];
    	[mainView addSubview: imgView[0] ];
    
    	slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 380, 280, 40)];
    	[slider setShowValue:NO];
    	[slider addTarget:self action:@selector(handleSlider:) forEvents:7]; // 7=drag, 2=up
    	slider.minimumValue = 0.0;
    	slider.maximumValue = 10.0;
    	slider.value = 1.0;
    	[mainView addSubview:slider];	
    
    
    	[mainView becomeFirstResponder];
    	[window setContentView: mainView];
    	[window orderFront: self];
    	[window makeKeyAndVisible];
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        NSUInteger numTaps = [[touches anyObject] tapCount];
    	if(numTaps >= 2) {
    		if (numTaps == 2) {  //double tap
    			if ([slider isEnabled]) {
    				[slider setEnabled:NO];
    				[slider removeFromSuperview];
    			}
    			else {
    				[slider setEnabled:YES];
    				[mainView addSubview:slider];
    			}
    		}
    	} 	
    }
    
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {  
    	// Enumerates through all touch objects
        for (UITouch *touch in touches){
    	    // Check for a swipe. Not all move events are swipes. A swipe can have two directions, such as down, right.
    	    if (touch.info & UITouchInfoSwipedDown) {
    			[slider removeFromSuperview];	
    		} else if (touch.info & UITouchInfoSwipedUp ) {
    			[mainView addSubview:slider];
    		} else if (touch.info & UITouchInfoSwipedRight) {
    			[imgView[0] removeFromSuperview];	
    			[mainView addSubview:imgView[1]];
    		} else if (touch.info & UITouchInfoSwipedLeft) {
    			[imgView[1] removeFromSuperview];	
    			[mainView addSubview:imgView[0]];
    		}
    	}
    }
    
    - (void) handleSlider: (id)unused
    {
    	if (slider.value == 0.0) {
    		[mainView setBackgroundColor:[UIColor whiteColor]];
    	}
    	else if (slider.value <= 1.0) {
    		[mainView setBackgroundColor:[UIColor grayColor]];
    	}
    	else if (slider.value <= 2.0) {
    		[mainView setBackgroundColor:[UIColor redColor]];
    	}
    	else if (slider.value <= 3.0) {
    		[mainView setBackgroundColor:[UIColor greenColor]];
    	}
    	else if (slider.value <= 4.0) {
    		[mainView setBackgroundColor:[UIColor blueColor]];
    	}
    	else if (slider.value <= 5.0) {
    		[mainView setBackgroundColor:[UIColor cyanColor]];
    	}
    	else if (slider.value <= 6.0) {
    		[mainView setBackgroundColor:[UIColor yellowColor]];
    	}
    	else if (slider.value <= 7.0) {
    		[mainView setBackgroundColor:[UIColor magentaColor]];
    	}
    	else if (slider.value <= 8.0) {
    		[mainView setBackgroundColor:[UIColor orangeColor]];
    	}
    	else if (slider.value <= 9.0) {
    		[mainView setBackgroundColor:[UIColor purpleColor]];
    	}
    	else if (slider.value <= 10.0) {
    		[mainView setBackgroundColor:[UIColor brownColor]];
    	}
    	else {
    		[mainView setBackgroundColor:[UIColor whiteColor]];
    	}
    } 
    @end
    
    int main(int argc, char *argv[]) {
    	int returnCode;
    	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    	returnCode = UIApplicationMain(argc, argv, [HelloTouch class]);
    	[pool release];
    	return returnCode;
    }

    Last edited by javacom; 05-14-2008 at 09:24 AM.

  3. #13
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    You need UIAccelerometer.h, in order to use the Accelerometer for the firmware 2.0 using the open toolchain API
    Code:
    #import <UIKit/UIAccelerometer.h>
    There is an example code for the Accelerometer using the open toolchain (for firmware 1.1.x) by Erica Sadun
    http://www.tuaw.com/2007/09/10/iphon...accelerometer/

    But the code will not work under iPhone OS 2.0 as Apple has changed the API. You need to add UIAccelerometer.h, override the accelerometer: didAccelerate: method and set the delegate.
    Code:
    - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;
    Here is the sample code that modified from the original (as in those #ifdef ASPEN blocks) in order to build and run using the open toolchain template for the SDK of this thread

    I have added the meaning of X, Y, Z in the sample code as per Erica, but the range of values should now go from 1.0 to -1.0

    Code:
    /*
     HelloSensor.app
     main.m
    */
    
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    #import <UIKit/UIWindow.h>
    #import <UIKit/UIHardware.h>
    #import <UIKit/UIApplication.h>
    #import <UIKit/UIImageView.h>
    #import <UIKit/UIImage.h>
    #import <UIKit/UITextView.h>
    #include <stdio.h>
    #include <time.h>
    #include <math.h>
    
    #ifdef ASPEN
    #ifndef UIKIT_UIFont_UIColor_H
    #define UIKIT_UIFont_UIColor_H
    typedef float CGFloat;
    #import <UIKit/UIFont.h>
    #import <UIKit/UIColor.h>
    #endif
    
    #ifndef UIKIT_UIAccelerometer_H
    #define UIKIT_UIAccelerometer_H
    #import <UIKit/UIAccelerometer.h>
    #define kUpdateFrequency 10  // Hz
    #endif
    
    #endif
    
    
    #ifdef ASPEN
    @interface HelloSensor : UIApplication <UIAccelerometerDelegate> 
    #else
    @interface HelloSensor : UIApplication 
    #endif
    {
            UIWindow     *window;
    		UIView       *mainView;
            UITextView   *textView;
            UIImageView  *xarrow;
    }
    #ifdef ASPEN
    - (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz;
    - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;
    #endif
    @end
    
    @implementation HelloSensor
    
    
    #ifdef ASPEN
    // UIAccelerometer delegate method in SDK
    - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
    	[self acceleratedInX:acceleration.x Y:acceleration.y Z:acceleration.z];
    }
    #endif
    
    /*
    The meaning of X, Y, Z by Erica Sadun
    X = Roll X corresponds to roll, or rotation around the axis that runs from your home button to your earpiece. 
        Values vary from 0.5 (rolled all the way to the left) to -0.5 (rolled all the way to the right).
    
    Y = Pitch. Place your iPhone on the table and mentally draw a horizontal line about half-way down the screen. 
        That's the axis around which the Y value rotates. 
    	Values go from 0.5 (the headphone jack straight down) to -0.5 (the headphone jack straight up).
    
    Z = Face up/face down. I expected the Z value to correspond to yaw. And it does not. 
        It refers to whether your iPhone is face up (-0.5) or face down (0.5). 
    	When placed on it side, either the side with the volume controls and ringer switch, or the side directly opposite
    	, the Z value equates to 0.0.
    */
    
    - (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz
    {
       // Create Status feedback string
       NSString *xstring = [NSString stringWithFormat:
          @"X (roll, %4.1f%%): %f\nY (pitch %4.1f%%): %f\nZ (%4.1f%%) : %f",
          100.0 - (xx + 0.5) * 100.0, xx, 
          100.0 - (yy + 0.5) * 100.0, yy, 
          100.0 - (zz + 0.5) * 100.0, zz];
       [textView setText:xstring];
    
       // Revert Arrow and then rotate to new coords
       [xarrow setTransform:CGAffineTransformIdentity];
       float angle = atan2(yy, xx);
       angle *= 180.0/3.14159;
       [xarrow setRotationBy:angle];
    }
    
    
    - (void) applicationDidFinishLaunching: (id) unused
    {
    #ifdef ASPEN
    	[UIHardware _setStatusBarHeight:0.0f];
    	[self setStatusBarMode:2 duration:0.0f];
    	[self setStatusBarHidden:YES animated:NO];  // hide status bar
    #endif
    
        struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
        rect.origin.x = rect.origin.y = 0.0f;
        window = [[UIWindow alloc] initWithContentRect: rect];
        mainView = [[UIView alloc] initWithFrame: rect];
    
        textView = [[UITextView alloc] initWithFrame:
              CGRectMake(0.0, 0.0, 320.0, 480.0)];
        [textView setEditable:NO];
    #ifdef ASPEN
        [textView setFont:[UIFont systemFontOfSize:24]];
    #else
        [textView setTextSize:24];
    #endif
        [mainView addSubview: textView];
    
    // I changed the arrow by getting it from Notes app
    	xarrow = [[UIImageView alloc] initWithFrame: CGRectMake(135.0, 320.0, 50.0, 46.0)];
    	UIImage *img = [[UIImage imageAtPath:@"/Applications/MobileNotes.app/arrow right.png"] retain];
    
    //  If you want the original arrow get it from http://www.tuaw.com/2007/09/10/iphone-coding-using-the-accelerometer/
    //  xarrow = [[UIImageView alloc] initWithFrame: CGRectMake(50.0, 320.0, 200.0, 50.0)];
    //	[[UIImage imageAtPath:[[NSBundle mainBundle] pathForResource:@"arrow" ofType:@"png" inDirectory:@"/"]] retain];
    
    
        [xarrow setImage:img];
        [textView addSubview:xarrow];
    
        [window orderFront: self];
        [window setContentView: mainView];
    
    #ifdef ASPEN
        [window makeKeyAndVisible];
    	[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kUpdateFrequency)];
    	[[UIAccelerometer sharedAccelerometer] setDelegate:self];
    #else
    	[window makeKey: self];
        [window _setHidden: NO];
    #endif
    
    }
    @end
    
    int main(int argc, char *argv[]) {
    	int returnCode;
    	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    	returnCode = UIApplicationMain(argc, argv, [HelloSensor class]);
    	[pool release];
    	return returnCode;
    }
    Last edited by javacom; 05-16-2008 at 12:43 PM.

  4. #14
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    Multitouch is default disabled in the UIView for firmware 2.0 SDK. To enable it
    Code:
    	[myView setMultipleTouchEnabled:YES];
    this method is not in the Open Toolchain header but in the class-dump of SDK and also in the property directives of the SDK header file here
    Code:
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIView.h
    The property directives offer some convenient ways of getter and setter methods for the Objective C 2.0, such as
    Code:
    	gameView.multipleTouchEnabled=YES;
    	xarrow.hidden = !debuginfo;
    	label1.hidden = imgView.hidden = NO;
    	imgView.center = mainView.center;
    It is better to add these property directives to the project file, and once added, the property directives are available to the UIView class and its subclasses e.g. UIImageView

    Code:
    #import<UIKit/UIView.h>
    
    typedef int NSInteger;
    
    typedef enum {
        UIViewAnimationCurveEaseInOut,         // slow at beginning and end
        UIViewAnimationCurveEaseIn,            // slow at beginning
        UIViewAnimationCurveEaseOut,           // slow at end
        UIViewAnimationCurveLinear
    } UIViewAnimationCurve;
    
    typedef enum {
        UIViewContentModeScaleToFill,
        UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent
        UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped.
        UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)
        UIViewContentModeCenter,              // contents remain same size. positioned adjusted.
        UIViewContentModeTop,
        UIViewContentModeBottom,
        UIViewContentModeLeft,
        UIViewContentModeRight,
        UIViewContentModeTopLeft,
        UIViewContentModeTopRight,
        UIViewContentModeBottomLeft,
        UIViewContentModeBottomRight,
    } UIViewContentMode;
    
    typedef enum {
        UIViewAnimationTransitionNone,
        UIViewAnimationTransitionFlipFromLeft,
        UIViewAnimationTransitionFlipFromRight
    } UIViewAnimationTransition;
    
    enum {
        UIViewAutoresizingNone                 = 0,
        UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
        UIViewAutoresizingFlexibleWidth        = 1 << 1,
        UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
        UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
        UIViewAutoresizingFlexibleHeight       = 1 << 4,
        UIViewAutoresizingFlexibleBottomMargin = 1 << 5
    };
    
    @interface UIView(UIResponder)
    
    @property(getter=isUserInteractionEnabled)  BOOL      userInteractionEnabled;  // default is YES. if set to NO, user events (touch, keys) are ignored and removed from the event queue.
    @property                                   NSInteger tag;                     // default is 0
    //@property(readonly, retain)                 CALayer  *layer;                   // returns view's layer. Will always return a non-nil value. view is layer's delegate
    
    @end
    
    
    @interface UIView(UIViewGeometry)
    // animatable. do not use frame if view is transformed since it will not correctly reflect the actual location of the view. use bounds + center instead.
    @property CGRect            frame;
    
    // use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part
    @property CGRect            bounds;      // default bounds is zero origin, frame size. animatable
    @property CGPoint           center;      // center is center of frame. animatable
    @property CGAffineTransform transform;   // default is CGAffineTransformIdentity. animatable
    
    @property(getter=isMultipleTouchEnabled) BOOL   multipleTouchEnabled;   // default is NO
    @property(getter=isExclusiveTouch) BOOL         exclusiveTouch;         // default is NO
    @property BOOL               autoresizesSubviews; // default NO. if set, subviews are adjust if self bounds change
    //@property UIViewAutoresizing autoresizingMask;    // simple resize. default is UIViewAutoresizingNone
    @end
    
    @interface UIView(UIViewHierarchy)
    @property(readonly) UIView              *superview;
    @property(readonly, copy) NSArray       *subviews;
    @property(readonly) UIWindow            *window;
    @end
    
    @interface UIView(UIViewRendering)
    @property                  BOOL              clipsToBounds;              // When YES, content and subviews are clipped to the bounds of the view. Default is NO.
    @property(retain)          UIColor          *backgroundColor;            // animatable. default is nil
    @property                  CGFloat           alpha;                      // animatable. default is 1.0
    @property(getter=isOpaque) BOOL              opaque;                     // if opaque, assumes that draw will fill (implies clearsContextBeforeDrawing). default is YES
    @property                  BOOL              clearsContextBeforeDrawing; // says we draw full contents even if not opaque. otherwise context is cleared causing extra work. default is YES
    @property(getter=isHidden) BOOL              hidden;                     // default is NO. doesn't check superviews
    @property                  UIViewContentMode contentMode;                // default is UIViewContentModeScaleToFill
    @end
    For the multitouch app of firmware 2.0, I have ported a game called T4Two to firmware 2.0 beta

    The original project is at (with source and binary for 1.1.x)
    http://www.iamas.ac.jp/~aka/iphone/#T4Two.app

    This game allows two players to control the rackets on the multitouch screen with sound.

    I have added the following enhancements:
    (a) double tap on the screen to toggle debug touch position information on the screen
    (b) triple tap on the screen to toggle sound (default is changed to no sound)

    The Accelerometer is turned off, as this has problem with the multitouch for the beta, but you can turn it on by #define ENABLE_ACCELEROMETER in the source code and build again.

    The program will run on firmware 2.0 beta 3 and has been tested on iPhone firmware 2.0 beta 3 (pwned). The source code and makefile will build on SDK beta 3 with Open Toolchain header. I think SDK beta 5 will also work, but I did not try.

    The compiled binary T4Two.app folder (for firmware OS 2.0 beta 3 build 5A240d) is at
    http://www.iphone.org.hk/attach/29958-T4Two.zip
    MD5 (29958-T4Two.zip) = aa5c2868289cf53af7395d0f5dbdfc04

    To install, just scp to the /Applications folder, or wget directly and unzip in iPhone.

    If you don't have wget in iPhone, get it from here, this wget binary works in firmware 2.0 beta 3
    http://ericasadun.com/ftp/PortedUtilities/

    Code:
     
    wget http://www.iphone.org.hk/attach/29958-T4Two.zip  
    unzip -oj 29958-T4Two.zip build/2.0/T4Two.app/* -d /Applications/T4Two.app

    The source code, resources and Makefile are at
    http://www.iphone.org.hk/attach/29959-T4Two_src.zip
    MD5 (29959-T4Two_src.zip) = bebf039854480b48ae6a8758f7e00ced

    Last edited by javacom; 05-19-2008 at 10:50 AM.

  5. #15
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    Xcode Template with Open Toolchain headers to run UIShowCase sample app

    There is a sample app from Apple SDK called UIShowCase (non Interface Builder version) for SDK beta 3. This sample app uses a lot of UIKit classes that are missing from the open toolchain headers. In order to use these UIKit classes in the SDK, I have created a patched local header #import "UIKit.h", so that it can be build and run using open toolchain Xcode template. The patched header will be added to the Xcode template of this thread.

    To build the app, the UIShowCase sample code should be amended as

    Code:
    /*
     main.m
    */
    #ifdef ASPEN
    #import "UIKit.h"
    #import "AppDelegate.h"
    #else
    #import <UIKit/UIKit.h>
    #endif
    
    int main(int argc, char *argv[]) {
    	int returnCode;
    	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    #ifdef ASPEN
    	returnCode = UIApplicationMain(argc, argv, [AppDelegate class]);
    #else
    	returnCode = UIApplicationMain(argc, argv, nil, @"AppDelegate");
    #endif
    	[pool release];
    	return returnCode;
    }
    Code:
    /*
    File: AppDelegate.h
    */
    
    #ifdef ASPEN
    #import "UIKit.h"
    @interface AppDelegate : UIApplication
    #else
    #import <UIKit/UIKit.h>
    @interface AppDelegate : NSObject <UIApplicationDelegate>
    #endif
    
    {
        UIWindow *window;
    	UINavigationController *navigationController;
    }
    
    @end
    and for every .h header files of the UIShowCase app that use #import <UIKit/UIKit.h>, they should also be changed to

    Code:
    #ifdef ASPEN
    #import "UIKit.h"
    #else
    #import <UIKit/UIKit.h>
    #endif
    With this local "UIKit.h" header file, you can now use most of the new UIKit classes
    from the SDK in the open toolchain header template.

    To get the local "UIKit.h", you can install the version 2 of this Xcode Template

    The installation instruction for version 2 of the Xcode Template is to use the following commands in Mac Terminal

    Code:
    curl http://cocoatouchdev.com/javacom/ToolChainTemplate_v2.zip  > ToolChainTemplate_v2.zip 
    unzip ToolChainTemplate_v2.zip -d "/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates"
    MD5 (ToolChainTemplate_v2.zip) = 64f547c961818404e4a1cf2764e7c285

    Last edited by javacom; 05-24-2008 at 09:24 AM.


  6. #16
    Senior Professional Array

    Join Date
    Mar 2007
    Posts
    147
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    If I create a project using the Cocoa Touch Toolchain template and build it I get the following error:

    Building target “Insomnia” of project “Insomnia” with configuration “Debug” — (1 error)
    cd /Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia
    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.0 -x objective-c-header -arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -iquote /Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Insomnia.build/Debug-iphoneos/Insomnia.build/Insomnia-generated-files.hmap -I/Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Insomnia.build/Debug-iphoneos/Insomnia.build/Insomnia-own-target-headers.hmap -I/Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Insomnia.build/Debug-iphoneos/Insomnia.build/Insomnia-all-target-headers.hmap -iquote /Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Insomnia.build/Debug-iphoneos/Insomnia.build/Insomnia-project-headers.hmap -F/Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/PrivateFrameworks -I/Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Debug-iphoneos/include -I/Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/build/Insomnia.build/Debug-iphoneos/Insomnia.build/DerivedSources -I/Developer/SDKs/iPhoneOS.sdk/Versions/iPhoneOS2.0.sdk/include -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include -I/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.0.1/include -F/System/Library/Frameworks -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/PrivateFrameworks -DMAC_OS_X_VERSION_MAX_ALLOWED=1050 -DASPEN -DDEBUG -DVERSION="2.1.0" -O3 -funroll-loops "
    " -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -c /Users/mh/Development/iphone/iphone-insomnia/2.0/Insomnia/Insomnia_Prefix.pch -o /var/folders/96/969awEv6H1Ow0ssTOoVZ1U++-+6/-Caches-/com.apple.Xcode.1026/SharedPrecompiledHeaders/Insomnia_Prefix-acpcxnwzgmsdbaducchsmymblnkz/Insomnia_Prefix.pch.gch
    arm-apple-darwin9-gcc-4.0.1:
    : No such file or directory
    : No such file or directory
    : No such file or directory
    : No such file or directory
    Build failed (1 error)

    Any ideas?

  7. #17
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default

    It supports build to device and "release" only, if you use Xcode.

    Or you can use the Makefile that is included in the project template.

  8. #18
    Senior Professional Array

    Join Date
    Mar 2007
    Posts
    147
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Oh sorry I missed that. A new project builds fine in release if you choose Toolchain Build, but the UIKit.h included in Cocoa Touch Toolchain fails because its redefining many of the enums.

    Anyway my real problem is that when I add the IOKit framework:
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks/IOKit.framework

    When I build Xcode reports framework IOKit not found...I haven't figured out how to include the IOKit headers yet too, I expect to be able to include the IOKit include directory for the normal intel sdk.

  9. #19
    Developer Array javacom's Avatar

    Join Date
    Mar 2008
    Posts
    304
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    28

    Default UIApplicationUseLegacyEvents

    When porting some 1.1.x games app to 2.0 firmware and in order to use the open toolchain methods for event handling such as
    Code:
    - (void)mouseDown:(struct __GSEvent *)fp8;
    - (void)mouseUp:(struct __GSEvent *)fp8;
    - (void)mouseDragged:(struct __GSEvent *)fp8;
    - (void)mouseEntered:(struct __GSEvent *)fp8;
    - (void)mouseExited:(struct __GSEvent *)fp8;
    - (void)mouseMoved:(struct __GSEvent *)fp8;
    You need to add this in main.m
    Code:
        UIApplicationUseLegacyEvents(1);
    Otherwise, you have to rewrite the touch handling events into these methods using the firmware 2.0 UITouch and UIEvent headers as in my previous post (T4Two.app)
    Code:
    - (void)touchesBegan:(id)fp8 withEvent:(id)fp12;
    - (void)touchesMoved:(id)fp8 withEvent:(id)fp12;
    - (void)touchesEnded:(id)fp8 withEvent:(id)fp12;

    I have ported a game called tris to firmware 2.0 beta using these 2 approaches, but I found out that the performance of UITouch/UIEvent handling events are slightly better in firmware 2.0 beta, so the compiled binary uses the firmware 2.0 methods.

    The original project is at (with source and binary for 1.1.x)
    http://code.google.com/p/tris/

    This game supports suspend and resume and I have added a quit menu, so that it can be remove from background completely.

    You can enable the firmware 1.x event handling methods (that is to disable firmware 2.0 event handling methods) by uncomment this line in the Makefile and run make again
    Code:
    #CFLAGS += -DUSE_LEGACY_EVENT
    The program will run on firmware 2.0 beta 3 and has been tested on iPhone firmware 2.0 beta 3 (pwned). The source code and makefile will build on SDK beta 3 with Open Toolchain header.

    The compiled binary tris.app folder (for firmware OS 2.0 beta 3 build 5A240d) is at
    http://www.iphone.org.hk/attach/30626-tris.zip
    MD5 (30626-tris.zip) = 08a155605419317843084c04648be5eb

    To install, just scp to the /Applications folder, or wget directly and unzip in iPhone.

    If you don't have wget in iPhone, get it from here, this wget binary works in firmware 2.0 beta 3
    http://ericasadun.com/ftp/PortedUtilities/

    Code:
     
    wget http://www.iphone.org.hk/attach/30626-tris.zip  
    unzip -oj 30626-tris.zip build/2.0/tris.app/* -d /Applications/tris.app

    The source code, resources and Makefile are at
    http://www.iphone.org.hk/attach/30631-tris_src.zip
    MD5 (30631-tris_src.zip) = 8b6434572a355d477c7da49baa2a2425


    Last edited by javacom; 06-06-2008 at 05:46 PM.

  10. #20
    Professional Array

    Join Date
    May 2008
    Posts
    59
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    8

    Default

    There are problems using setFont setColor methods in UITextLabel and UITextView in the sdk compiler and open toolchain headers

    Typically the code for setFont and setColor in firmware 1.1.x would be

    Code:
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
    UITextLabel* label;
    [label setFont:[NSClassFromString(@"WebFontCache") createFontWithFamily:@"Helvetica" traits:0 size:17.]];
    [label setColor:CGColorCreate(colorSpace, grayComponents)];
    When porting these codes using the sdk compiler and the open toolchain headers to firmware 2.0, the iPhone OS 2.0 runtime will fail and show this error in the Xcode Organizer

    Code:
    [NSCFType CGColor]: unrecognized selector sent to instance
    The reason is that the struct __GSFont and struct CGColor are not recognized in iPhone OS2.0 and it can be solved by including these in the code and used the new UIFont and UIColor methods in the SDK headers


    Code:
    typedef float CGFloat;
    #import <UIKit/UIFont.h>
    #import <UIKit/UIColor.h>


    These two header files are in here and there are some new methods defined

    Code:
    /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks/UIKit.framework/Headers
    There are two methods to convert these 1.1.x codes using setColor:CGColor to firmware 2.0 as below

    Code:
    firmware 1.1.x code
    float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    [label setColor:CGColorCreate(colorSpace, grayComponents)];

    firmware 2.0 code method 1 (using CGColor)
    float grayComponents[4] = { 0.3, 0.3, 0.3, 1. };
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    [label setColor:[UIColor colorWithCGColor:CGColorCreate(colorSpace, grayComponents)]];

    firmware 2.0 code method 2 (using Color Components)
    [label setColor:[UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];

    The following sample code demonstrates the use of UIFont and UIColor methods and will display the useless "Hello ToolChain" in iPhone OS 2.0 (pwned) if you use the Xcode template of this thread to build

    There will be warning messages when build and just ignore them. To remove these warnings, the open toolchain headers should be amended.



    Code:
    /*
    HelloToolChain.app
    main.m
    */
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>

    // include for the sdk compiler and open toolchain headers
    #ifndef UIKIT_UIFont_UIColor_H
    #define UIKIT_UIFont_UIColor_H
    typedef float CGFloat;
    #import <UIKit/UIFont.h>
    #import <UIKit/UIColor.h>
    #endif

    @interface HelloToolChain : UIApplication
    {
    }
    @end

    @implementation HelloToolChain
    - (void) applicationDidFinishLaunching: (NSNotification *)aNotification
    {
    UIWindow *window = [[UIWindow alloc] initWithContentRect: [UIHardware fullScreenApplicationContentRect]];
    UITextLabel *label = [[UITextLabel alloc] initWithFrame: CGRectMake(0, 100, 320, 50)];
    [label setFont:[UIFont fontWithName:@"Marker Felt" size:50]];
    [label setCentersHorizontally: YES];
    [label setText:@"Hello ToolChain"];
    [label setBackgroundColor:[UIColor blackColor]];
    [label setColor:[UIColor whiteColor]];
    UIView *mainView = [[UIView alloc] initWithFrame: [UIHardware fullScreenApplicationContentRect]];
    [mainView addSubview: label];
    [mainView becomeFirstResponder];
    [window orderFront: self];
    [window makeKeyAndVisible];
    [window setContentView: mainView];
    }
    @end

    int main(int argc, char *argv[]) {
    int returnCode;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    returnCode = UIApplicationMain(argc, argv, [HelloToolChain class]);
    [pool release];
    return returnCode;
    }


 

 

LinkBacks (?)

  1. 02-16-2009, 06:37 AM
  2. 01-28-2009, 07:22 AM

Similar Threads

  1. MacNN: Apple working on official magazine template for Xcode?
    By hackint0sh in forum Latest Headlines
    Replies: 0
    Last Post: 03-14-2011, 03:10 PM
  2. [Xcode Problems] About Open Toolchain dev in Xcode
    By satashi in forum iPhone Developer Exchange
    Replies: 2
    Last Post: 02-08-2011, 11:26 AM
  3. Xcode Open Toolchain Application link error?
    By syamooo in forum iPhone Developer Exchange
    Replies: 1
    Last Post: 09-28-2010, 06:59 AM
  4. Development and distribution questions Xcode + template
    By antzee in forum iPhone Developer Exchange
    Replies: 1
    Last Post: 07-07-2009, 09:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 03:12 PM.
twitter, follow us!