Use of undeclared identifier '_AppsFlyerdelegate' - swift

I am not an iOS developer rather know bit of iOS and i am stuck at native side of iOS
So I was facing this issue on iOS
And I was trying this suggested answer
Here he says to add this and so I did
// AppsFlyer init here...
if(_AppsFlyerdelegate == nil){
_AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
}
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
[AppsFlyerLib shared].appsFlyerDevKey = #"YOUR_APPSFLYER_DEV_KEY"; // HACK: iOS SDK is faster than RN plugin
but I started getting these errors
Use of undeclared identifier '_AppsFlyerdelegate'
So I went to my pod file and added this (not sure if this sis correct)
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
pod 'AppsFlyerFramework'
Did pod install, again ran the command but the error didn't went away? Any idea what I am doing wrong?
Also (not important) but can someone briefly explain me this code
if(_AppsFlyerdelegate == nil){
_AppsFlyerdelegate = [[RNAppsFlyer alloc] init];
}
[[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate];
[AppsFlyerLib shared].appsFlyerDevKey = #"YOUR_APPSFLYER_DEV_KEY"; // HACK: iOS SDK is faster than RN plugin
// React Native Bridge and Root View init here...
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc]
initWithBridge:bridge
moduleName:#"FiftyViewsUnderTheAppiumSea"
initialProperties:nil
];

Related

Facebook SDK FBLoginView getting EXC_BAD_ACCESS

