Hello,
First of all thanks for such library. My app size grew a lot and when i tried to find out the problem I saw my generated ipa file.
My :
I am using RxSwift from cocopods as :
pod 'RxSwift', '~> 3.0.1'
pod 'RxCocoa', '~> 3.0.1'
App is for IOS >= 9
using single xcode version 8.2.1 and Swift 3.0.1
What can i do to reduce binary size of framework?
Best Regards
Hi @ergunkocak ,
I don't think this is the amount of data that will be sent to end user on each app download.
There is a mechanism called app thinning.
You also need to zip the framework contents.
I think that RxSwift should be ~1.3MB and RxCocoa ~0.8MB zipped after app thinning.
That's about the size of two jpeg images in 3x resolution.
If you want to further reduce the file size you can fork the library and remove files that you think you don't need.
Hi @kzaher ,
TL;DR;
When bitcode disabled and always embed swift is disabled, the difference is 4 MB.
Never enable bitcode :)
Long Journey
I know about app thinning thanks for reminding. On weekend i made a test with my pet project which has no image except the app icon. I uploaded it to TestFlight with and without Rx to test your theory. Here is the results in TestFlight:
I just added to Podfile these lines :
pod 'RxSwift', '~> 3.1.0'
pod 'RxCocoa', '~> 3.1.0'
And just imported in AppDelegate :
import RxSwift
import RxCocoa
There is no other change. Project is not using Rx in anywhere at all.
First results were pretty confusing; sometimes added 20 MB sometimes 9MB. I made many tests so i use sometimes :) Here is just one result with 9MB difference (the best i got) :
with Rx :
without Rx :
Then i wanted to try something else; removing bit code support and setting always embed swift binaries to false. Results are funny:
with Rx :
without Rx :
Rx is costing 4MB at least
I especially shared this to help others who may encounter same problem.
@kzaher one question though how can i zip framework contents? I want to test that too
Cheers
Hi @ergunkocak ,
Maybe I'm wrong about this, but not sure why are you getting those results.
Here is something you can try as a sanity check.
Build Rx in release mode with optimizations turned on (any optimizations you fancy) for single architecture only and zip the contents.
That's how I got
I think that RxSwift should be ~1.3MB and RxCocoa ~0.8MB zipped after app thinning.
App you download from the App Store should already be zipped. That's approx 2MB for both.
It seems to me that in your case you might have downloaded two architectures (without bitcode).
Probably arm_v7 and arm64.
If you download binary from latest release https://github.com/ReactiveX/RxSwift/releases/tag/3.1.0 unzip the binaries and zip only RxSwift, you'll get ~10.2MB (all architectures with bitcode).
/Users/kzaher/Downloads/Carthage 2/Build/iOS/RxSwift.framework/RxSwift: Mach-O universal binary with 4 architectures: [i386: Mach-O dynamically linked shared library i386] [x86_64] [arm_v7] [arm64]
/Users/kzaher/Downloads/Carthage 2/Build/iOS/RxSwift.framework/RxSwift (for architecture i386): Mach-O dynamically linked shared library i386
/Users/kzaher/Downloads/Carthage 2/Build/iOS/RxSwift.framework/RxSwift (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/Users/kzaher/Downloads/Carthage 2/Build/iOS/RxSwift.framework/RxSwift (for architecture armv7): Mach-O dynamically linked shared library arm_v7
/Users/kzaher/Downloads/Carthage 2/Build/iOS/RxSwift.framework/RxSwift (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
If you do the same for RxSwift and RxCocoa, you'll get ~15.2 (all architectures with bitcode).
I can't figure out why it behaved that way in your measurements.
Anyway, not sure can do anything else right now except for remedies described previously in this thread.
Most helpful comment
Hi @kzaher ,
TL;DR;
When bitcode disabled and always embed swift is disabled, the difference is 4 MB.
Never enable bitcode :)
Long Journey
I know about app thinning thanks for reminding. On weekend i made a test with my pet project which has no image except the app icon. I uploaded it to TestFlight with and without Rx to test your theory. Here is the results in TestFlight:
I just added to Podfile these lines :
pod 'RxSwift', '~> 3.1.0'
pod 'RxCocoa', '~> 3.1.0'
And just imported in AppDelegate :
import RxSwift
import RxCocoa
There is no other change. Project is not using Rx in anywhere at all.
First results were pretty confusing; sometimes added 20 MB sometimes 9MB. I made many tests so i use sometimes :) Here is just one result with 9MB difference (the best i got) :
with Rx :
without Rx :
Then i wanted to try something else; removing bit code support and setting always embed swift binaries to false. Results are funny:
with Rx :
without Rx :
Rx is costing 4MB at least
I especially shared this to help others who may encounter same problem.