Weird Audio error in Xcode

Discussion in 'iOS Programming' started by callebo, Sep 19, 2010.

  1. callebo macrumors newbie

    Joined:
    Aug 10, 2010
    #1
    Hey
    I'm kind of new to Xcode but I've come a long way on my first app. Adding sound has been a real mess though.
    The first code I used caused the app to lag whenever a sound played and gave a lot of warnings. The other code didn't work at all. And now, when I tried the third option, i accidentally deleted all the frameworks.
    I copied over all the frameworks from a new project into mine, but don't know if you can do it like that. The code I'm using right now also wants me to get the Audiotoolbox.framework, which I now have but it still doesn't seem to work.
    The code I'm using for a playing a sound is:

    Code:
    SystemSoundID ssid;
    
    NSString *paths=[[NSBundle mainBundle]resourcePath];
    
    NSString *audioFile=[paths stringByAppendingPathComponent :@"yoursound.wav"];
    
    NSURL *audioURL=[NSURL fileURLWithPath:audioFile isDirectory:NO];
    
    OSStatus error=AudioServicesCreateSyste mSoundID((CFURLRef)audioURL, &ssid);
    
    if(error){NSLog(@"Audio error");}
    
    else{AudioServicesPlaySystemSo und(ssid);}
    I've set the right file name to the imported sound.
    The 2 errors I'm getting along with 1 warning:
    Code:
    (Warning)
    Link /Users/mymacsname/Documents/Magnetman/build/Debug-iphonesimulator/SimpleGame.app/SimpleGame
    In /Users/mymacsname/Documents/Magnetman/AudioToolbox.framework/AudioToolbox, missing required architecture i386 in file
    (Error)
    "_AudioServiesPlaySystemSound", referenced from:
    -[SimpleGameViewController touchesBegan:withEvent:] in SimplegameViewController.o
    (Error)
    "_AudioServicesCreateSystemSoundID", referenced from:
    -[SimpleGameViewController touchesBegan:withEvent:] in SimpleGameViewController.o
    Symbol(s) not found
    Collect2: Id returned 1 exit status
    
    As I said, I'm kinda new to Xcode so these errors leave me clueless. Please help!
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Please elaborate: how did you "delete" the frameworks? You must realize that normally they are just linked to your project. And when you add frameworks, you are just adding a link to them. So, how did you "copy" the frameworks from another project?
     
  3. callebo thread starter macrumors newbie

    Joined:
    Aug 10, 2010
    #3
    I was going to delete one of the frameworks, so i selected it and pressed command + backspace which removed the entire "frameworks" folder. I kinda paniced, because I couldn't command + z it back.
    So what I did was to open a new project, selected the Frameworks folder from there and just command + c, then back to my project and command + v. That gave me the UIKit, Foundation and CoreGraphics frameworks.
    I've also added the AudioToolbox framework, by right-clicking a framework>open with finder and then dragged it in.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  5. callebo thread starter macrumors newbie

    Joined:
    Aug 10, 2010
    #5
    I perhaps didn't make clear how new I am to Xcode but...
    Where do I find the Contactmapper? If I click Target (with the bullseye icon) all I get from the dropdown menu is SimpleGame, which got "Copy Bundle Resources", "Compile Sources" and "Link Binary With Libraries".
    So, where's the contactmapper? :confused:
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Alright. You're new. No problem. Perhaps some background can help us to better understand where you're coming from: What have you already done to educate yourself into using Xcode, Objective-C, etc.? Books, tutorials, videos, etc.? Remember, be specific.

    You don't find Contactmapper. That just happens to be the name of the project (and target) in that example. For your project, sounds like you want to find SimpleGame.

    Targets should have an entry for your project name below it. Click that entry. Then either right-click and choose Get Info... or click the Info button from the top toolbar. You'll see a dialog box popup, with choices for 5 tabs at the top. You want the first one: General.
     
  7. callebo thread starter macrumors newbie

    Joined:
    Aug 10, 2010
    #7
    Thanks for the help so far but...
    I checked it out. Under the "general" tab, the Audiotoolbox.framework is already added. It has also been imported under .m. Do you know anything else that might be wrong?
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    I would try removing and relinking your framework(s), since it appears to be referencing one in your project's directory and not using the one from the System libraries.
     

Share This Page