I'm following the HelloFacebookSample project bundled with the Facebook SDK 3.5. I've virtually copied and pasted everything into my own app, even the stuff from the AppDelegate, yet for some reason clicking the Login button freezes my app. Just for the record, everything authenticates correctly when connecting to the integrated framework in iOS 6, which is done through the FB SDK anyway. It's only when I try to log in using the web, i.e. hit the FBLoginView website opens, get authenticated, return to app. Here is the code in the samepl project, and I'll compare it to mine:
FBLoginView *loginview = [[FBLoginView alloc] init];
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
[self.view addSubview:loginview];
[loginview sizeToFit];
Mine is a little different:
loginview = [[FBLoginView alloc] init];
loginview.delegate = self;
[self.facebookCell addSubview:loginview];
[loginview sizeToFit];
As for the delegate methods, I've implemented them all verbatim. Why does the app crash? There is no valid reason for a crash when all the code is pretty much identical between my app and the sample app. The debugger doesn't help much even with Zombie Objects on. The actual error is: Thread 1: EXC_BAD_ACCESS (code=2, address=somethingoranother) Anyone got any ideas as to why this is happening?
Regards,
Mike
UPDATE: It appears that the crash happens because something is recurring infinitely on a loop. Seems like over 100,000 processes were put on the main thread by the FB SDK! How?!
UPDATE 2: I'm beginning to think the error is here, even though I copied this straight from the sample AppDelegate.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall *call) {
NSLog(#"In fallback handler");
}];
}
Does this help at all?
I'm having whats seems to be the exact problem, but I have my application sandbox mode already disabled. This app has been working perfectly before, but I just upgraded the SDK and now this happens.
If I have a facebook account configured in iOs, it will work ok, but if not, It will crash.
One thing worth mentioning is if I remove the url scheme, so the app can't go to the web browser or the facebook app, It will user a web view to log in and this works too
EDIT: As far as I'm able to tell, my problem relies in not having access to my application settings in facebook.
The facebook SDK does an [FBUtility fetchAppSettings:callback:] call, more specifically, it does an
https://graph.facebook.com/267496536695242?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name,
which in the case of my app fails with:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
In comparision, any of the examples apps, for example this one, SessionLoginSample
https://graph.facebook.com/380615018626574?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name
returns correctly this:
{
"supports_attribution": true,
"supports_implicit_sdk_logging": true,
"suppress_native_ios_gdp": 0,
"name": "SessionLoginSample",
"id": "380615018626574"
}
Because the SDK expects something it keeps making the same request and gets stuck in a loop until the simulator crashes.
To confirm this, I've manually inserted the expected parameters in the callback, modifyng the facebook sdk, and now everything work perfectly.
It's worth mentioning that I upgraded the SDK from 2.0 which was deprecated, and there was a few parameters in the settings page that were outdated (no client token set, authorization as native/Desktop instead Web, without having the app secret key in the app) but I've already set them alright..
EDIT 2:
This is the method from Facebook SDK (in FBUtility.m) that I've modified. I only added the "bad stuff" if clause.
+ (void)fetchAppSettings:(NSString *)appID
callback:(void (^)(FBFetchedAppSettings *, NSError *))callback {
if (!g_fetchedAppSettingsError && !g_fetchedAppSettings) {
NSString *pingPath = [NSString stringWithFormat:#"%#?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name", appID, nil];
FBRequest *pingRequest = [[[FBRequest alloc] initWithSession:nil graphPath:pingPath] autorelease];
if ([pingRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// Bad stuff
if (error) {
error = nil;
result = [NSDictionary dictionaryWithObjectsAndKeys:#"true", #"supports_attribution",
#"true", #"supports_implicit_sdk_logging",
#"0", #"suppress_native_ios_gdp",
#"Your_App_Display_Name", #"name", nil];
}
if (error) {
g_fetchedAppSettingsError = error;
[g_fetchedAppSettingsError retain];
} else {
g_fetchedAppSettings = [[[FBFetchedAppSettings alloc] init] retain];
if ([result respondsToSelector:#selector(objectForKey:)]) {
g_fetchedAppSettings.serverAppName = [result objectForKey:#"name"];
g_fetchedAppSettings.supportsAttribution = [[result objectForKey:#"supports_attribution"] boolValue];
g_fetchedAppSettings.supportsImplicitSdkLogging = [[result objectForKey:#"supports_implicit_sdk_logging"] boolValue];
g_fetchedAppSettings.suppressNativeGdp = [[result objectForKey:#"suppress_native_ios_gdp"] boolValue];
}
}
[FBUtility callTheFetchAppSettingsCallback:callback];
}
]
);
} else {
[FBUtility callTheFetchAppSettingsCallback:callback];
}
}
Someone found the answer on another thread. In the Facebook Developer centre, the app was set to Sandboxing mode which is what caused this error. Seems it wasn't a problem with the code after all.
Facebook has fixed a server error that was causing this for a lot of developers. However, the server fix only makes the infinite loop problem less likely to happen. It is still there. I created a new bug to track the infinite loop problem.
https://developers.facebook.com/bugs/446010282155033
It's a memory access error, because the loginView is in a __block space.
Just move your controller ( the loginView delegate ) in this zone and it should work.
FBLoginView *loginview = [[FBLoginView alloc] init];
static id staticDelegateInstance = self;
loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = staticDelegateInstance;
[self.view addSubview:loginview];
[loginview sizeToFit];

NSInternalInconsistencyException - Could not load NIB in bundle:

I am trying to bundle all my .xib resources into a "ViewController.bundle" to ship along with "MyLibrary.framework". If I just place all the .xib files in the framework project, everything is working fine, but if I put them inside "ViewController.bundle", everything break apart
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Could not load NIB in bundle:
'NSBundle </Users/administrator/Library/Application Support/iPhone Simulator/5.0/
Applications/8AD68FD1-158E-4926-AE03-8FEF870E7012/ios.app/ViewController.bundle>
(not yet loaded)' with name 'FirstViewController_iPhone''
*** First throw call stack:
(0x160e052 0x1071d0a 0x15b6a78 0x15b69e9 0x3ff838 0x2a6e2c 0x2a73a9 0x2a75cb 0x2c2b89 0x2c29bd
0x2c0f8a 0x2c0d7e 0x2c0a22 0x2bfd88 0x5e3ac 0x2df8 0x2e34 0x160fec9 0x1e45c2 0x1e455a 0x289b76
0x28a03f 0x2892fe 0x209a30 0x209c56 0x1f0384 0x1e3aa9 0x1eedfa9 0x15e21c5 0x1547022 0x154590a
0x1544db4 0x1544ccb 0x1eec879 0x1eec93e 0x1e1a9b 0x2452 0x2385)
I have tried various ways:
1. Creating the "ViewController.bundle" in Finder, place all the .xib there, and drag to xcode
2. Create a new Target for the framework project, choose "Bundle" under "Framework & Library" in "OS X" section (Note: it has to be OSX since I am using xcode 4.6 which do not have "Bundle" under its "Framework & Library" - it used to have, and I used to create bundle that contains .png resources using this wizard)
Under both circumstances, I have made sure that the "ViewController.bundle" exist in "Build Phase" >> "Copy Bundle Resources" in my target app.
I also tried including "ViewController.bundle" under "Target Dependencies" of my Framework project, but all my efforts resulted in the same crash.
I also tried various ways to load the .xib, to no avail. However, the following code that load a .png resource from the same "ViewController.bundle" works perfectly:
// Loading .png resource works perfectly
// UIImage* closeImage = [UIImage imageNamed:#"ViewController.bundle/first.png"];
// NSString *szBundlePath = [[NSBundle mainBundle] pathForResource:#"ViewController" ofType:#"Bundle"];
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"showView" message:szBundlePath delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil];
// UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)];
// [imageView setImage:closeImage];
// [alertView addSubview:imageView];
// [alertView show];
// return;
Using the same code to load the xib failed:
NSBundle *bViewController = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:#"ViewController" withExtension:#"bundle"]];
if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {
self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:#"FirstViewController_iPhone" bundle:bViewController] autorelease];
self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:#"SecondViewController_iPhone" bundle:bViewController] autorelease];
} else {
self.m_pFirstViewController = [[[FirstViewController alloc] initWithNibName:#"ViewController.bundle/FirstViewController_iPad" bundle:nil] autorelease];
self.m_pSecondViewController = [[[SecondViewController alloc] initWithNibName:#"ViewController.bundle/SecondViewController_iPad" bundle:nil] autorelease];
}
/** It crash in this line!! Note however, both m_pFirstViewController and m_pSecondViewController is allocated and not nil */
self.viewControllers = #[self.m_pFirstViewController, self.m_pSecondViewController];
/** never reach here already crash */
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:self animated:YES completion:^{
NSLog( #"presented!" );
}];
I have spent the last 8 hours debugging this, googling and tried various suggestions from SO, but to no avail... any help is greatly appreciated! Thanks!
The 2nd way that I tried is the closest... Then modify the OSX bundle to iOS bundle in the Build Settings. Apparently, there are several steps that I missed. I followed the tutorial and sample project by Matt Galloway here:
http://www.galloway.me.uk/tutorials/ios-library-with-resources/
and now everything works as intended.
Thanks everyone for your help!

Game Center with iOS 5 SDK - leaderboardDelegate = self not working

I am still using iOS 5 SDK and Xcode 4.2 (Snow Leopard). I am adding Game Center to my game and while it passed authentication I get an ARC error whenever I try to show a leaderboard with this code (from Apple):
- (void) showLeaderboard: (NSString*) leaderboardID
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
**leaderboardController.leaderboardDelegate = self;**
leaderboardController.timeScope = GKLeaderboardTimeScopeToday;
leaderboardController.category = leaderboardID;
[self presentViewController: leaderboardController animated: YES completion:nil];
}
}
I get this error:
Passing "ViewController *const__strong' to parameter of incompatible type 'id <GKLeaderboardViewControllerDelegate>"
Is there any other solution than using iOS 6 SDK on lion?
Thanks!
Ah,
Found a similar problem, using id(self) fixed it;
Handling app delegates and switching between views
Should I delete this question>

Problems building for both iOS4.3 and iOS5.0

I'm running up against problems trying to incorporate some iOS5-specific libraries into an app targeted at both iOS5 and iOS4.3. I've gone through the following steps:
weakly-linked the Twitter framework by setting it as optional in 'Link Binary with Libraries"
added it as a framework for the iOS5.0 SDK in Other Linker Flags with `-framework Twitter.framework'
conditionally linked the framework in the class header:
#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif
then in the method itself, I'm then checking whether the user's set up for Twitter:
if ([TWTweetComposeViewController class]) {
self.canTweet = [TWTweetComposeViewController canSendTweet];
}
This works beautifully on both the 5.0 and 4.3 simulators. However, I've got problems getting it to run on, or archive for, actual devices.
When I've got either a 3GS running 5.0, or a 4 running 5.0 attached, both show up twice in the Scheme dropdown. Selecting the top one, and attempting build or run the project fails with an Use of unidentified identifier 'TWTweetComposeViewController' error.
Using the second device entry, the build fails with a ld: framework not found Twitter.framework error.
I'm sure there's something I'm missing here, but I'm stumped. Can anyone advise?
If you are using a week linking then you have to check first availability of API using
NSClassFromString, respondsToSelector, instancesRespondToSelector etc.
So, change your if condition. First try to get your class object using above specified runtime function.
here is a link explaining in detail how to do such.
link
The code for presenting twitter controller
Before this you have to add the frameworks as optional and make the import in h file if iOS is min iOS 5
Class TWTweetComposeViewControllerClass = NSClassFromString(#"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil) {
if([TWTweetComposeViewControllerClass respondsToSelector:#selector(canSendTweet)]) {
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:#selector(setInitialText:)
withObject:NSLocalizedString(#"TwitterMessage", #"")];
[twitterViewController performSelector:#selector(addURL:)
withObject:url];
[twitterViewController performSelector:#selector(addImage:)
withObject:[UIImage imageNamed:#"yourImage.png"]];
[self.navigationController presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
}
Further digging into the error thrown back by the compiler suggested that it was ignoring the weak link flag. Although I've no idea how or why, it was fixed by a reinstallation of XCode.
if you link to 4.2 or later and deploy to 3.1 or later, you can use the new weak linking features to make this check simple.
you have to add Twitter frameworks as optional and then
Class TWTweetComposeViewControllerClass = NSClassFromString(#"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil)
{
if([TWTweetComposeViewControllerClass respondsToSelector:#selector(canSendTweet)])
{
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:#selector(setInitialText:)
withObject:NSLocalizedString(#"TwitterMessage", #"")];
[twitterViewController performSelector:#selector(addURL:)
withObject:url];
[twitterViewController performSelector:#selector(addImage:)
withObject:[UIImage imageNamed:#"yourImage.png"]];
[self.navigationController presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
}

game center not working on ipod/iphone

Hi all
Working on a universal build for an iphone/ipod/ipad app. I was trying to get game center working within this app. I now have the game center working on the ipad but for some reason it still wont work on the ipod/iphone and i have no idea why.
highScoreVC=[[UIViewController alloc] init];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:highScoreVC.view];
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
this is my code for displaying the leaderboard and it does work everytime for ipad but as i said not for other devices. the code is still being called the same as for ipad so i have no clue why it is not displaying. any ideas why this would be? cheers
As far as I'm concerned, [GKLeaderboardViewController init] will return nil if the device is not authenticated with Game Center by that point. Are you sure you are correctly authenticated on the devices causing problems?
I suspect there may be some issues with how your UIKit items for Game Center are being displayed if they are working fine on the iPad but not iPhone/iPod. I experienced similar sounding issues when converting an app to universal.
If you create a new standalone iPhone/iPod project just for testing does game center display fine?
ok i got it working in the end.
cocos2d 0.99.5 has indeed made some changes that to how this works. the following code displays the leaderboard correctly
-(UIViewController*) getRootViewController{
return (UIViewController*)([(BubbleDreamsAppDelegate*) [[UIApplication sharedApplication] delegate] viewController]);
}
and then
highScoreVC = [self getRootViewController];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
hope this helps anyone that gets stuck with same problem