Unity,libiPhone-lib.a去掉webview

公司大部分项目用的是unity4.72和unity5.62,苹果要求去掉webview,但是项目又不能更新unity,所以只能手动去掉.a库的webview

先自己查下.a库支持armv7,arm64,armv7s不,然后拆出来

lipo libiPhone-lib.a -thin armv7 -output armv7-libiPhone-lib.a
lipo libiPhone-lib.a -thin arm64 -output arm64-libiPhone-lib.a
lipo libiPhone-lib.a -thin armv7s -output armv7s-libiPhone-lib.a

注意下,unity版本不一样,支持的也不一样,而且不是每个.a都有webview,需要自己检查下

将以下内容保存为 URLUtility.mm

#include 
#import 
using namespace std;
namespace core {
template 
class StringStorageDefault {};
template 
class basic_string {
public:
char *c_str(void);
};
}
void OpenURLInGame(core::basic_string< char,core::StringStorageDefault > const&arg){}
void OpenURL(core::basic_string >const&arg){
const void *arg2= &arg;
UIApplication *app = [UIApplication sharedApplication];
NSString *urlStr = [NSString stringWithUTF8String:(char *)arg2];
NSURL *url = [NSURL URLWithString:urlStr];
[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];
[app openURL:url];
}

构建需要的.o (每一个都要单独构建,后面需要单独合并)

clang -c URLUtility.mm -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
clang -c URLUtility.mm -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
//删除
ar -d armv7-libiPhone-lib.a URLUtility.o
//添加
ar -q armv7-libiPhone-lib.a URLUtility.o

最后合并

lipo -create armv7-libiPhone-lib.a arm64-libiPhone-lib.a armv7s-libiPhone-lib.a -output libiPhone-lib.a 

unity每一次导xcode都需要替换哦,直接用合并出来的.a库替换就好了,不需要每次都走一遍流程

最后如果xcode跑不起来,试试

试一下在 other link flags:
添加一项:
-Wl,-undefined,dynamic_lookup

你可能感兴趣的:(Unity,libiPhone-lib.a去掉webview)