How to obfuscate Objective C code of Cordova hybrid app? - ios

I have an Ionic v1 / Cordova mobile app and I need to obfuscate all sources. For obfuscation of Javascript I have used https://github.com/javascript-obfuscator/javascript-obfuscator and for Java for Android I have used https://github.com/greybax/cordova-plugin-proguard. As I couldn't find any cordova plugin for obfuscation of Objective C and I decided to use https://github.com/preemptive/PPiOS-Rename.
However, after obfuscation with PPiOS-Rename, there seems to be a problem with obfuscation of cordova plugins and I'm unable to run the app correctly. If I remove the plugins from obfuscation process the app would work but I need to make obfuscated also the code of plugins.
Does anybody have experience with obfuscating the Objective C code of Cordova app please?
Thanks!

The problem that you have is that Cordova relies on a bridge between your app code written in Javascript and the underlying native code in order to function.
By obfuscating all of the Objective C code, the Javascript layer is unaware of this, and can no longer find the native class names it is looking for.
For example, let's suppose you have included cordova-plugin-device in your app.
Its <feature> definition for iOS maps the Device feature name to the CDVDevice class.
Let's suppose your Cordova app calls the plugin method device.getInfo().
This in turn invokes a call to cordova.exec() which calls the Device feature with the getDeviceInfo action.
Under the hood, Cordova looks up Device to find the native class name it's mapped to (CDVDevice) and then on the iOS platform it attempts to call the getDeviceInfo() member function on this class.
However, by running the PPiOS-Rename tool, you have obfuscated both the class name (CDVDevice) and the function name (getDeviceInfo()) so Cordova cannot find the class or function to invoke, so will throw an error.
In this case you'd need to exclude the CDVDevice using the filter option provided by PPiOS-Rename, for example:
ppios-rename --analyze -F 'CDVDevice' /path/to/program.app/program
If you wish to proceed with obfuscating the Objective C layer of your Cordova app, you will have to add exclusions for all of the class and function names which Cordova calls explicitly from the Javascript layer.
This includes any Cordova plugin interface classes in your project, and possibly classes belonging to the Cordova framework itself (as cordova-plugin-proguard does for ProGuard on Android.

Related

How can I add iOS support via dart ffi without adding flutter sdk as a dependency?

I am working on the dart_ping package and although it currently is tagged with iOS support, it does not actually support iOS. This is due to the way pub.dev detects supported platforms. I have filed an issue on dart-sdk repo.
Nonetheless, I would like to add iOS support while still preserving support for dart native. Right now, dart_ping works by calling the host OS's ping binary. The ping binary is available on Windows, macOS, Linux, and Android but not on iOS.
Current methods of performing a ping on iOS use native Objective-C code and call them via either method channels or ffi. Since method channels are a flutter feature rather than a dart feature, using them would require dart_ping to depend on the flutter sdk, which would prevent it from being used in a dart native application (perhaps server side).
Ffi on the other hand, is a dart native feature and is capable of doing what I want. However, I cannot seem to find a way to include the iOS framework/library/binary for ping in my dart_ping package in a way that instructs a flutter application to include it and link it to the iOS target/runner.
Is there any way to keep dart native support in my package while also supporting the edge case of iOS needing an extra non-dart framework? Even federated plugins depend on the flutter sdk. It seems to me that we need a pure dart equivalent to the federated plugin system.
TLDR: How do I add a pre-compiled iOS framework or binary to a dart package without depending on the flutter sdk and call it only when the package is used on iOS ?
For your specific case of adding iOS support only for Flutter users of your package but keeping the package as pure Dart without a dependency on the Flutter SDK should be possible by having a Flutter plugin package that depends on your Dart package.
In the pure Dart package you can have FFI calls to a native iOS library, but its actually the Flutter plugin package that supplies the native iOS library per the Flutter documentation for using FFI.
You would of course need to make it very clear in the documentation for your pure Dart package that for iOS, it should only be used via the "wrapper" plugin package.
Unfortunately this is a rather convoluted way to do it, but I don't know of a better way to achieve this as of now.
There is further discussion on this topic in the comments in this issue, which as of today is still open.

Loading native C library from Objective-C in Flutter plugin

I have a native C library (.so) build in versions for android and iOS. I want them to be used in a flutter app I am building.
For android I use System.loadLibrary() in Java to load the file (wrapped in JNI) and it is included via the Gradle build system/CMake.
But how do I get the same for iOS in objective C ?
Seems like I can use dlopen() on the library and then dlsym() every single function to get their symbol into the app at runtime. Seems pretty dump but I guess it could work (when I at some point have convinced the buildsystem to include the lib into the actual package it builds.

Can I use F# to build a (cross-platform) library for use in an otherwise native iOS application?

Subject line pretty much describes it. I'm looking for a toolchain to build a cross-platform business logic library that would be consumed by (among others) an otherwise native iOS application.
I'm thinking about using F# for this library, as I like its functional approach and what I've read about performance seems at least reasonable.
I'm wondering how feasible it is to write this library in F# and then invoke/consume it from an otherwise native (probably Swift) application on iOS.
You can use Fable to compile your library and then write your app in React Native to consume it as a native app in iOS. Here are some interesting things you can do with Fable. http://www.navision-blog.de/blog/2016/08/14/fable-sudoku-creating-a-sudoku-solver-app-with-f/
If you don't want React Native, then your other option is to call the generated JS code directly from your native code, but that's a bunch of boilerplate and casting for each function call. How to call JavaScript Function in objective C
The solution I think you're hoping for is to be able to compile to Xamarin and use the library from an iOS app like a native library, however that's not possible.

Porting C code for an iOS app

I am working on building an app that needs to use a C library that I have.The C code is designed for Linux platform and has Linux system calls.
Firstly, I would need to port this C code to run on iOS. Is it possible to do so? Are iOS apps allowed to use system calls? (I read elsewhere that apps using syscall.h are not permitted on the appstore)
Secondly, once I have ported the code can I include them directly in my swift code? Or would I have to create .so files or any such thing.

appcelerator module for existing ios project sdk

I want to use into my titanium project the functionalities provided by an existing sdk (deezer sdk).
I know I must deal with modules, so I found a lot of tutorials that explain well how to create a titanium module from scratch. But I didn't find something about to explain how to "wrap" an existing ios project within a titanium module. I just need the login/signup functionality and to retrieve the logged user (functionalities provided by the deezer ios sdk, of course).
can anybody help me on how to proceed?
thanks in advance
Dario
After creating the vanilla module, you have to include the framework you are wrapping (so deezer SDK) inside the bundle. Then follow these steps to add the framework to the compiler directives. Essentially you just add this:
OTHER_LDFLAGS=$(inherited) -framework DeezerSDK
To the module.xconfig file. Just check what the exact name is of the SDK.
After that, you can use the DeezerSDK just like you would in regular native Xcode development.
EDIT:
If the library is just a *.a file, then you can model what Titanium did for the Google Admob module. Its best to just inspect their project, bt essentially all that you need to do is create the vanilla titanium module, drop in the *.a file, and the headers, and then use it just like a native project.

Resources