[SourceCode] Bluetooth.app

Discussion in 'iOS Development' started by SkylarEC, Dec 5, 2007.

  1. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Here is the Source for the newly updated updated Bluetooth.app toy that I created. This is version 0.1

    main.m
    Code:
    #import <UIKit/UIKit.h>
    
    #import "Bluetooth.h"
    
    int main(int argc, char **argv)
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        return UIApplicationMain(argc, argv, [Bluetooth class]);
    }
    Bluetooth.h
    Code:
    #import <CoreFoundation/CoreFoundation.h>
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    #import <UIKit/UIApplication.h>
    
    @interface Bluetooth : UIApplication 
    {
    
    }
    
    @end
    Bluetooth.m
    Code:
    #import "Bluetooth.h"
    
    @implementation Bluetooth
    	
    - (void) applicationDidFinishLaunching: (id) unused
    {
    	float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
    	float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
    
    	struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    
    	rect.origin.x = rect.origin.y = 0;
    
    	UIWindow* window = [[UIWindow alloc] initWithContentRect: rect];
    	[window orderFront: self];
    	[window makeKey: self];
    	[window _setHidden: false];
    
    	UIView* mainView = [[[UIView alloc] initWithFrame: rect] autorelease];
    	[window setContentView: mainView]; 
    
    	UITextLabel *title = [[UITextLabel alloc] initWithFrame: rect];
    	[title setText: @"Look at your Status Bar."];
    	[title setBackgroundColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), black)];
    	[title setColor: CGColorCreate(CGColorSpaceCreateDeviceRGB(), white)];
    	[title setCentersHorizontally: true];
    	[mainView addSubview: title];
    	
    	[UIApp addStatusBarImageNamed: @"BluetoothActive" removeOnAbnormalExit: NO];
        
    }
    
    @end
    makefile
    Code:
    CC=arm-apple-darwin-gcc
    LD=$(CC)
    LDFLAGS=-lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework CoreGraphics
    
    all:	Bluetooth
    
    Bluetooth:	main.o Bluetooth.o
    	$(LD) $(LDFLAGS) -o $@ $^
    
    
    %.o:	%.m
    		$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    
    clean:
    		rm -f *.o Bluetooth
  2. Hazed

    Hazed Retired Moderator

    Joined:
    Sep 30, 2007
    Messages:
    762
    Likes Received:
    5
    Device:
    iPhone 3G (Black)
    Ahhh thankyou.

    I've successfully compiled your Bluetooth app and launched it on my iPod. ^^

    Now how do I remove the icon from my status bar, haha!
  3. Blake

    Blake Super Moderator Emeritus

    Joined:
    Oct 4, 2007
    Messages:
    2,963
    Likes Received:
    63
    Device:
    iPhone 4S (White)
    I think restarting you ipod will remove it from the status bar.
  4. Hazed

    Hazed Retired Moderator

    Joined:
    Sep 30, 2007
    Messages:
    762
    Likes Received:
    5
    Device:
    iPhone 3G (Black)
    Thanks, ^^

    Now to go and learn how to write some apps.
  5. ipodtouchlover

    ipodtouchlover New Member

    Joined:
    Oct 15, 2007
    Messages:
    215
    Likes Received:
    0
    Device:
    iPod touch
    does bluetooth work yet?
  6. Blake

    Blake Super Moderator Emeritus

    Joined:
    Oct 4, 2007
    Messages:
    2,963
    Likes Received:
    63
    Device:
    iPhone 4S (White)
    O M G,
    No!
    This just applies an icon to your status bar to use and trick your un-educated friends with.
  7. H3X

    H3X New Member

    Joined:
    Dec 3, 2007
    Messages:
    649
    Likes Received:
    6
    Thanks, I'm gonna compile this to test out my toolchain.
  8. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    that's one reason I posted this, as the code is so simple, it is a great resource for testing toolchains. And it is easier to understand than the HelloWorld that's already out there.

    If you want, jsut change the "Look at your Status Bar" string to "Hello World!" and there you do.
  9. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    yes it does just install the bluetooth.app from the ipod touch fans repo and open up the blue tooth app and bam (to know its working just look at the blue tooth icon in your status bar)
  10. H3X

    H3X New Member

    Joined:
    Dec 3, 2007
    Messages:
    649
    Likes Received:
    6
    It's not compiling for me.

    I'm getting an error1.

    I used all your files, too. No mods to them at all.

    EDIT: I also tried HelloApplication and got the same error, after fixing the spaces problem. Here's a screenshot:

    Attached Files:

Share This Page