Polidea ios-class-guard 在 XCode 7 中已死,更换还是修复?

Polidea ios-class-guard is DEAD in XCode 7, replace it or fix it?

在XCode 7和iOS 9之前一切都很好。在我们将XCode升级到7.0和7.0.1之后,ios-class -守卫一直在烦我们。 不能按照官方教程安装ios-class-guard。自制软件安装公式失败

The following build commands failed:
CompileC /Users/Digiflex/Library/Developer/Xcode/DerivedData/ios-class-guard-afpnixzupjudctebfxyqptpmbgpa/Build/Intermediates/ios-class-guard.build/Release/MachObjC.build/Objects-normal/x86_64/CDLCSegment.o Source/CDLCSegment.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

然后,我们从Polidea/ios-class-guard下载源代码。在我们修复了几个错误并编译之后。我们将构建和导出归档到

/usr/bin/ios-class-guard 

当我们进行混淆时,它看起来没问题。但是当我们 运行 在 XCode 7 中进行项目时,我们遇到了很多错误,例如:

Unexpected '@' in program

Missing context for method declaration

经过数小时的研究仍未得出结论,我们的问题是:

  1. 如何在XCode 7环境下自行解决ios-class-guard问题?

  2. 是否有其他开源项目提供类似的功能,可以混淆Class、方法和字符串?

我通过替换

成功修复了此类错误
#import <Foundation/Foundation.h>

与:

@import UIKit;

在我的项目.pch 文件中。 然后我也改变了我的项目构建设置:

启用模块(C 和 objective C)为 YES

但是 我最终在 .pch 文件中导入 类 时遇到了同样的问题:

    #import "BDError.h"

iOS Class Guard 的新版本 (0.8),支持 Xcode 7。

iOS Class Guard 的最新版本(撰写本文时为 0.8)仍然存在 Xcode 7.3 的问题,并且没有完全修复对早期版本的支持Xcode7.

  1. How to fix the ios-class-guard problem by myself, under XCode 7 environment?

从 Xcode 7 开始,Xcode 附带的 iPhoneOS SDK 不再包含基于 ARM 的 .dylib 动态库文件,并且这些已被替换为 .tdb 文件。 .tbd 文件似乎是描述其相应 .dylib 文件的标记(文本)文件,特别是至少包括一些符号。您看到的错误是因为此更改。

这样做的结果是,为了混淆基于 ARM 的构建,要排除的符号只能通过检查 iPhone 模拟器库来找到。目前,这意味着必须为构建的分析阶段创建 x86/x86_64 构建。

根据“apple staff”:

"For those who are curious, the .tbd files are new 'text-based stub libraries', that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size."

不过,这些 .tbd 文件不包含自动查找排除项所需的所有符号。

iOS Class Guard 0.8 修复了错误消息,但是它没有找到所有应该排除的符号。

  1. Is there any other open source project provide a similar feature, which is can obfuscate Class, Method and String?

是的,PPiOS-Rename is a fork of ios-class-guard that fixes this issue, by always searching for symbols in the iPhoneSimulator SDK, even if the build was compiled for a device. It has also been updated to work with Xcode 7.3. (Full disclosure: I work for PreEmptive Solutions 谁创建了这个分支,但它是开源且免费的。)