ios-class-guard icon indicating copy to clipboard operation
ios-class-guard copied to clipboard

Cannot compile the app after obfuscation when using Xcode 7

Open johncoding opened this issue 9 years ago • 16 comments

I tried to compile the app after obfuscation by using Xcode 7 GM but compile fails with lot of errors. See few example errors below.

error: use of undeclared identifier 'k1r' self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

error: no known class method for selector 'colorWithWhite:k7G:' self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

error: no visible @interface for 'UIViewController' declares the selector 'b50' [super didReceiveMemoryWarning];

Any glue or plans for Xcode 7 support?

johncoding avatar Sep 10 '15 19:09 johncoding

Hi there! Did you manage to solve this issue somehow? Having same problem and still no luck...

greggS avatar Sep 23 '15 08:09 greggS

I have some debuging results. It turns out that after xcode update list of ibfuscated symbolg grows a lot and includes symbols belonging to iOS SDK itself making mess.

The question is how Xcode 7 changed building symbols lists and why it includes now much more of them.

greggS avatar Sep 23 '15 11:09 greggS

I have same problem under XCode 7.0 I got hundreds

DTAlertView/DTAlertView.h:27:1: unexpected '@' in program
@class DTAlertView;

Everything about DTAlert will cause problems. It wasn't a problem in XCode 6.x.

Now, I am trying to ignore DTAlert in Bash, but the same errors keep popped up.....

jiang-yi-siphty avatar Sep 25 '15 01:09 jiang-yi-siphty

I am facing the same issue. After obfuscation, it is showing errors everywhere in the project. Any luck guys solving this? Please let me know.

chandan276 avatar Sep 25 '15 12:09 chandan276

Updated today to XCode 7.0.1, and I'm getting the same errors. How to fix it?

euroboy avatar Sep 29 '15 13:09 euroboy

We've just release new (0.8) version of iOS Class Guard which, we hope, solves Xcode7 issues. Please upgrade iOS Class Guard and let us know about results.

scibas avatar Oct 14 '15 13:10 scibas

This version 0.8 is working very well with XCode 7.0

renlix avatar Oct 23 '15 17:10 renlix

Thanks a lot for that fix. Works like a charm :)

greggS avatar Oct 26 '15 14:10 greggS

bumped up to Xcode 7.2 today and everything started failing after obfuscation.

Expected an Objective-C directive after '@'

and the actual line of code is just

@property (nonatomic, assign) BOOL enabled;

n8stowell82 avatar Dec 09 '15 06:12 n8stowell82

I'm getting the same errors that "Expected an Objective-C directive after '@'". How to fix it?

vida1199 avatar Dec 30 '15 07:12 vida1199

Am facing the same issue with xCode 7.1.1 and xCode 7.2. How to fix it ?

Mohamed3amer avatar Feb 14 '16 12:02 Mohamed3amer

@Mohamed3amer Did you fix it now?Am so confuse about it.

lin493369 avatar Mar 16 '16 02:03 lin493369

@lin493369 No :( , I tried to exclude the external libraries and the pods libraries from obfuscation but i still facing issues. I posted another issue here https://github.com/Polidea/ios-class-guard/issues/55#issuecomment-185082608.

Mohamed3amer avatar Mar 16 '16 07:03 Mohamed3amer

I have the latest version of the library and still having unexpected '@' in program error under Xcode7 working with a workspace that gathers my project and Pods.

Any solutions?

jjrebollo avatar Apr 19 '16 09:04 jjrebollo

Facing the same issue at xcode7.3. Is there any workaround proposed from the Polidea team? Or simply giving more information on why there are tons of "unexpected '@' in program" at new xcode?

I can try to help. Thanks.

MiguelChiang avatar Apr 26 '16 03:04 MiguelChiang

The approach ios-class-guard takes to renaming is clever, but can produce less than intuitive compiler errors when there is a problem. In order for it to work well, the system libraries that your app uses must be analyzed. ios-class-guard will warn you if this fails. Pay attention to warnings like the following:

2016-04-25 12:41:44.173 ios-class-guard[2598:64769341] Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore
2016-04-25 12:41:44.174 ios-class-guard[2598:64769341] Warning: Couldn't load MachOFile with ID: /System/Library/Frameworks/QuartzCore.framework/QuartzCore, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore
2016-04-25 12:41:44.174 ios-class-guard[2598:64769341] Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
2016-04-25 12:41:44.174 ios-class-guard[2598:64769341] Warning: Couldn't load MachOFile with ID: /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics

This means that ios-class-guard is not able to analyze the dependencies correctly. Apple has dramatically changed the SDKs ship with Xcode (6 and again in 7) to reduce download footprints. iPhoneSimulator SDK still works, but the iPhoneOS SDK format is unsupported. This means that analysis of an ARM binary will not work.

Make sure to look for the Forbidden keywords line:

2016-04-25 12:41:45.225 ios-class-guard[2598:64769341] Forbidden keywords = 98

This number should be > 50k for even a simple iOS project. If the number is very small, analysis of the SDK failed, and poor build results can be expected, including error messages like unexpected '@' in program.

We (PreEmptive Solutions) forked iOS Class Guard, creating a new product, called PreEmptive Protection for iOS - Rename (or PPiOS-Rename), that fixes this issue and a number of others.

PPiOS-Rename uses the same approach to renaming, but will use iPhoneSimulator SDK in lieu of iPhoneOS SDK, even for ARM binaries. Cocoapods should work fine, so long as they are open-source (e.g. they are compiled as part of your build), and not pulled down as compiled static libraries. Closed-source Cocoapods will need to be excluded with something like:

ppios-rename --analyze -F '!CSC*' path/to/your.app

This will exclude all classes, etc. starting with "CSC" ("Closed-Source Cocoapod").

Note that PPiOS-Rename changes the way the obfuscation process is integrated into the build (to make it easier to use), so you'll probably need to make changes to your build, and to pay attention to the new/changed argument names.

Please give it a try and let us know how it works for you.

neuralmer avatar May 09 '16 13:05 neuralmer