error unrecognized selector sent to class while adding Google Map SDK to iOS6 - dictionary

This is a single view application and I followed the instruction given at link
https://developers.google.com/maps/documentation/ios/start
for adding google map SDK to iOS6.
ERROR Is:
unrecognized selector sent to class 0xe2b0
2013-02-07 15:21:29.788 mapApp[2061:12e03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '+[GMSCameraPosition
cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xe2b0'
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
//initializing google map api key
[GMSServices provideAPIKey:#"google's api key goes here"];
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m
#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#interface ViewController ()
#end
#implementation ViewController
{
GMSMapView *mapView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231
longitude:77.64072579999993
zoom:6];
mapView = [GMSMapView mapWithFrame:CGRectZero camera:cam];
mapView.myLocationEnabled = YES;
GMSMarkerOptions *options = [[GMSMarkerOptions alloc]init ];
options.position = CLLocationCoordinate2DMake(13.025738,77.637809);
options.title = #"ensign";
options.snippet = #"kalyan nagar";
[mapView addMarkerWithOptions:options];
}
main.m
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv,nil, NSStringFromClass([AppDelegate class]));
}
}
While tracking the error it is showing at the return statement in main.m which comes from the method -viewDidLoad after executing the first line
GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231
longitude:77.64072579999993
zoom:6];
It escapes the rest of the lines.

Did you add -ObjC to the Other Linker Flags, in step 7 of the instructions?
--
Extra information edit: note that -ObjC is case sensitive.

I had the same problem. Make sure you add the -ObjC flag to the 'Build Settings' of your 'Target' and NOT 'Project'.
P.S. Adding it in both places doesn't break it either.

Google Doc says
Choose your project, rather than a specific target, and open the Build Settings tab.
In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
Sometimes this is wrong....
I had to add the linker flag to the target as well, to get it to work. This should help someone

Related

React Native Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

I have implemented push notification for android and it work 100% correctly but when I open the same app to test push notification for IOS it fails as it requires for a config file here is my config file code:
import { firebase } from '#react-native-firebase/messaging';
const reactNativeFirebaseConfig = {
apiKey: "my apiKey",
...
...
measurementId: "my measurementID XYZ"
};
firebase.initializeApp(reactNativeFirebaseConfig);
now the issue is even after adding this to my project gives an error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Note: I am using '#react-native-firebase/app'; and '#react-native-firebase/messaging' for push notification which is working for Android. anyone knows what is wrong on my code side or where should I use that config file as I saved this file as FirebaseConfig.js.
To setup Firebase on iOS, you need to do a few extra steps.
Open Firebase, and create a new iOS app.
Fill in the bundle identifier and give it a nickname of your choice.
Next download the google services file and open xCode.
Drag the Google Services file into the file tree yourApp/yourApp, next to your AppDelegate.m file.
Open AppDelegate.m and add
#import <Firebase.h>
to the top.
Next, at around line 58 there should be a return YES.
Add this above the return
[FIRApp configure];
Lastly, after the return and close bracket, add this code.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[FIRMessaging messaging].APNSToken = deviceToken;
}
All together it should look similar to this.
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[FIRApp configure];
return YES;
}
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[FIRMessaging messaging].APNSToken = deviceToken;
}
After you've done that, you should be all set to send your first message to your app.
Bare in mind that Firebase isn't very quick to send messages, it can take a few minutes to come through.
Side-note you cant sent notifications to a iOS simulator, only a real device. You also need to add Notification permission to the app in your Apple developer account, and in xCode.
If you need help setting this up, let me know and we can Skype.
You need to add a check in the following file's method didFinishLuanchWithOptions ios/{AppName}/AppDelegate.m
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}

"strict" mode for QML?

Does Qt's QML language provide any kind of "strict" mode? In particular, there are two features I'd like:
Application crash on reference to undefined or null (e.g. foo = bar when foo is an existing property but bar is not defined, and foo.bar when foo is null)
"hard" asserts (the console.assert feature does not crash the application).
1. Use qml lint
Run qmllint on all .qml and .js files in your build setup
find ./myproject -type f -regex ".*\.\(qml\|js\)" -exec "$QT_DIR/bin/qmllint" \{\} +
2. Crash app on QML error/warning
Write a custom QDebug message handler function static void handler(QtMsgType type, const QMessageLogContext& context, const QString &message); you register via qInstallMessageHandler(&MyQDebugMessageHandler::handler); that turns QML warnings into fatal logs:
if (type == QtWarningMsg)
{
auto fatalWarnings = std::vector<QString>{
QStringLiteral("ReferenceError:"),
QStringLiteral("is not a type"),
QStringLiteral("File not found"),
};
for (const auto &s : fatalWarnings)
{
if (message.contains(s))
{
type = QtFatalMsg;
break;
}
}
}
Then make sure that QDebug messages of type QtFatalMsg crash the app.
3. Crash on console.assert()
console.assert() creates errors but nothing specific to detect them. So adapt point 2. to crash the app on errors as well.

