Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:25:07+00:00 2026-06-17T06:25:07+00:00

I have been searching the web for a way to play sounds in Objective

  • 0

I have been searching the web for a way to play sounds in Objective C and I have found plenty of answers. However, when I try to play something three “Apple Mach-O Linker Errors” pop up.

Here is my code:

viewController.m

-(IBAction)shoot{
    tempSound *sound = [[tempSound alloc]init];
    [sound playSound:@"test" :@"wav"]  
}

tempSound.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@interface tempSound : NSObject{
    SystemSoundID audioEffect;
}

-(void)playSound: (NSString*) fName : (NSString*) ext;

@end

tempSound.m

@implementation tempSound

-(void)playSound:(NSString *)fName :(NSString *)ext
{
    NSString *path  = [[NSBundle mainBundle] pathForResource : fName ofType :ext];

    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {

        NSURL *pathURL = [NSURL fileURLWithPath:path];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)pathURL, &audioEffect);
        AudioServicesPlaySystemSound(audioEffect);
    }

    else{
        NSLog(@"Error, file not found: %@",path);
    }


}

@end

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:25:09+00:00Added an answer on June 17, 2026 at 6:25 am

    You have to link against the AudioToolbox framework. (If you’re using Xcode, you can add that in the “link with binaries” tab on the “build phases” section; if you’re using a command line toolchain, you should add the -framework AudioToolbox linker flag.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching the web and found many odd answers and i've tried
I have been searching around the web all day for the best way to
I have been searching the web for about an hour, however, I only seem
I have been searching for a solution to this and so far found nothing
I have been searching for how to create an animated widget. I have found
I have been searching for the best way to validate a URL in php
I've been searching the web for a way to do this for about a
I've been searching through the web but I have not been able to find
I have been doing a lot of searching on the web and cant seem
I have been searching the internet high and low for a simple way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.