How to Create a Development Framework in iOS Including Swift

How to build a framework or library for other developers, the secure way?

Yes, it is possible to build frameworks so the user of the framework can't see the source code.

Check out these articles (I've successfully used the first one to create frameworks in the past -- the later articles are updates to the original):

http://www.drobnik.com/touch/2010/04/making-your-own-iphone-frameworks/

http://www.drobnik.com/touch/2010/05/making-your-own-iphone-frameworks-in-xcode/

http://www.drobnik.com/touch/2010/10/embedding-binary-resources/

To use the framework, your users would just drag the .framework bundle into Xcode. They will be able to see the header files you copy into the bundle (see the articles above), but not the source (as it's not included -- only the compiled output is in the bundle).

This can also be a great way to distribute code that is used for multiple projects within your company.



Update:

Check out the link featherless added below -- it is much more recent and all on one page: http://github.com/jverkoey/iOS-Framework. It also lays out the issues with several other approaches. This is the guide I now follow when trying to remember what to do when setting up a new framework. :)

Update2 (with Xcode 6 release)

There is a option, exactly that you a re looking for:
Universal Framework for iOS!

Will be my code visible to others? A: No. This Framework will export a compiled binary, so anyone can see inside it. You can make the same for some other files, like XIBs.

Why I need this? A: This is for developers/teams that want to share their codes without shows the entire code (.m/.c/.cpp files). Besides this is for who want to organize compiled code + resources (images, videos, sounds, XIBs, plist, etc) into one single place. And this is also for that teams that want to work together above the same base (framework).

(c) http://blog.db-in.com/universal-framework-for-ios/

Create a framework from existing iOS project

When you want to make a framework, or module, from a project, the first thing you’ll need to do is, if you don’t have one already, make an Xcode project workspace (File > Save as Workspace) . The next step is to add a new framework “project” to your workspace (that could’ve been why you saw some resources telling you to make a new project) with File > New Project and choosing Cocoa Touch framework. When you add it, make sure you pick your workspace under both Add to and Group. Then you will need to migrate in the files that you wanted to be in this module — make sure to choose copy items if needed.
Here’s an article with more specific details on the process if you need it:
https://medium.com/kinandcartacreated/modular-ios-splitting-a-workspace-into-modules-331293f1090

sdk inside iOS framework swift

You don't need to use CocoaPods.

You need to embed KontaktSdk.framework in your application's build phase. Since your library's output is not an .app bundle, it does not have a /Frameworks directory inside it. That's why it does not have a "Embed Framework" build phase.

You should link KontaktSdk.framework framework against your _library, but embed KontaktSdk.framework into your application target.

How to create a single shared framework between iOS and OS X

If you wish to create a single dynamic framework binary, here are the steps you can follow (as outlined in http://colemancda.github.io/2015/02/11/universal-ios-osx-framework):

1. Change the project's valid architectures and supported platforms.

This should change your framework's and test unit's valid architectures and supported platforms as well. If not, then manually change them to inherit from the project's build settings.

Step One

  • Base SDK: I recommend OS X, but it will work with iOS too. Note that with with iOS as the base SDK, "My Mac" target is separated into 3 different targets.

  • Supported Platforms: macosx iphoneos iphonesimulator

  • Valid Architectures: arm64 armv7 armv7s i386 x86_64

2. Change the search paths for the Unit Test bundle

Step Two

  • Runpath Search Paths: $(inherited) @executable_path/Frameworks @loader_path/Frameworks @executable_path/../Frameworks @loader_path/../Frameworks

  • Framework Search Paths: $(SDKROOT) $(inherited)

Its a better solution than having two separate targets.



Related Topics



Leave a reply



Submit