I'm trying to use this class as
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
And getting this compiler error
error: AVAudioPlayer.h no such file or directory
I have added #import "AVAudioPlayer.h at the beginning of the .m file
Could you let me know how can I fix it?
Thanks
Instead of
#import "AVAudioPlayer.h"
Try
#import <AVFoundation/AVAudioPlayer.h>
Add the AVFoundation framework to your project.
The problem is in the fact that as the Fistman said, you probably did not add the Framework to your project.
You need to go to the Frameworks folder (in your project tree on the left side, usually just bellow the Resources folder), right click on Frameworks->Add->Existing Frameworks..' and pick AVFoundation from the list.
Notice that by default XCode will open the frameworks folder of your set Active SDK and so it must be at least OS 2.2 in order to show up (that's the earliest version when apple released it).
Once you added the framework, it should compile and link and you wouldn't have to add the h files manually.
Hope it helped,
-Adi
Related
Currently I am working in iPhone application, Using Storyboard to create JSONParser, Import JSON Library inside the application, then I have add #import JSON/JSON.h inside ViewController.h file, but the error comes in "file not found", and JSON Framework classes error in release because I am using RFC, so how to fix these issues?
Inside JSON Framework classes error found here
Your project uses ARC, but the JSON library doesn't. You need to disable ARC for the library files. To find out how, see this question:
How can I disable ARC for a single file in a project?, or this one: ios5 ARC what is the compiler flag to exclude a file from ARC?
the error you are getting is ARC issue. your project is ARC enabled , but the JSON framework is not using ARC.
you can disable the ARC in your whole project, or use it for single file . see
I'm using MPMusicPlayerController, specifically with setNowPlayingItem protocol and it's for cydia. But I have some issues and theos' warning when i make. It seems that some of the protocols and methods are not working and I receive some warning like this:
Tweak.xm:177: warning: ‘MPMusicPlayerController’ may not respond to ‘-skipToPreviousItem’
Tweak.xm:188: warning: ‘MPMusicPlayerController’ may not respond to ‘-pause’
Tweak.xm:193: warning: ‘MPMusicPlayerController’ may not respond to ‘-play’
Tweak.xm:201: warning: ‘MPMusicPlayerController’ may not respond to ‘-skipToNextItem’
Tweak.xm:317: warning: ‘MPMusicPlayerController’ may not respond to ‘-setNowPlayingItem:’
Have anyone some ideas? I enter the protocol already in prototype
I don't think it's because of cydia - it sounds like a compilation issue.
Have you definitely got
#import <MediaPlayer/MediaPlayer.h>
in your file?
have you added the MediaPlayer.framework to your project?
select your project in the project navigator
select your target on the right side
select the "Build Phases" tab
open "Link Binary With Libraries"
add your framework
I'm using MPMusicPlayerController, specifically with setNowPlayingItem. This is a complete online verses asset with an immense assortment of melody verses, data, what's more, MPMusicPlayerController *mp = [MPMusicPlayerController. downloadmp3music
I hope you can help with that.
OK i have created new group/folder under Classes - Libs: Classes/Libs and have created class there Msg.h
now I am trying to import it into my RootViewController
#import "Libs/Msg.h"
but I am getting an error:
Libs/Msg.h = no such file or directory
what should i Do ?
cheers,
/marcin
OK, as it turns out, the Libs is not required just
#import "Msg.h"
is enaugh even if its in folder level down.
thanks
What path is your RootViewController in? If you give a path in import, it must be relative to the current file. Also check the case of both directory and file; Mac OS X is case-insensitive, but Xcode and iPhone are not.
I am writing an app for my iPad running 3.2.2 with XCode 3.2.3. It seems that the highest version of the iOS for iPad this version of XCode has is 3.2, but other apps load fine onto the phone so this doesn't seem to be an issue. I am attempting to make use of the new UITextChecker class. I have imported UIKit, and UITextChecker.h appears in the headers folder under the UIKit.framework icon. However, when I try to compile this code:
NSString *theLanguage = [[UITextChecker availableLanguages] objectAtIndex:0];
or simply this:
UITextChecker *textChecker;
XCode tells me that UITextChecker is undeclared. Any ideas what it going on here? Thanks!
James
Here is a picture of the UIViewController's header file:
For whatever reason, UIKit.h does not import UITextChecker.h. You can fix this by also adding the following line.
#import <UIKit/UITextChecker.h>
Using core-plot does not seem to be an easy integration task. Header path are already setup. In Interface-Builder I create an CPLayerHostingView which belongs to a View Controller which is instantiated by Interface Builder.
When the nib file is loaded I get the message:
Unknown class CPLayerHostingView in Interface Builder file
I found, that there are two different versions of that object. One for Mac-Only called "CPLayerHostingView", one for iPhone only called "CPGraphHostingView".
If following the poplular example at http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application you would use the following lines, if building an iPhone-App:
CPGraphHostingView *graphView = (CPGraphHostingView*)self.view;
graphView.hostedGraph = graph;
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
Here is the answer ..
U can see mars' answer there
"i got it to work....ok, i added the -all_load -ObjC flag in the Target>Settings....I think this is where everyone gets confused...There are 2 places where to put the other link and header search paths, in Project Settings and in Target Settings.."
So solution is
Add -all_load -ObjC in Project settings and target settings
I had to rename CPLayerHostingView to CPGraphHostingView to get this to work after upgrading to the latest version of core plot (along with iOS 4 and the upgrade of XCode).
I think you're saying that you get this error when you load the NIB file in your app's code. In that case, the error suggests that you haven't built the Core Plot classes into your application (iPhone) or linked against the CorePlot framework and copied into the app bundle's Frameworks/ directory (OS X).
CPGraphHostingView
thank u it worked for me aswell;
3 imp things
1>perform settings for both project target aswell as application target.(make sure configuration is all configuration)
2>give correct header search path for framework library
3>learn over it::::::-)
For whatever it is worth.
Followed tutorial: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application and ended up having that same error. I looked into the CorePlot framework folder and did not find that CPLayerHostingView there, but found CPGraphHostingView inside iPhoneOnly folder.
Changed CPLayerHostingView to CPGraphHostingView in IB and error disappeared.
So, check what is in yours and use it. May work.