公司大部分項目用的是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崔步,需要自己檢查下
將以下內(nèi)容保存為 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 *c_str(void);
};
}
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;
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];
}
構(gòu)建需要的.o (每一個都要單獨構(gòu)建稳吮,后面需要單獨合并)
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每一次導(dǎo)xcode都需要替換哦,直接用合并出來的.a庫替換就好了刷晋,不需要每次都走一遍流程
最后如果xcode跑不起來盖高,試試
試一下在 other link flags:
添加一項:
-Wl,-undefined,dynamic_lookup