Unity去掉删除libiPhone-lib.a中的UIWebView问题 上架被拒UIWebView

传送门:大神就是6

2020年5月以来,上传到iTunes Connect的ipa文件如包含UIWebView相关引用,会导致ipa包无法通过处理,构建版本不可用。

解决方案:

  1. 首先,生成一个URLUtility.mm文件
  2. #include <iostream>
    #import <UIKit/UIKit.h>
    using namespace std;
    namespace core {
        template <class type>
        class StringStorageDefault {};
        template <class type,class type2>
        class basic_string {
        public:
            char * str;
            basic_string( char* arg){
                str = arg;
            }
        };
    }
    void OpenURLInGame(core::basic_string< char,core::StringStorageDefault<char> > const&arg){}
    
    void OpenURL(core::basic_string<char,core::StringStorageDefault<char> >const &arg){
        const void *arg2 = arg.str;
        UIApplication *app = [UIApplication sharedApplication];
        NSString *urlStr = [NSString stringWithUTF8String:(char *)arg2];
        NSURL *url = [NSURL URLWithString:urlStr];
        if (@available(iOS 10.0, *)) {
            [app openURL:url options:@{UIApplicationOpenURLOptionsSourceApplicationKey : @YES} completionHandler:nil];
        } else {
            [app openURL:url];
        }
    }
    
    
    void OpenURL(std::string const&arg){
        UIApplication *app = [UIApplication sharedApplication];
        NSString *urlStr = [NSString stringWithUTF8String:arg.c_str()];
        NSURL *url = [NSURL URLWithString:urlStr];
        if (@available(iOS 10.0, *)) {
            [app openURL:url options:@{UIApplicationOpenURLOptionsSourceApplicationKey : @YES} completionHandler:nil];
        } else {
            [app openURL:url];
        }
    }
    

2.使用lipo查看libiPhone-lib.a文件中包含的架构

lipo -info libiPhone-lib.a 
Architectures in the fat file: libiPhone-lib.a are: armv7 arm64 armv7s

操作流程

 

lipo libiPhone-lib.a -thin arm64 -output ./URLUtility64/libiPhone-lib64.a


ar -d ./URLUtility64/libiPhone-lib64.a URLUtility.o


ar -q ./URLUtility64/libiPhone-lib64.a ./URLUtility.o

3.使用URLUtility.mm生成对应架构下URLUtility.o文件


clang -c URLUtility.mm -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk

4.拆分libiPhone-lib.a中各架构文件

lipo libiPhone-lib.a -thin armv7 -output ./URLUtilityv7/libiPhone-libv7.a

5.移除对应架构中的原有URLUtility.o文件

ar -d ./URLUtilityv7/libiPhone-libv7.a URLUtility.o

6.将新生成的URLUtility.o文件添加到对应架构的.a中
ar -q ./URLUtilityv7/libiPhone-libv7.a ./URLUtility.o

 

7.将各架构的.a文件合并生成新的libiPhone-lib.a
lipo -create ./URLUtility64/libiPhone-lib64.a ./URLUtilityv7/libiPhone-libv7.a -output ./new/libiPhone-lib.a

查询是否还有不允许使用的内容
find . | grep -v .svn  | grep "\.a" | grep -v "\.app" | xargs grep UIWebView

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值