Reputation: 4127
I was looking today at the advantages of moving lots of code into a dynamic framework (this is possible since iOS 8) to streamline the process of making an app extension.
Once the framework is built it is then bundled in the Frameworks
directory in the app bundle as MyFramework.framework
.
However, I had a thought (while wearing a tin foil hat). How can you prevent someone from copying that framework, class dumping it (assuming Objective-C) and then using the classes and methods it includes by bundling it into their own app?
Would it be even possible to do so?
Upvotes: 1
Views: 131
Reputation: 32783
You can't prevent someone taking your framework, class dumping it, or simply taking the public headers and using them. You can make life harder for someone who does that by, for example, adding crashes from your framework if the framework detects that was loaded by an unknown application.
Basically you check the bundle id and if it's not whitelisted by the then the framework throws an exception, or, to obfuscate things, it generates a crash with a long call stack.
The code that does this can be added either to a +load method of one or more classes, or in the instance methods you think it would make sense to add a behavior like this.
The downside is that you'll need to make sure that every application that you develop is whitelisted by the framework, otherwise you'll prevent yourself from using your framework :)
Upvotes: 1