Apple Mach-O Linker error (APActivityIcon) - iphone

I've a problem! Sorry I'm new to programming and I dont know what to do. I implemented some code, to customize my ActivitiViewController. I created a new class, which I linked to my code:
- (IBAction)share:(id)sender
{
Class avcClass = NSClassFromString(#"UIActivityViewController");
if (avcClass) {
APActivityProvider *ActivityProvider = [[APActivityProvider alloc] init];
UIImage *ImageAtt = [UIImage imageNamed:#"MyApp Icon 512x512.png"];
NSArray *Items = #[ActivityProvider, ImageAtt];
APActivityIcon *ca = [[APActivityIcon alloc] init];
NSArray *Acts = #[ca];
UIActivityViewController *ActivityView = [[UIActivityViewController alloc]
initWithActivityItems:Items
applicationActivities:Acts];
[ActivityView setExcludedActivityTypes:
#[UIActivityTypeAssignToContact,
UIActivityTypeCopyToPasteboard,
UIActivityTypePrint,
UIActivityTypeSaveToCameraRoll,
UIActivityTypePostToWeibo]];
[self presentViewController:ActivityView animated:YES completion:nil];
[ActivityView setCompletionHandler:^(NSString *act, BOOL done)
{
NSString *ServiceMsg = nil;
if ( [act isEqualToString:UIActivityTypeMail] ) ServiceMsg = #"Mail sended!";
if ( [act isEqualToString:UIActivityTypePostToTwitter] ) ServiceMsg = #"Post on twitter, ok!";
if ( [act isEqualToString:UIActivityTypePostToFacebook] ) ServiceMsg = #"Post on facebook, ok!";
if ( [act isEqualToString:UIActivityTypeMessage] ) ServiceMsg = #"SMS sended!";
if ( done )
{
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:ServiceMsg message:#"" delegate:nil cancelButtonTitle:#"ok" otherButtonTitles:nil];
[Alert show];
}}];
.........However, I run the code, but I still get an error! My two files I created are named APActivityProvider. So now I get that error and dont know how to treat this. Whats the error of my architecture?
Any tipps, suggestions or solutions?
Thanks

Simple 4 Steps to follow :)
Step 1: Click on Project's name
Step 2: Click on Projects Name under Targets and select Build Phases Tab
Step 3: Check the compile source files list and add the missing files name by pressing the + button at the bottom
Step 4: Enter the file name and it will show the file in the search list, just Add it and you are done :)
**
Hope this will help :) Happy Coding

APActivityIcon.m is probably not being compiled with your app, when it probably should be.
If it's part of a library, then you will have to configure that library as a dependency in Xcode, then link your app to that static library.

You need to check if target architectures in linked libraries project details have every architecture of main target.
In other words, go to your project build settings, check Architectures line (by default you'll have armv7 and arv7s now) then iterate through every project of included libraries and check if they have the same.

If it is the problem with your architecture you can solve it by check on settings BuildActiveArchitectureOnly in your project as well as target build settings.
Refer this. Hope this helps. Happy Coding :)

Related

How to use AHAlertView in iphone project?

