libiPhone-lib.a、Unity3D 去掉UIWebview

如下命令只針對arm64架構ios

# 將如下代碼保存至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];
    [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];
    
}


複製代碼

# 編譯成新的目標文件:URLUtility.o

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

# 去掉原來的目標文件:URLUtility.o

ar -d libiPhone-lib.a URLUtility.o架構

# 將新的URLUtility.o增長進靜態庫末端

ar -q libiPhone-lib.a URLUtility.oapp

相關文章
相關標籤/搜索