ASIHTTPRequest and ShareKit in the same app has two reachability files - iphone

I am creating an iOS app which uses both ASIHTTPRequest and ShareKit. Both APIs have a Reachability.h and Reachability.m file... thus this is creating a Mach-O duplication error. Is there a special way to avoid this?
Thanks

I had this issue a little while back and figured out an easy fix.
You have two options.
1) If the versions of the two Reachability sets are the same, you could just delete one set. I don't think you should even have to change any headers.
2) If the versions are different, rename one set of Reachability files something like "MyReachability". Obviously you will have to clean up all references to the renamed class as well.
Hope that helps!

Related

.h file in my Swift Framework

I am creating my first Swift framework and I notice there is a default .h file (Obj-C). What purpose does it serve in a Swift Framwork? Can it be removed without causing problems?
It is a bridging header to make sure everything plays nice with Obj-C frameworks. You may be okay deleting it depending on the intended use of your framework, but it won't hurt anything to leave it in so that's what I would recommend for best practice and to make sure you don't accidentally break anything in different contexts that you use the framework in.

xcode build error : duplicate symbol when my project has two files with the same name

My project has a file named "Reachability.h" (It's very popular, many people use it)
Today I add a framework of others into my project.
I think the frameword has the same file "Reachability.h".
So there is a conflict.
Is it because there is NO namespace in C?
How to avoid this problem?
And here is the log:
ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in /Volumes/Data/Project/ios/FreeMaster/FreeMaster/src/ThirdParty/Lmmob/LmmobAdWallSDK.framework/LmmobAdWallSDK(Reachability.o) and /Users/lxp/Library/Developer/Xcode/DerivedData/FreeMaster-hdzirfpzangiuqaavvqkrzlccrku/Build/Intermediates/FreeMaster.build/Debug-iphonesimulator/FreeMaster.build/Objects-normal/i386/Reachability.o for architecture i386
Thanks very much
Correct, there´s no namespace in Objective-C, this problem is often circumvented by using prefixed classes. This is often also the problem when you get "undeserved" rejections from Apple for using private API's you´re not using, e.g. a class called BaseResponse caused us trouble.
Apple reserves the right to have prefixed classes, but in this case you either have to prefix it or rename your class to something else.
There is no namesapce or package kind of stuff in objective-c.
Generally if you are same class as in the library, you can delete your class. Import <yourFramework/Reachability.h> where ever you use reachability in your code.
Maintain single copy of Reachability files(.h, .m) in your project & remove the extra files. That will solve the issue.
If you want to maintain an extra copy you can create a newgroup and move Reachability files into that folder as in the below screenshot:
In my finder my files are placed like this:

iPhone localization not working properly

I've been developing an app which is localized in two languages. Everything has been going good so far until today.
What happens is that if i deploy the application on device, it alternates between being localized and not being localized (in which case it just shows the localized keys and not strings). It is getting really really annoying and I haven't been able to find a solution for this. I think it has to do with my Xcode setup perhaps?
This happened earlier in another project as well, but I could never see what was the matter.
Well, right after posting this question, it struck me that the only common thing I added in both projects was the ShareKit. share kit introduces its own localizable strings and for some odd reason, the iOS alternates between ShareKit's localizable files and my own. Moving share kit localizations into my own fixed the issue.
How should such a situation be handled?
I updated the question.
How should such a situation be handled?
The library (in this case, ShareKit) is at fault. Libraries that are meant to be included in other code should not use the default file name Localizable.string. They should give their .strings file a unique name and use NSLocalizedStringFromTable() in their code.

iPhone static lib

i want to share some code with other iOS projects. So I create static library.
When I use this library in other projects and use header file from that lib I get an error like No such file and Directory. Can any one tell me fixes of it.
Here I get reference for making static lib
http://www.amateurinmotion.com/articles/2009/02/08/creating-a-static-library-for-iphone.html
I downloaded that sample. It is also not working in my case. So please help me to fix that error.
Thanks in advance
My guess would be because the blog, whilst detailed, is probably a bit old now. Like anything there's a thousand ways to skin a cat.
You can now create frameworks for the iPhone sdk and include both simulator and device versions of the classes. Frameworks have the advantage that they can simply be dragged and dropped on Xcode to include them in a project. In addition I like to store my frameworks in version numbered directories so if I make changes, dependent projects can still use the old ones until I'm ready to update them.
I don't do it, but for the above reasons I'm not sure I'd drag and drop a libs project on a client project. To me the idea of a static framework is that it's independent on it's clients. Dropping it into client projects makes a connection between the two projects that is too tight.
Anyway do some searches on lipo and static frameworks. I also have so scripts in my project at https://github.com/drekka/dUsefulStuff that you mint find useful.

Want to share a MGTwitterEngine iPhone Xcode skeleton project?

Anyone want to share an Xcode project that has MGTwitterEngine in it? Mine won't compile. Are there certain project settings to set? I just made a stock tab bar app for iPhone and added the MGTwitterEngine files. Tons of compiler errors. What am I missing?
I had same problem. To get it to compile I added "$SDKROOT/usr/include/libxml2" to the Header Search Paths list. I also checked Recursive checkbox.
Make sure that you're adding "$SDKROOT/usr/include/libxml2" to header search paths in your Target settings and not just the Project.
I managed to get the library path right eventually. However, in the end, I got rid of the whole MGTwitterEngine thing and went with the TwitterHelper stuff that I noticed the folks from the Stanford iPhone class using. It uses the synchronous calls and it's not as full-featured. But it's lighter and I understand it better. I just use threading to counter the synchronicity. (Hey, wasn't that a song?!) Anyway, a little JSON code and it's all under control. Most of you are probably going to think I'm a noob but it just feels cleaner and easier to handle. I know there are plenty of good reasons to use MGTwitterEngine.
Bottom line is, even though I got it to work by getting the library path right, I don't even need to worry about any paths by adding the very small TwitterHelper stuff to my project. Seems more Mac-like than to have to go into too much tinkering (I can already hear the experts saying that setting paths is not too much but I absolutely detest the Project Settings dialog.)
You also need to add
libxml to Header Search Path ( should be something like /usr/library/libxml2 )
I just wanted to add something that tripped me up. You have to make sure the Target header search path is also set because it may override the default project search path headers. If you are unable to find some header files that the path is definitely pointing to correctly in your project search path headers, then this is probably the reason.
You're probably missing the libxml library. You need to add that to your linked frameworks. Here's a question that has a little more information, but that's the gist of it.
Best approach for XML parsing on the iPhone