PROBLEM: Linking with my library adds 2MB to binary.
I am trying to distribute my own static library on iOS. My library depends on KSCrash and ProtobufObjc pods. Pods are compiled in their own targets and later as a static libs (libabc.a) are linked to target application - that is usual procedure for working with cocoapods. There is a flag '-ObjC' passed to linker, that causes ALL object files from KSCrash and Protobuf to be pulled into resulted app binary. My code has files that contain only categories, so I cannot remove this flags without consequences. Pulling this 2 libs adds up to 1.5MB to resulted app binary size. If I link without '-ObjC' added size is about half less - because dead_stip flag, which, I suppose, works only if there is no '-ObjC', 'load_all' etc flags.
Question: How can I make 'dead_strip' or any other mechanism work, while not loosing Objective-C categories?
notice 1: I cannot afford stripping symbols because I need on-device symbolication.
notice 2: Regeneration of protobuf code with LITE flag doesn't reduce size, I think I have to use C++ version to make it work.
The
-force_load
linker flag should solve your problem. From the Apple documentation:If I understood your problem correctly, you should point
-force_load
to your library archive to include all categories. I don't quite understand why you can live with not loading everything from your dependencies, but it may not be essential to help out...