Obfuscate iOS project using iOS ClassGuard - ios

How to obfuscate iOS project using iOS ClassGuard project:
https://github.com/Polidea/ios-class-guard
I am using this project to obfuscate my iOS project. Unfortunately, it is not working, throwing error.
I followed the steps provided to How to use it. But, when I am doing
bash obfuscate_project
The build was successful but it crashed after that. Here is the report:
ios-class-guard[57105:1897397] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: 'working directory
doesn't exist.'
*** First throw call stack: ( 0 CoreFoundation 0x00007fff856ad03c __exceptionPreprocess + 172 1 libobjc.A.dylib
0x00007fff88bf876e objc_exception_throw + 43 2 CoreFoundation
0x00007fff856aceed +[NSException raise:format:] + 205 3 Foundation
0x00007fff86d682a6 -[NSConcreteTask launchWithDictionary:] + 582 4
ios-class-guard 0x000000010f1db7d6
-[CDSystemProtocolsProcessor systemProtocolsSymbolsToExclude] + 534 5 ios-class-guard 0x000000010f1977e2 main + 6110 6
libdyld.dylib 0x00007fff8b4275c9 start + 1 )
libc++abi.dylib: terminating with uncaught exception of type
NSException obfuscate_project: line 28: 57105 Abort trap: 6
"$#"
Please let me know how to fix this issue.

Fixed this issue following these steps:
What to change while obfuscation:
1. cd project folder path
2. Download iOS ClassGuard project.
curl -o obfuscate_project https://raw.githubusercontent.com/Polidea/ios-class-guard/master/contrib/obfuscate_project && chmod +x obfuscate_project
3. change mode:
chmod +x obfuscate_project
4. Open obfuscate_project in text editor
change following things:
From...
PROJECT=YourProject.xcodeproj
SCHEME=YourScheme
CONFIGURATION=Release
SDK=7.1
From...
"--sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$SDK.sdk"
To...
"--sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk"
5. bash obfuscate_project
This will start building the project and after that it will obfuscate.
Two files will be created: 1. symbols.h and 2. symbols.json
pch file will be modified
But after obfuscating, the project is not compiling.
It is throwing error:
> Use of undeclared identifier

Fixed this issue. Steps that I took to fix this are:
Add "symbols.h" file in the project.
Import "symbols.h" file in your .pch file.
Add "symbols.h" file only for release mode, importing that file like this:
ifndef DEBUG
#import "symbols.h"
endif
Now compile the project for anything - "Debug" or "Release" mode. Everything work fine without errors.
Hope it helps someone.

Related

All framework error when launch framework/Info.plist: No such file or directory

