在 ObjC 项目里使用 Swift 静态库
Mar 29, 2019
Xcode 9 开始 Swift 支持编译生成静态类型的 framework 如果给之前的 ObjC 项目直接添加 Swift 写的 framework,在编译的时候会报错,错误信息是无法找到 Swift 的方法。 解决方…
git with GPG sign
Mar 25, 2019
Setup GPG pub key for git server Install GPG Suite or gpgosx on macOS Create a GPG key Setup GPG pub key for github or gitlab etc. Setup GPG key for git client List all GPG key gpg -K Setup signingkey for git git config user.signingkey your-key Enable gpgsign for git commit git config commit.gpgsign true using gpg2 git config --global gpg.program $(which gpg2)
GNU auto tools
Mar 25, 2019
The GNU Autotools: Autoconf Automake Libtool (Xcode built-in) Gettext
Make carthage portable
Mar 23, 2019
I wanna run carthage without install CarthageKit.framework to system library. Download latest release get latest carthage pkg form https://github.com/Carthage/Carthage/releases Extract pkg file pkgutil --expand-full Carthage.pkg Carthage Copy to system path cp Carthage/CarthageApp.pkg/Payload/usr/local/bin/carthage /usr/local/bin mkdir -p /usr/local/Library/Frameworks cp -r Carthage/CarthageApp.pkg/Payload/Library/Frameworks/CarthageKit.framework /usr/local/Library/Frameworks Add rpath for carthage install_name_tool -add_rpath @executable_path/../Library/Frameworks /usr/local/bin/carthage install_name_tool -add_rpath @executable_path/../Library/Frameworks/CarthageKit.framework/Versions/Current/Frameworks /usr/local/bin/carthage All done. I using a shell script make it easy #!/bin/bash set -e if [ ! -f Carthage.pkg ]; then echo Carthage.…
fatal: cannot run gpg: No such file or directory
Mar 22, 2019
After installed GPG Site: https://gpgtools.org/ Git commit with error: fatal: cannot run gpg: No such file or directory error: gpg failed to sign the data fatal: failed to write commit object Solution: git config --global gpg.program $(which gpg) About Signing commits
Using xcrun
Mar 22, 2019
Run a command with special toolchain # using clang of toolchain org.llvm.8.0.0 xcrun --toolchain org.llvm.8.0.0 clang -v output clang version 8.0.0 Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/LLVM8.0.0.xctoolchain/usr/bin Show SDK path xcrun --show-sdk-path --sdk iphoneos /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk xcrun --show-sdk-path --sdk iphonesimulator /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk xcrun --show-sdk-path --sdk macosx /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
build LLVM 8 on macOS
Mar 21, 2019
TL;DR download my pre-built: LLVM8.0.1.xctoolchain.7z MD5: 32241cb3e093b15c58bd40200dc2fd76 LLVM8.0.0.xctoolchain.7z MD5: 169fd4d3fdffa5a136cbe77aac759cdc prepare building lldb Install editline Install pcre && swig Read code-signing.txt building clone llvm-project checkout 8.0 branch cd llvm run build-llvm.sh build-llvm.sh #!/bin/bash set -e mkdir build && cd build output=/tmp/llvm-build cmake -DCMAKE_INSTALL_PREFIX=${output} \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_INCLUDE_TESTS=OFF \ -DLLVM_INCLUDE_EXAMPLES=OFF \ -DLLDB_CODESIGN_IDENTITY='' \ -DLLDB_BUILD_FRAMEWORK=ON \ -DLLVM_ENABLE_PROJECTS="all" \ -DLLVM_CREATE_XCODE_TOOLCHAIN=ON \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ -GNinja \ .. ninja ninja install-xcode-toolchain echo build finish. echo toolchain installed at ${output} Note: you need install cmake and ninja first.…
A simple Dispatch Queue Pool
Mar 18, 2019
I named it MDispatchQueuePool. Really easy to use: [MDispatchQueuePool.sharedPool asyncExecute:^{ // put your code here ... }]; Here is MDispatchQueuePool.m @interface MDispatchQueuePool () { dispatch_queue_t _executionQueue; dispatch_queue_t _waitingQueue; dispatch_semaphore_t _maximumQueueSemaphore; } @end @implementation MDispatchQueuePool + (instancetype)sharedPool { static MDispatchQueuePool *pool = nil; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ pool = [[self alloc] init]; }); return pool; } - (instancetype)init { if (self = [super init]) { _executionQueue = dispatch_queue_create("queue.exec.MDispatchQueuePool", DISPATCH_QUEUE_CONCURRENT); _waitingQueue = dispatch_queue_create("queue.…
Build LLVM for macOS
Mar 13, 2019
Build LLVM We build a toolchain for Xcode, and include these projects: clang clang-tools-extra libcxx libcxxabi compiler-rt libunwind polly lld clone llvm project, and build the 7.0.1 version git clone https://github.com/llvm/llvm-project.git llvm-project cd llvm-project/llvm git checkout llvmorg-7.0.1 mkdir build && cd build && build_llvm.sh Build obfuscator-LLVM obfuscator-LLVM upon LLVM, so We must clone LLVM project first. We build heroims’ fork, because his fork is newer. cd llvm-project git clone https://github.com/heroims/obfuscator.git…
Build boringssl for iOS
Feb 16, 2019
Clone boringssl git clone https://github.com/google/boringssl.git boringssl Build boringssl cd boringssl mkdir build && cd build ./build.ios build.ios is my build script #!/bin/bash set -e export IPHONEOS_DEPLOYMENT_TARGET="9.0" # for -miphoneos-version-min arch=arm64 mkdir ${arch} && cd ${arch} cmake -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=${arch} -GNinja ../.. ninja cd .. arch=armv7 mkdir ${arch} && cd ${arch} cmake -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=${arch} -GNinja ../.. ninja cd .. arch=x86_64 mkdir ${arch} && cd ${arch} cmake -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=${arch} -GNinja ../.. ninja cd .…