ShareKit has recently become one of my favorite iPhone open source projects. Just add a few lines of code to your app and you can instantly share text, URLs and other data via Email, Twitter, Facebook and a whole slew of other services.
I’ve found a couple of minor issues with the current release (version 0.2.1) of ShareKit, and I thought I’d share them to save you a couple of hours of debugging.
Error when building for device
This seems to be a known issue, that may depend on your Xcode install.
If you get 12 compiler errors when building for a device, starting with:
ShareKit/Core/SHK.m:35:28: error: objc/objc-class.h: No such file or directory
Then the solution is to change this import statement in SHK.m:
#import <objc/objc-class.h>
to:
#import </usr/include/objc/objc-class.h>
or:
#import <objc/runtime.h>
Hardcoding the path to something outside of Xcode or your project directories seems like bad idea. So I went with the second solution.
Conflicting Localizable.strings
The ShareKit project contains its own Localizable.strings files in the ShareKit / Localization directory. If your project is also localized there will be a conflict over which Localizable.strings file will be used at runtime.
There are a couple of ways to resolve this conflict:
- Remove the ShareKit files from your build target. This is the quickest solution, but you will lose the localizations provided in ShareKit (currently only German).
- Copy the contents of the Localizable.strings files from ShareKit to your Localizable.strings files. And then remove the ShareKit files from your build target. This works well when you have corresponding localizations.
- Rename the ShareKit files to ShareKitLocalizable.strings and then replace the NSLocalizedString macros in the ShareKit code with NSLocalizedStringFromTable where you can specify the ShareKitLocalizable.strings filename as the tableName.
May 1st, 2011 at 01:16
Thanks Nick, you solved my build issue.
July 3rd, 2011 at 00:57
super, thanks man ! Very helpful.
July 5th, 2011 at 08:22
Man, THANK YOU! I spent hours trying to find out why my localization wouldn’t work. That was it. Thanks.
July 21st, 2011 at 01:25
thank you for this post!!! upgraded to lion, suddenly got this when building something that worked fine yesterday – already solved thanks to your post. cheers!
October 10th, 2011 at 18:15
Thank you! This solved my problem after upgrading to Lion!
November 10th, 2011 at 01:28
thanks man, you’re a life saver
February 27th, 2012 at 10:07
The localization thing, bit us bad because our app wasn’t localized but adding ShareKit silently made it appear so and unfortunately the app now claims to support German in iTunes.
March 14th, 2012 at 09:57
#import
Solve the problem for ios5.1 at lion.
March 14th, 2012 at 09:58
#import objc/runtime.h
the or option
Solve the problem for ios5.1 at lion.
May 29th, 2012 at 09:45
solved; you did save hours of time!
September 27th, 2012 at 07:43
Any chance to update ShareKit for Xcode 4.5 and IOS Deployment Target 6.0?
January 16th, 2013 at 03:21
Thanks a lot,I was try to solve for long time