I have a project on react native,
I'm Stack all day with this error I try a lot of things but nothing works, build successfully but the application is not launched on device or simulator here is the error I got
Could not install at this time.
Failed to load Info.plist from bundle at path /Users/BT/Library/Developer/CoreSimulator/Devices/32A76497-8C7B-4639-B3F9-80379AF5CB9A/data/Library/Caches/com.apple.mobile.installd.staging/temp.SEVqpI/extracted/XXXXXX.app/Frameworks/RCTVibration.framework; Extra info about Info.plist: Couldn't stat /Users/BT/Library/Developer/CoreSimulator/Devices/32A76497-8C7B-4639-B3F9-80379AF5CB9A/data/Library/Caches/com.apple.mobile.installd.staging/temp.SEVqpI/extracted/XXXXX.app/Frameworks/RCTVibration.framework/Info.plist: No such file or directory
Even I reset to the old version of the project witch worked perfectly I'm getting the error
When I add a info.plist to RCTVibration other library has the same problem as 20 library
I tried to clean project, close xcode, delete derived data, restart Mac i tried Embded Framework copy only when installing ... but still stuck i can't delete use_frameworks! because i have dynamic and no dynamic framework
On device i'm getting a different error :
Details
Unable to install "XXXXX"
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653103
Could not inspect the application package.
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653103
User Info: {
DVTRadarComponentKey = 282703;
MobileDeviceErrorCode = "(0xE8000051)";
"com.apple.dtdevicekit.stacktrace" = (
0 DTDeviceKitBase 0x0000000129dbe93f DTDKCreateNSErrorFromAMDErrorCode + 220
1 DTDeviceKitBase 0x0000000129dfd124 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 155
2 DVTFoundation 0x000000010d9a1b43 DVTInvokeWithStrongOwnership + 71
3 DTDeviceKitBase 0x0000000129dfce65 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1440
4 IDEiOSSupportCore 0x0000000129c6dd28 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.292 + 3513
5 DVTFoundation 0x000000010dad02aa DVT_CALLING_CLIENT_BLOCK + 7
6 DVTFoundation 0x000000010dad1ecc __DVTDispatchAsync_block_invoke + 1191
7 libdispatch.dylib 0x00007fff6d0416c4 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x00007fff6d042658 _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fff6d047c44 _dispatch_lane_serial_drain + 597
10 libdispatch.dylib 0x00007fff6d0485d6 _dispatch_lane_invoke + 363
11 libdispatch.dylib 0x00007fff6d051c09 _dispatch_workloop_worker_thread + 596
12 libsystem_pthread.dylib 0x00007fff6d29ca3d _pthread_wqthread + 290
13 libsystem_pthread.dylib 0x00007fff6d29bb77 start_wqthread + 15
);
}
System Information
macOS Version 10.15.7 (Build 19H2)
Xcode 12.0.1 (17220)
any help will be appreciated
I tried even uninstall xcode and install again another version, also pull project git on a new location, create new simulator, restart device nothing worked
What worked for is adding for every framework, click on choose info.plist file like image show it and pods-Project-info.plist and it will be filled with correct information
It's not the best solution because it takes me a lot of time to associate all plist file, but it's the only solution that worked for me
Try running your project with npx react-native run-ios.
After hours of struggling and trying everything I found (cleaning derived data, erasing content and settings of simulators, reinstalling Xcode...)
This is the only thing that made it work, I was even able to build with Xcode after running the build with npx.
I was getting a similar error even after the builds passed and the simulator popped up. But the app was prevented from opening as it seems there was some .plist file missing in the frameworks.
I rechecked and set the Embed mode to "Do not Embed" for each of the frameworks added in the .xcworkspace target > General.
I also might had Clean the build folder (Cmd + Shift + K), closed the xcode, deleted DerivedData, pod deintegrate && pod update before shooting the Run in xcode again.
Other Info: Xcode-13.2.1, React Native project, M1Pro mac, Xcode running in Rosetta, Excluded Architecture - arch64 (in target & project Build Settings)
Clean drive data in XCODE preferences, clean and then rebuild the project. Hope it works!
One probable solution is following the steps:
Run pod install command in your terminal
Before installing App again delete content of your Derived Data
folder
Build and run to install the app.
Moreover if the above 2 steps doesn't work the try removing use_frameworks! from your Podfile and follow steps 1 & 2.
I also tried all the methods mentioned above, but they didn't work, and when I debugged all the Cocoapod and XcodeProj in Ruby, it was confirmed that the problem occurred due to the special setting. It may be a unique case, but it is very simple to check, so I recommend you to try it...
if ENV['INFOPLIST_FILE'] has a file for any Info.plist,
CocoaPods doesn't make Info.plist for Pod targets.
reference: https://github.com/CocoaPods/Xcodeproj/blob/29cd0821d47f864abbd1ca80f23ff2aded0adfed/lib/xcodeproj/project/object/build_configuration.rb#L115
I put this phrase in for the test and I was able to confirm that the file existed.
puts "#{ENV['INFOPLIST_FILE']}"
Finally, I could solved adding this line on top of Podfile.
ENV['INFOPLIST_FILE'] = nil
By the way, I don't know how I ended up assigning a specific Info.plist file to ENV...

Step to configure ML Kit library model in podfile - flutter apps

I am new in using ios, and right now I am using this package https://pub.dev/packages/firebase_ml_vision to do face detection... here is said that
If you're using one of the on-device APIs, include the corresponding ML Kit library model in your Podfile. Then run pod update in a terminal within the same directory as your Podfile. and right now I am using 'Firebase/MLVisionFaceModel' and I need to do pod 'Firebase/MLVisionFaceModel'... since I am new in using ios, I am trying to find a tutorial how to configure it in ios, but I still don't find yet... what I don't understand here is how to include the corresponding ML Kit library model in my Podfile... should I edit it inside Xcode or inside ios folder in my flutter project?... is anyone here know how step by step to configure it?
and here is what I get when I didn't set that up
Xcode build done. 26.9s
Configuring the default Firebase app...
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c710bc +[NSException raise:format:] + 188
3 Runner 0x00000001064aafca +[FIRApp configure] + 138
4 Runner 0x0000000106a6dab6 -[FLTFirebaseMlVisionPlugin init] + 214
5 Runner 0x0000000106a6d8f3 +[FLTFirebaseMlVisionPlugin registerWithRegistrar:] + 211
6 Runner 0x00000001064a5bf5 +[GeneratedPluginRegistrant registerWithRegistry:] + 309
7 Runner <…>

Trouble reading output console Flutter

