在iPhone应用程序中实现应用程序细化 [英] Implement app thinning in iphone application
问题描述
我的iOS应用程序在应用商店中的尺寸很大.如何降低应用程序精简,以使应用程序尺寸变小.
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
:-
- 我已经在使用Images.xcassets分别放置x/2x/3x图像.
- 我还阅读了苹果文档,并仔细阅读了优化级别的构建设置.
- 我还使用了8位PNG而不是32位PNG.
- I am already using Images.xcassets to put x/2x/3x images separately.
- I also read this apple documentation and take care of optimisation level build settings.
- I am also using an 8-bit PNG instead of a 32-bit PNG.
推荐答案
从昨天开始搜索应用程序细化,位代码和按需应用程序资源,现在我调试所有这些内容并分享我从美丽的苹果文档,并在我的示例项目的帮助下.
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:-
iOS中的按需资源:-
它会在需要时访问
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
设置. - 创建一个新的
Tag
.它将显示在仅按需下载"下. - 您可以在各种标签下添加.h,.m,.xassest,.png等.您还可以通过选择单个文件在文件检查器中像这样.
- Goto
Resource tags
setting in your target. - Create a new
Tag
. It will appear under Download Only On demand. - You can add .h, .m, .xassest, .png etc under various tags. You can also assign tag by selecting individual file like this in file inspector.
现在是编码部分(我最喜欢的网站):-
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:-
不要忘记请不要为这个项目中的自动布局而烦恼.我主要关注需求资源/应用程序事情.
Please don't bother about autolayout in this project. My main focus is on demand resourcing/App thing.
摘要:-因此,使用上述技术,我们可以通过on-demand resourcing
来实现app thinning
.另请参阅
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
).
这篇关于在iPhone应用程序中实现应用程序细化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!