Xcode 4.2 thread 1 sigabrt error. Retrieving from Database

I found out that Sigabrt throws error because of this code where am trying to retrieve from database based on a tutorial but I dont know what the error is. I just commented the lines that gave me problem but am not understanding what is happening though
(void)viewDidLoad
{
MyWineLists * mywines =[[MyWineLists alloc] init];
self.wines = [mywines getMyWines];
/*[self.wineViewer setImage:((WineList *) [self.wines objectAtIndex:0]).photo];
[self.winename setText:((WineList *) [self.wines objectAtIndex:0]).wine];
[self.winerating setText:((WineList *) [self.wines objectAtIndex:0]).rating];*/
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

CBCentralManager *manager EXC_BAD_ACCESS with iOS7.0

I just upgraded to Xcode V5.0 (5A1413) the build success but running the program against the emulator causes the error at the property definition:
#property (nonatomic, strong) CBCentralManager *manager; --> Thread 1:EXC_BAD_ACCESS (code=2, address=0x8)
I ran into the same issue and finally resorted to this:
UIDevice *currentDevice = [UIDevice currentDevice];
if ([currentDevice.model rangeOfString:#"Simulator"].location == NSNotFound) {
self.centralMgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
On the Simulator, if I don't guard against creation of the CBCentralManager, I see centralManagerDidUpdateState: called with a CBCentralManager* that matches my strong property. It can be referenced and the state is CBCentralManagerStateUnsupported. That makes sense, but if I nil my strong manager property at that point (since I'm not going to be doing any BLE on a simulator that doesn't support it) I get the EXC_BAD_ACCESS. So, in the absence of a better answer, I suggest you simply guard against firing up the manager at all, as in my code above.

AVAssetReader kills playback (in AVAudioPlayer)

I am using AVAssetReader to read ipod library asset audio data and render a waveform image. this takes place using code I have described in my answer to this question
this sometimes takes place while audio is being played by an instance of AVAudioPlayer.
regardless of wether the audio being played is the same asset that is being read, the moment i hit
[reader startReading];
the audio being played "fades out". (as if the AVAudioPlayer has somehow been told to stop playback). This is odd, as I am not actually playing the audio, just reading it.
I did a search on SO and found this possible solution however i have found that this does not appear to solve the problem.
note - I am able to have several instances of AVAudioPlayer playing, and starting these do not seem to interfere with each other - however
[reader startReading];
will even kill multiple simultaneous instances of AVAudioPlayer, causing them all to synchronously fade out.
any ideas?
answering my own question....
further searching on SO led me to implementing this alternate solution:
- (void)setupAudio {
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
UInt32 doSetProperty = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
[[AVAudioSession sharedInstance] setActive: YES error: nil];
}
this was gleaned from here
**EDIT **UPDATED****
I have since made this into a class that also pre-initialises the audio queue (useful in both simulator and device as it eliminates the startup lag from the playback of the first audio file.
you can find the point1sec.mp3 here: http://www.xamuel.com/blank-mp3s/
#import <AVFoundation/AVFoundation.h>
#import "AudioToolbox/AudioServices.h"
#interface sw_AVAudioPlayerSetup : NSObject
<AVAudioPlayerDelegate> {
}
+ (void)setupAudio ;
+ (void)setupSharedSession ;
#end
#implementation sw_AVAudioPlayerSetup
+ (void)setupSharedSession {
static BOOL audioSessionSetup = NO;
if (audioSessionSetup) {
return;
}
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
UInt32 doSetProperty = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
[[AVAudioSession sharedInstance] setActive: YES error: nil];
audioSessionSetup = YES;
}
+ (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
// delegate callback to release player
[player release];
}
+ (void)setupAudio {
[self setupSharedSession];
NSString *filepath = [[NSBundle mainBundle]
pathForResource:#"point1sec"
ofType:#"mp3"];
if ([[NSFileManager defaultManager] fileExistsAtPath:filepath]) {
AVAudioPlayer* player = [[AVAudioPlayer alloc]
initWithContentsOfURL:
[NSURL fileURLWithPath:filepath]
error:nil];
player.delegate = (id <AVAudioPlayerDelegate>) self;
[player play];
}
}

Resources