I have been trying to use AHALertView in my iphone project but it does not work.Even if i run the sample project of AHAlertView, it does not compile and shows as much as 13 errors saying 'undeclared use of identifier' and other warnings as well.
Has anyone faced such problem ? If yes, how do i fix it?
Here is the code:-
- (IBAction)addEmail:(id)sender
{
AHAlertView *addFriendAlertView = [[AHAlertView alloc]initWithTitle:#"Add New Contact" message:#"Enter New E-mail"];
addFriendAlertView.alertViewStyle = AHAlertViewStylePlainTextInput;
[addFriendAlertView setCancelButtonTitle:#"Cancel" block:^{
NSLog(#"User cancelled the alert instead of entering new address");
}];
[addFriendAlertView addButtonWithTitle:#"OK" block:^{
NSLog(#"User entered the email :- %#",[addFriendAlertView textFieldAtIndex:0].text);
}];
[addFriendAlertView show];
If you are not using the latest XCode version you need to explicitely synthesize this properties like
#synthesize presentationStyle = _presentationStyle; etc........

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!

Is automated sharing possible for Twitter in the background on iOS?

I wanted to share a Twitter feed on the Twitter wall which contains an image and some text. I want support from iOS 4.3 to iOS 6.0.1. Is sharing possible in the background without a send/share button? How do I implement it?
The API call that you need to send is:
https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
Before making that call, of course, you will need to authenticate with Twitter via xAuth/OAuth. Unless you get special permission from Twitter to do otherwise, it looks like you will need to use OAuth,
https://dev.twitter.com/docs/oauth/xauth
To background the request, it will likely make sense to use Grand Central Dispatch --that is unless you have a lot of different Twitter requests to send. In that case, I would instead opt for an NSOperationQueue where maxConcurrentOperationCount = 1. See the following:
http://www.fieryrobot.com/blog/2010/06/27/a-simple-job-queue-with-grand-central-dispatch/
http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues
Nevertheless, because OAuth is such a pain, it will likely make sense to use a third party library. I've never used it before, but here is an example using MGTwitterEngine:
Twitter's statuses/update_with_media on iOS returns 500 error
If you were able to limit use to iOS 5+, then I would highly recommend using the SLRequest object. The advantage of this approach is that you integrate with the iOS users account directly, so they don't have to authenticate through a UIWebView or something cheesy.
To do so, you would simply plug in the appropriate Twitter API url in the following function requestForServiceType:requestMethod:URL:parameters: and obtain your SLRequest object. Then assign the appropriate Twitter ACAccount obtained from the ACAccountStore using requestAccessToAccountsWithType:options:completion:. Finally make your call to performRequestWithHandler, which would then perform your request asynchronously.
The following code will not post in background but it can post across ios versions...
You can use condition for ios versions like below code.This is working code I have implemented and it is working on both ios 5 and 6. Please check in ios 4 to confirm.I think it should work.
#import "Twitter/Twitter.h"
#import "Social/Social.h"
-(IBAction)tweetPost:(id)sender
{
if ([self isSocialAvailable])
{
SLComposeViewController *tweetComposer=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewControllerCompletionHandler __block completionHandler=
^(SLComposeViewControllerResult result){
[tweetComposer dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(#"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(#"Posted....");
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"Sent"
message:nil
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles: nil];
[alert show];
}
break;
}};
NSString*message = #"posting to twitter test ios 6";
[tweetComposer setInitialText:message];
[tweetComposer addImage:[UIImage imageNamed:#"2.jpg"]];
[tweetComposer addURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
[tweetComposer setCompletionHandler:completionHandler];
[self presentViewController:tweetComposer animated:YES completion:nil];
}
}
else
{
TWTweetComposeViewController *twitter= [[TWTweetComposeViewController alloc] init];
[twitter addImage:[UIImage imageNamed:#"2.jpg"]];
[twitter addURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
[twitter setInitialText:#"Tweet from iOS 5 app using the Twitter framework."];
[self presentModalViewController:twitter animated:YES];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = #"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = #"Tweet compostion was canceled.";
else if (result == TWTweetComposeViewControllerResultDone)
msg = #"Tweet composition completed.";
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:#"Okay" otherButtonTitles:nil];
[alertView show];
};
}
}
-(BOOL)isSocialAvailable {
return NSClassFromString(#"SLComposeViewController") != nil;
}
You need to include three frameworks named social,adSupport and Accounts.Check which one not needed with twitter feed post.
Hope ,this will help you.
Yes, but you'll need find some 1.1 API wrapper (thing which generates API requests, singns them etc) for you and authoriser (MGTWitter engine works fine). I have a working solution for sharing (text only) and getting user info for iOS 4+.
And about background part - that depends on how you implement that (i.e. notifications or continious background execution or gps callbacs etc...).

Error! Twitter not Conecting from my IPhone

i m using AddThis SDK for facebook,twitter and Email share, facebook and Email is nicely working while Twitter is giving error while conecting from my Iphone. it nice work from my simulator but from iphone twitter not connecting and just display a message in console"Error!" code: [AddThisSDK setTwitterViaText:#"QuotesApp"];
[AddThisSDK shareURL:#"http://HazratAliQuotes.com"
withService:#"twitter" title:string description:#"QuotesApp"];
Try this link to implement Twitter in your application for previous version of iOS
The Previos API of twitter is known as MGTTwitter
For AddThis:
To use Twitter OAuth-enabled sharing, you'll need to tell the library to do so, and then configure your Twitter consumer key, consumer secret, and callback URL.
[AddThisSDK setTwitterAuthenticationMode:ATTwitterAuthenticationTypeOAuth];
[AddThisSDK setTwitterConsumerKey:#"yourconsumerkey"];
[AddThisSDK setTwitterConsumerSecret:#"yourconsumersecret"];
[AddThisSDK setTwitterCallBackURL:#"yourcallbackurl"];
Below is the new answer added.
Remove the line [AddThisSDK setTwitterViaText:#"QuotesApp"];
Add the line [AddThisSDK setTwitterAuthenticationMode:ATTwitterAuthenticationTypeOAuth];
and on twitter button pressed create a selector and add the following code as
[AddThisSDK shareURL:#"http://www.addthis.com"
withService:#"twitter"
title:#"AddThis - The #1 Bookmarking & Sharing Service"
description:#"AddThis is a free way to boost traffic back to your site by making it easier for visitors to share your content."];
This is optional answer for you. In IOS 5 there is framework Tweeter.Framework. add this Framework and import, i use this for uploading a image(as a link) and message. may be it's helpful for you.:)
import "Twitter/Twitter.h"
and on Button Click..
- (void)postImageOnTweeterWall
{
if (imageView.image)
{
NSLog(#"tweetbutton pressed called");
// Create the view controller
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
// Optional: set an image, url and initial text
[twitter addImage:[UIImage imageNamed:#"img1.jpeg"]];
// [twitter addURL:[NSURL URLWithString:[NSString stringWithString:#"http://MobileDeveloperTips.com/"]]];
[twitter setInitialText:#"Tweet from iOS 5 app using the Twitter framework."];
// Show the controller
[self presentModalViewController:twitter animated:YES];
// Called when the tweet dialog has been closed
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = #"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = #"Tweet compostion was canceled.";
else if (result == TWTweetComposeViewControllerResultDone)
msg = #"Tweet composition completed.";
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:#"Okay" otherButtonTitles:nil];
[alertView show];
// Dismiss the controller
[self dismissModalViewControllerAnimated:YES];
};
}
else
{ UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:#"Tweeter" message:#"Select photo to Upload"
delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil] autorelease];
[alertView show];
}
}

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];
}
}