Ok, need help with my hello world app!

Discussion in 'iOS Development' started by hockeypanda32, Jul 31, 2008.

  1. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Here is the code what is wrong, are my Viewers Wrong? What are Viewers if mine are wrong! help

    MyExample.m

    Code:
    #import "MyExample.h"
    
    int main(int argc, char **argv)
    {
       NSAutoreleasePool *autoreleasePool = [
            [ NSAutoreleasePool alloc ] init
        ];
        int returnCode = UIApplicationMain( argc, argv, @"MainView", @"MyApp" );
        [ autoreleasePool release ];
        return returnCode;
    }
    
    @implementation MyApp
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
        window = [ [ UIWindow alloc ] initWithContentRect:
            [ UIHardware fullScreenApplicationContentRect ]
        ];
    
        CGRect rect = [ UIHardware fullScreenApplicationContentRect ];
        rect.origin.x = rect.origin.y = 0.0f;
    
        mainView = [ [ MainView alloc ] initWithFrame: rect ];
    
        [ window setContentView: mainView ];
        [ window orderFront: self ];
        [ window makeKey: self ];
        [ window _setHidden: NO ];
    }
    @end
    
    @implementation MainView
    - (id)initWithFrame:(CGRect)rect {
    
        if ((self == [ super initWithFrame: rect ]) != nil) {
    
            textView = [ [ UITextView alloc ] initWithFrame: rect ];
            [ textView setTextSize: 20 ];
            [ textView setText: @"Hello, World! My first Crappy App!" ];
            [ self addSubview: textView ];
        }
    
        return self;
    }
    
    - (void)dealloc
    {
        [ self dealloc ];
        [ super dealloc ];
    }
    
    @end		
    
    MyExample.h

    Code:
    #import <CoreFoundation/CoreFoundation.h>
    #import <UIKit/UIKit.h>
    #import <UIKit/UITextView.h>
    
    @interface MainView : UIView
    {
            UITextView         *textView;
    }
    - (id)initWithFrame:(CGRect)frame;
    - (void)dealloc;
    @end
    
    @interface MyApp : UIApplication
    {
        UIWindow *window;
        MainView *mainView;
    }
    - (void)applicationDidFinishLaunching:
        (NSNotification *)aNotification;
    @end
    
    main.m

    Code:
    /* Import the UIKit header and our app header, so the app can tell its a UIApplication */
    
    #import <UIKit/UIKit.h>
    #import "MyExample.h"
    
    /* This tells that when launched the app goes the the application's main function */
    
    int main(int argc, char *argv[])
    {
    	NSAutoreleasePool* pool = [ [ NSAutoreleasePool alloc ] init ];
    	int AppReturn;
    	AppReturn = UIApplicationMain( argc, argv, @"MainView", @"MyApp" );
    	return AppReturn;
    	[ pool release ];
    }
    
    	
    
  2. Spreche

    Spreche Member

    Joined:
    Dec 27, 2007
    Messages:
    164
    Likes Received:
    0
    Device:
    iPhone
    When you compile it, what errors do you get. That is a vital part to debugging/troubleshooting.
  3. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Here is the log of errors

    Code:
    iPod:/MyApps/First root# make
    arm-apple-darwin9-gcc -c -I/var/include  main.m -o main.o
    arm-apple-darwin9-gcc -c -I/var/include  MyExample.m -o MyExample.o
    arm-apple-darwin9-gcc -lobjc -framework UIKit -framework Foundation -framework CoreFoundation -framework CoreGraphics -L"/usr/lib" -F"/System/Library/Frameworks" -F"/System/Library/PrivateFrameworks" -bind_at_load -o First main.o MyExample.o
    /usr/bin/ld: multiple definitions of symbol _main
    main.o definition of _main in section (__TEXT,__text)
    MyExample.o definition of _main in section (__TEXT,__text)
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamDataWrittenToMemoryStreamKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamDataWrittenToMemoryStreamKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamDataWrittenToMemoryStreamKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamFileCurrentOffsetKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamFileCurrentOffsetKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamFileCurrentOffsetKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyConfigurationKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyConfigurationKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyConfigurationKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyHostKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyHostKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyHostKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyPasswordKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyPasswordKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyPasswordKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyPortKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyPortKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyPortKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyUserKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyUserKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyUserKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyVersion4
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyVersion4
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyVersion4
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyVersion5
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyVersion5
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyVersion5
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSOCKSProxyVersionKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSOCKSProxyVersionKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSOCKSProxyVersionKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelKey
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelKey
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelKey
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelNegotiatedSSL
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelNegotiatedSSL
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelNegotiatedSSL
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelNone
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelNone
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelNone
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelSSLv2
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelSSLv2
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelSSLv2
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelSSLv3
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelSSLv3
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelSSLv3
    /usr/bin/ld: warning multiple definitions of symbol _NSStreamSocketSecurityLevelTLSv1
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of _NSStreamSocketSecurityLevelTLSv1
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of _NSStreamSocketSecurityLevelTLSv1
    /usr/bin/ld: warning multiple definitions of symbol ___crashreporter_info__
    /System/Library/Frameworks/Foundation.framework/Foundation(single module) definition of ___crashreporter_info__
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation(single module) definition of ___crashreporter_info__
    collect2: ld returned 1 exit status
    make: *** [First] Error 1
    
  4. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    where is the .h? they both say .m maybe thats a typo or a error?
  5. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Typo!

    Please Register or Log in to view images

  6. Spreche

    Spreche Member

    Joined:
    Dec 27, 2007
    Messages:
    164
    Likes Received:
    0
    Device:
    iPhone
    Try using these:

    main.m
    Code:
    /* Import the UIKit header and our app header, so the app can tell its a UIApplication */
    
    #import <UIKit/UIKit.h>
    #import "MyExample.h"
    
    /* This tells that when launched the app goes the the application's main function */
    
    int main(int argc, char *argv[])
    {
    	NSAutoreleasePool* pool = [ [ NSAutoreleasePool alloc ] init ];
    	int AppReturn;
    	AppReturn = UIApplicationMain( argc, argv, @"MyApp", @"MyApp" );
    	return AppReturn;
    	[ pool release ];
    }
    
    MyExample.h
    Code:
    #import <CoreFoundation/CoreFoundation.h>
    #import <UIKit/UIKit.h>
    #import <UIKit/UITextView.h>
    
    @interface MyApp : UIApplication
    {
        UIWindow *window;
        MainView *mainView;
        UITextView *textView;
    }
    - (void)applicationDidFinishLaunching:
        (NSNotification *)aNotification;
    @end
    
    MyExample.m
    Code:
    #import "MyExample.h"
    
    
    @implementation MyApp
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
        
    
        CGRect rect = [ UIHardware fullScreenApplicationContentRect ];
        rect.origin.x = rect.origin.y = 0.0f;
    
        window = [ [ UIWindow alloc ] initWithContentRect: [ UIHardware fullScreenApplicationContentRect ]];
        [window makeKeyAndVisible];
    
        mainView = [ [ UIView alloc ] initWithFrame: rect ];
        [ window setContentView: mainView ];
    
    
            textView = [ [ UITextView alloc ] initWithFrame: rect ];
            [ textView setTextSize: 20 ];
            [ textView setText: @"Hello, World! My first Crappy App!" ];
            [ mainView addSubview: textView ];
    }
    
    
    - (void)dealloc
    {
        [ self dealloc ];
        [ super dealloc ];
    }
    
    @end
    
  7. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    Trying now
    ------------------double post merged------------------
    It compiled but now it just opens and closes... whats wrong?
  8. Spreche

    Spreche Member

    Joined:
    Dec 27, 2007
    Messages:
    164
    Likes Received:
    0
    Device:
    iPhone
    Do you have your Info.plist file? What does your .app folder contain?
  9. hockeypanda32

    hockeypanda32 Well-Known Member

    Joined:
    Dec 18, 2007
    Messages:
    2,183
    Likes Received:
    89
    Device:
    iPhone 4 (Black)
    info.plist and my compiled file
  10. Spreche

    Spreche Member

    Joined:
    Dec 27, 2007
    Messages:
    164
    Likes Received:
    0
    Device:
    iPhone
    Did you set your permissions to 755?

Share This Page