在iphone应用程序中实现app thinning

问题描述 投票:2回答:3

我的iOS应用程序大小在app store上相当大。如何降低app thinning以使应用程序大小降低。

Note -

  1. 我已经使用Images.xcassets分别放置x / 2x / 3x图像。
  2. 我还读了这个apple documentation并负责优化级别的构建设置。
  3. 我也使用8位PNG而不是32位PNG。
ios iphone ios9 xcode7 on-demand-resources
3个回答
1
投票

应用程序切片是currently not working,直到另行通知。目前,减少应用规模的唯一方法是减少.ipa中包含的资产数量。

您可以尝试使用On Demand Resources,如果它们对您的应用程序有意义。


1
投票

从昨天开始搜索app thinning,bitcode和on demand app资源,现在我调试所有这些东西,并在我的示例项目的帮助下分享我从美丽的apple documentation获得的知识。

应用程序细化概念涵盖bit code和按需资源。我将在下面详细讨论按需资源: -

iOS中的按需资源: - 在需要时访问images / videos / .h / .m / swift文件(Yes, on-demand resouring include source code files also)。

  • 在目标中转到Resource tags设置。
  • 创建一个新的Tag。它将显示在仅按需下载。
  • 您可以在各种标签下添加.h,.m,.xassest,.png等。您还可以通过选择单个文件like this in file inspector来分配标签。

现在是编码部分(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
        }
    }];
}

在不使用时结束访问点播资源(通常在游戏级别更改时)

#pragma mark - Remove access to on demand
-(void)endAccessToOnDemandResource{
    [resourceRequest endAccessingResources];
}

qazxsw poi别忘了qazxsw poi。

NOTE:-

请不要担心这个项目中的autolayout。我主要关注需求资源/应用程序的事情。

摘要: - 因此我们可以使用上述技术通过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] 。还请看一下app thinning,它也描述了on-demand resourcingofficial documentation of resourceRequests(tracking progress)。


0
投票

据我所知,App变薄,这一切都是由Apple完成的。它会查看目标设备是什么,所需的图像和内容将自动提供给用户。

如果你想获得更薄的应用程序,也许重构是你应该看的主题。

© www.soinside.com 2019 - 2024. All rights reserved.