Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift use #1

Closed
AgapovOne opened this issue Jul 20, 2015 · 8 comments
Closed

Swift use #1

AgapovOne opened this issue Jul 20, 2015 · 8 comments
Labels

Comments

@AgapovOne
Copy link

Hello. How can i use this with swift?

Is it generated by:

let o = Obfuscator.newWithSaltUnsafe()
o.hexByObfuscatingString("superNEEDEDstring")

? or how?

@pjebs
Copy link
Owner

pjebs commented Jul 20, 2015

It's unfortunate that most of the important methods aren't bridged over to Swift. I heard in XCode 7 they may get bridged over.

You can use newWithSaltUnsafe(<_SALT_>) if you want but you should not UNLESS YOU KNOW WHAT YOU ARE DOING.

This is because the salt needs to be dynamically created without reference to any hard-coded strings.

My recommendation is listed here for Swift: https://github.com/pjebs/Obfuscator-iOS#step-1---generate-objective-c-code
eg.
[Obfuscator storeKey:@"swift" forSalt:[AppDelegate class],[NSObject class],[NSString class], nil]

and then

Obfuscator.reveal(CC, usingStoredSalt: "swift")

@pjebs
Copy link
Owner

pjebs commented Jul 20, 2015

If your AppDelegate is in Swift, you can actually create an Objective C class that implements:

+ (void)load
{
   <PUT OBJECTIVE-C code in here>
}

That way it won't interfere with the rest of your swift code.

@pjebs pjebs added the question label Jul 22, 2015
@ryancstack
Copy link

Hey, the storeKey: forSalt: doesn't bridge to swift. Is the only way around this to create the Obj-C class in the AppDelegate or create another Obj-C class?

@pjebs
Copy link
Owner

pjebs commented Dec 1, 2015

That is correct:

  1. Either create AppDelegate in Obj-C OR
  2. Just create a small Objective C class that does nothing more than implement the + (void) load method. This is the recommended way as it is less intrusive.
    In the load method, you can put objective C code that will get run when your app starts up. It is guaranteed to run only once also.

@ryancstack
Copy link

Thanks for the quick response! ended up going with 2

@Nathan187
Copy link

thanks for the suggestion (#2)...helped me as well

@RajChanchal
Copy link

I am working on a Swift project and I included this lib in my podfile.
When I import the module, it says: Could not build Objective-C module 'Obfuscator'. What should I do?

@pjebs
Copy link
Owner

pjebs commented Jan 8, 2017

Add to bridging header

@pjebs pjebs mentioned this issue Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants