ShareKit
ShareKit copied to clipboard
problem with + (NSString *)shareKitLibraryBundlePath{...}
Hello, I have installed ShareKit modules (great piece of code!) as a separate folder outside of my project tree, in order to prevent conflicts with the git verisoning of my project. The issue below might be an artefact of this particular setup.
The sharekit libs compile fine, and I can link them against my project as expected. When running a test drive, the following function
-
(NSString *)shareKitLibraryBundlePath { if (shareKitLibraryBundlePath == nil) {
shareKitLibraryBundlePath = [[[NSBundle mainBundle] pathForResource:@"ShareKit" ofType:@"bundle"] retain];
} return shareKitLibraryBundlePath; }
called by NSString* SHKLocalizedStringFormat(NSString* key){} generates an exception because the resource bundle sharekit.bundle can't be found.
When putting traces in SHK.m here NSString* SHKLocalizedStringFormat(NSString* key) { ... NSString* Originalpath = [[SHK shareKitLibraryBundlePath] stringByAppendingPathComponent:@"ShareKit.bundle"];
NSString* path =[SHK shareKitLibraryBundlePath];
NSBundle* Originalbundle = [[NSBundle bundleWithPath:Originalpath] retain];
bundle = [[NSBundle bundleWithPath:path] retain];
NSLog(@"path = %@ Bundle = %@",path,bundle.debugDescription);
NSLog(@"OriginalPath = %@ OriginalBundle = %@",Originalpath,Originalbundle.debugDescription);
... } the resource bundle for path is found correctly, it is not however if I use the original code for the path:
[[SHK shareKitLibraryBundlePath] stringByAppendingPathComponent:@"ShareKit.bundle"];
the traces give:
OriginalPath = /var/mobile/Applications/FE...3/My.app/ShareKit.bundle/ShareKit.bundle
OriginalBundle = (null)
Below is the correct path obtained using NSString* path =[SHK shareKitLibraryBundlePath]; path = /var/mobile/Applications/FE2..413/My.app/ShareKit.bundle Bundle = NSBundle </var/mobile/Applications/FE...3/My.app/ShareKit.bundle> (not yet loaded)
The bundle is loaded fine, and I have the sharekit functionality.
It looks like the original code duplicates ShareKit.bundle at the end of the path string which results from the way this string is built, the fact + (NSString *)shareKitLibraryBundlePath returns a fully qualified path already.
My questions are the following:
1-If I change the code to use
path =[SHK shareKitLibraryBundlePath]; instead of path = [[SHK shareKitLibraryBundlePath] stringByAppendingPathComponent:@"ShareKit.bundle"];
Do I introduce a regression that will show up later in the code ? NSString* SHKLocalizedStringFormat(NSString* key) deals with ShareKit.bundle, so it looks pretty safe to change it, provided the bundle is loaded as expected.
2- Is installing Sharekit as a folder outside of my project tree OK ? (file are not copied in the tree, they are just referenced) . It's just that I'd like to have only one checkout of the main Sharekit branch, for maintenance purposes. Plus Xcode-git tends to behave in a weird way if I have .git folders tied to a foreign repository.
Thank You ! Mamo.