Search code examples
xcodeios8frameworksresourcesios9

Hide resources in iOS framework


I am developing Universal iOS framework using this guide. How to hide images inside framework from other developers?

Also, I am not sure, do we need Info.plist file inside framework?

enter image description here


Solution

  • I solve my problem by encrypt the resources. I am not sure, that is the best way to resolve, but it works in my case. Here is a simple OS X app that encrypt files before adding it to the framework.

    Code for decrypt:

    NSError* error;
    NSData* encryptedData = [NSData dataWithContentsOfFile:filePath];
    NSData* decryptedData = [RNDecryptor decryptData:encryptedData
                                      withPassword:@"SAMPLE-KEY"
                                             error:&error];
    UIImage* image = [UIImage imageWithData:decryptedData]; 
    

    `

    Code for encrypt:

    NSData* data = [NSData dataWithContentsOfFile:filePath];
    
    NSError* error;
    NSData* encryptedData = [RNEncryptor encryptData:data
                                      withSettings:kRNCryptorAES256Settings
                                          password:@"SAMPLE-KEY"
                                             error:&error];
    [encryptedData writeToFile:encryptedFilePath atomically:YES];