My iOS application\'s size is quite bigger on app store. How can I lower achieve the app thinning so that application size get lower.
Note
:-
As far as i understand App thinning, it is all done by Apple. It looks at what is the target device, and the required images and stuff will be provided to the user automatically.
If you would like get thinner app, maybe refactoring is the topic you should look at.
App slicing is currently not working until further notice. The only way to reduce your app size is currently to reduce the amount of assets included in the .ipa.
You could try using On Demand Resources if they make sense for your app.
Searching app thining, bit code and on demand app resource from yesterday, Now I debug all these things and sharing my knowledge that I got from beautiful apple documentation with help of my sample project.
App thinning concept covers bit code and on-demand resource. I will discuss on-demand resource in detail below:-
On-Demand Resources in iOS:-
It is accessing the images/videos/.h/.m/swift file whenever needed (Yes, on-demand resouring include source code files also
).
Resource tags
setting in your target. Tag
. It will appear under Download Only On demand.Now comes the coding part (my favourite site):-
NSBundleResourceRequest *resourceRequest;
#pragma mark - On demand resource
-(void)getOnDemandResource{
NSSet *setOfTag = [NSSet setWithObjects:@"chair", nil];
resourceRequest = [[NSBundleResourceRequest alloc]initWithTags:setOfTag];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
if (!resourcesAvailable) {
// resourceRequest.loadingPriority = 1;//set the downloading priority (0 - 1) , NSBundleResourceRequestLoadingPriorityUrgent
[resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:error.debugDescription preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
}else{
//// The associated resources are loaded
}
}];
}else{
// The associated resources are available
}
}];
}
End accessing the on demand resource when not in use(generally when game level changes)
#pragma mark - Remove access to on demand
-(void)endAccessToOnDemandResource{
[resourceRequest endAccessingResources];
}
NOTE:-
Don't forgot to enable On_Demand_Resources in build setting.
EXAMPLE PROJECT:- I create a sample project and uploaded here:- [http://www.dropbox.com/s/edi5zj68a4wuguh/WebOnTab.zip?dl=0][6]
Please don't bother about autolayout in this project. My main focus is on demand resourcing/App thing.
SUMMARY:- Thus we can achieve app thinning
by on-demand resourcing
using above technique. Please also have a look at official documentation which also describes about tracking progress
, priorities
of resourceRequests(NSBundleResourceRequest
).