$ git clone -b llvm-3.6.1 https://github.com/obfuscator-llvm/obfuscator.gitgit
$ mkdir buildgithub
$ cd buildvim
$ cmake -DCMAKE_BUILD_TYPE:String=Release ../obfuscator/xcode
$ make -j5bash
將build/bin加入環境變量app
$vim ~/.bash_profileide
export PATH=/Users/dream/ollvm/build/bin:$PATHui
$source ~/.bash_profile插件
基於現有插件修改以下:code
$ cd /Applications/Xcode-beta.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
$ sudo cp -r Clang\ LLVM\ 1.0.xcplugin/ Obfuscator.xcplugin
$ cd Obfuscator.xcplugin/Contents/
$ sudo plutil -convert xml1 Info.plist
$ sudo vim Info.plist
修改文件內容(修改前->修改後)
<string>com.apple.compilers.clang</string> -> <string>com.apple.compilers.obfuscator</string>
<string>Clang LLVM 1.0 Compiler Xcode Plug-in</string> -> <string>Obfuscator Xcode Plug-in</string>
接下來修改Info.plist
$ sudo plutil -convert binary1 Info.plist
$ cd Resources/
$ sudo mv Clang\ LLVM\ 1.0.xcspec Obfuscator.xcspec
$ sudo vim Obfuscator.xcspec
修改成:
Identifier = "com.apple.compilers.llvm.clang.1_0"; -> Identifier = "com.apple.compilers.llvm.obfuscator.3_6_1";
Name = "Apple LLVM 7.0"; -> Name = "Obfuscator 3.6.1";
Description = "Apple LLVM 7.0 compiler"; -> Description = "Obfuscator 3.6.1";
Vendor = Apple; -> Vendor = HEIG-VD;
Version = "7.0"; -> Version = "3.6.1";
ExecPath = "clang"; -> ExecPath = "/Users/dream/ollvm/build/bin/clang";
接下來修改顯示:
$ cd English.lproj/
$ sudo mv Apple\ LLVM\ 7.0.strings "Obfuscator 3.6.1.strings"
$ sudo vim Obfuscator\ 3.6.1.strings
修改成:
"Name" = "Apple LLVM 7.0"; -> "Name" = "Obfuscator 3.6.1";
"Description" = "Apple LLVM 7.0 Compiler"; -> "Description" = "Obfuscator 3.6.1";
"Version" = "7.0"; -> "Version" = "3.6.1";
"Vendor" = "Apple"; -> "Vendor" = "HEIG-VD";
重啓Xcode,Build Options裏面,能夠設置Compiler for C/C++/Objective-C爲Obfuscator 3.6.1, 在CustomFlags中自行添加 flag:
-mllvm -sub -mllvm -fla -mllvm -bcf
編譯時出錯,提示信息以下:
clang-3.6: error: unknown argument: '-gmodules'
clang-3.6: error: unknown argument: '-fembed-bitcode-marker'
Command /Users/dream/ollvm/build/bin/clang failed with exit code 1
在 Build Settings中搜索並修改:
-gmodules: Obfuscator 3.6.1 - Code Generation: Generate Debug Symbols: 原來yes,改爲no
-fembed-bitcode-marker: Build Option: Enable Bitcode: 原來yes,改爲no
補充
---
2016年10月28日18:56:14
目前該方法兼容最新版xcode:8.0