I'm following the tutorial on flutter_bloc firebase login.
First I tried downloading the repo, adding my reversed Key in the Info.plist, my own GoogleService_Info.plist and launching the example it works.
Then I started again from scratch, but I get this output which I can't understand and the app doesn't start on iPhone simulator:
Xcode build done. 41.0s
Configuring the default Firebase app...
*** First throw call stack: ( 0 CoreFoundation 0x00000001082e46fb __exceptionPreprocess + 331 1 libobjc.A.dylib
0x0000000107888ac5 objc_exception_throw + 48 2 CoreFoundation
0x00000001082e4555 +[NSException raise:format:] + 197 3 Runner
0x0000000103ae64da +[FIRApp configure] + 138 4 Runner
0x0000000103bdae86 -[FLTFirebaseAuthPlugin init] + 214 5 Runner
0x0000000103bdac38 +[FLTFirebaseAuthPlugin registerWithRegistrar:] +
184 6 Runner 0x0000000103a8bbc0
+[GeneratedPluginRegistrant registerWithRegistry:] + 112 7 Runner <…>
I did put the reverse Key in the Info.plist and added my own GoogleService-Info.plist file in Runner but my app version doesn't start..
Actually when looking for the URL where to put the reverse Key I didn't see any, so I added it myself. Can it be a lead to where something gone wrong?
Thank you very much
OK found the problem.. Th GoogleService-Info.plist MUST be added to Runner through Xcode.. I must have just used Finder instead ..
Hope it helps others
Cheers

Flutter firebase_admob not working on iOS with default app install

Steps to reproduce:
create a default app in Android Studio
build and run the app successfully in iOS simulator through Android Studio
add dependency firebase_admob: ^0.9.0+2 in pubspec.yaml
app builds successfully but crashes on startup
follow instructions to add GADApplicationIdentifier with test ID code into ios/Runner/info.plist file
The app still crashes on startup. Instructions were followed for setting up on iOS as detailed here: https://pub.dev/packages/firebase_admob.
As far as I can see, I've done everything as instructed so no idea why it doesn't work with a default app.
The error I get after all steps above is:
Xcode build done. 8.5s
Configuring the default Firebase app...
6.4.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
6.4.0 - [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
6.4.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
6.4.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
*** First throw call stack: ( 0 CoreFoundation 0x0000000113b521bb
__exceptionPreprocess + 331 1 libobjc.A.dylib 0x00000001130f0735
objc_exception_throw + 48 2 CoreFoundation 0x0000000113b52015 +
[NSException raise:format:] + 197 3 Runner 0x000000010bd33af0 +[FIRApp
configure] + 576 4 Runner 0x000000010bd7f1c5 -[FLTFirebaseAdMobPlugin
init] + 261 5 Runner 0x000000010bd7ef2e +[FLTFirebaseAdMobPlugin
registerWithRegistrar:] + 78 6 Runner 0x000000010bd333fb +
[GeneratedPluginRegistrant registerWithRegistry:] + 123 7 Runner <…>
I believe this medium post is the most comprehensive ios Firebase setup guide, however point 1 can be skipped - I have an app using firebase_admob 0.8.0+3 and it works flawlessly under iOS, once all other steps are completed.
You need to add GoogleService-Info.plist from firebase to your project.
Check this links:
https://support.google.com/firebase/answer/7015592
https://firebase.google.com/docs/ios/setup

Firebase error while configuring app - unrecognized selector sent to class

I'm using Firebase in an iOS app and have two separate Firebase projects, one for production and one for development. My two .plist files are GoogleService-Info.plist and GoogleService-Info-Dev.plist, which I have been able to select based on a flag set in Targets -> Build Settings -> Other Swift Flags.
Inside AppDelegate didFinishLaunchingWithOptions:
#if DEBUG
let buildFor = "DEV"
#else
let buildFor = "PROD"
#endif
let firebasePlistFileName = buildFor == "DEV" ? "GoogleService-Info-Dev" : "GoogleService-Info"
let firebaseOptions = FIROptions(contentsOfFile: NSBundle.mainBundle().pathForResource(firebasePlistFileName, ofType: "plist"))
FIRApp.configureWithOptions(firebaseOptions) // line causing new Firebase error
This has been working fine up until today, when I had a problem with another Cocoapod project. I think it started happening when I cleaned the Xcode project or deleted Derived Data folder:
dyld: Library not loaded: #rpath/OtherPod.framework/OtherPod
Referenced from:
/Users/me/Library/Developer/CoreSimulator/Devices/12345678-E1C4-480F-B1D9-C10823DEA810/data/Containers/Bundle/Application/AE7B6EB0-43AB-CCCC-BBBB-AAAA71BF/MyApp.app/MyApp
Reason: image not found
I eventually resolved that by choosing my app under Targets -> General -> Linked Frameworks and Libraries, then added all of the choices inside the Workspace folder (7 other pod projects) and set those ones I added as optional. Ever since then, I've been facing the error described in the title of this post:
2017-02-10 17:19:29.660 MyApp[12639:182433] +[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x10a0442e8
2017-02-10 17:19:29.680 MyApp[12639:182433] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x10a0442e8'
*** First throw call stack:
(
0 CoreFoundation 0x0000000109d88d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001097f121e objc_exception_throw + 48
2 CoreFoundation 0x0000000109df8e44 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000109d0e005 ___forwarding___ + 1013
4 CoreFoundation 0x0000000109d0db88 _CF_forwarding_prep_0 + 120
5 MyApp 0x0000000102d73c9d -[FIRNetwork postURL:payload:queue:usingBackgroundSession:completionHandler:] + 331
6 MyApp 0x0000000102d70e72 -[FIRClearcutLogger sendNextPendingRequestWithCompletionHandler:] + 570
7 MyApp 0x0000000102d70918 -[FIRClearcutLogger sendLogsWithCompletionHandler:] + 447
8 libdispatch.dylib 0x000000010a6ab978 _dispatch_call_block_and_release + 12
9 libdispatch.dylib 0x000000010a6d50cd _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000010a6b2e17 _dispatch_queue_serial_drain + 236
11 libdispatch.dylib 0x000000010a6b3b4b _dispatch_queue_invoke + 1073
12 libdispatch.dylib 0x000000010a6b402b _dispatch_queue_override_invoke + 683
13 libdispatch.dylib 0x000000010a6b6385 _dispatch_root_queue_drain + 720
14 libdispatch.dylib 0x000000010a6b6059 _dispatch_worker_thread3 + 123
15 libsystem_pthread.dylib 0x000000010aa3a712 _pthread_wqthread + 1299
16 libsystem_pthread.dylib 0x000000010aa3a1ed start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have tried a lot of different fixes, including adding to the Link Binary with Libraries, adding to the Other Linker Flags, and none of them have worked.
What could the unrecognized selector possibly be, and how would I change/remove it? Could this issue be due to the earlier one I was facing (library not loaded)?
For clarification, when the unrecognized selector sent to class error happens, the Xcode debug navigator is focused on Thread 7, with the FIRApp.configureWithOptions(firebaseOptions) line being highlighted.
Update
I found a temporary fix by reverting to a previous git commit (cloned my repository into a separate directory), then replacing the majority of the project contents from that old commit with the current error-producing copy, including the App-Name folder within root directory, App-Name.xcodeproj, and App-Name.xcworkspace. I only tested on the simulator (iPhone 7 running iOS 10.2), and that worked. I then successfully submitted a build to iTunes Connect and was able to run that build on my device (iPhone 5c with 10.2.1), but after deleting that and attempting to run a build from Xcode, I got the same error again. However, the error did not occur while running on the simulator. This is in contrast to the initial error scenario as it occurred on both physical device and simulator.
This made me remember that the stack trace I initially posted was that of running the app on the simulator. Running it on the device produced less output, specifically the content after *** First throw call stack: is only (0x1d01cdf7 0x1c27f077 0x1d022467 0x1d020579 0x1cf453d8 0x31ff3f 0x31d653 0x31d05d 0x1c57d57 0x1c63e63 0x1c5b205 0x1c64391 0x1c65d9f 0x1c65ba7 0x1c877937 0x1c877490) instead of the more descriptive output with file/function names.
Earlier, I have faced the same issue, I fixed the issue by reinstalling pod.
Please refer to the below-mentioned steps to resolve the issue.
Please make sure that you have added Add two-parameter in Other Linker Flags.
$(inherited)
-ObjC
Cocoapods:
Just install cocoa-pods again in the project. Please refer below command for remove and install pods.
Remove all Framework from project using below command.
pod deintegrate
pod clean
- Install framework using below pod command
pod install
Manual:
If you have added framework Manual in the project then remove it and add it into the project again.
Issue:
You have faced reference issue in your project (framework not found at
Specific Directory).
Hit the Clean and Build project. Everything worked as expected
Make sure GTMNSData+zlib.m from the GoogleToolboxForMac pod is still being built and linked into your app.
Make sure that -ObjC and -framework GoogleToolboxForMac is in the Link log:
To anyone experiencing this problem, while trying to add the firebase frameworks manually. I had the same issue, which was caused by having different versions of firebase. I tried to add additional frameworks as the readme suggested, but experienced the above mentioned error.
I resolved this by removing all the firebase frameworks from the project and build phases. Downloaded the newest version, and re-added all frameworks to the project, and the problem was resolved.
I just typed pod update and then closed out and reopened Xcode afterward. Worked for me.

Resources