传送门:大神就是6
2020年5月以来,上传到iTunes Connect的ipa文件如包含UIWebView相关引用,会导致ipa包无法通过处理,构建版本不可用。
解决方案:
- 首先,生成一个URLUtility.mm文件
-
#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