A simplified framework creation tutorial

The aim of this post is provide a simplified framework creation tutorial. This post is targeted to those who want to create a static library (framework) in iOS and never did it before.

Getting started

Start off by creating a new Cocoa Touch Static Library project.

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

Next step is add some basic code to the library. This is the header file:

… And that the implementation:

 

A simplified framework creation tutorial

 

The framework (library) has not been generated yet, you will see the libSimplifiedFramework.a in red.

This is an important issue, before compiling select the target SimplifiedFramework and the device iOS Device. Otherwise it will appear the message that says that compilation is successful but the library binary will not be generated.

A simplified framework creation tutorial

 

For generating the library binary, go to Xcode menu Product>Archive

A simplified framework creation tutorial

Now you should have to see that library is in black, that means that library has been successfully created.

A simplified framework creation tutorial

Universal libraries

Reached to that point the library is generated, but for a concrete platform. The target now is generate a multi-platform library. For doing that you have to create a new target

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

 

Select universalSimplifiedFramework target and in its project options add a new build phase.

A simplified framework creation tutorial

 

Now is time to add the script that will generate the multiplatform library, this script is extracted from another article that explains with more detail how to create a library.

Replace in Step 1, SimplifiedFramework by your project name.

A simplified framework creation tutorial

 

For building just select Product>Archive from Xcode menu:

A simplified framework creation tutorial

 

And check in the logs if all was fine.

A simplified framework creation tutorial

Client app

So as to check if the proper if all the process was carried on well, we will create a new app that will use the library. For doing that we will add a new target:

Go to Xcode menu and select File > New > Target :

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

 

A simplified framework creation tutorial

 

 

Once the app has been created, it is time to setup the project options that the app is going to use the library:

 

A simplified framework creation tutorial

 

Select SimplifiedApp target and in General section, unfold Linked Frameworks and Libraries and select add:

A simplified framework creation tutorial

A simplified framework creation tutorial

 

The following code will call the function defined in the library. Place that code in the view controller class:

And run the app target for any device, in my case I have used iPhone6 device.

A simplified framework creation tutorial

As you can see in the last screen shot the client library app is calling a function from the library without major problems.

Conclusion

As I said at the beginning of the post, this is a simplified vision of how to create a library. From that point you can find very interesting articles about how to create frameworks in Xcode, like:

Ernesto GarcíaCreating a static Librfary in iOS Tutorial.

Sam DaviesHow to Create a Framework for iOS

 

Disable fullscreen mode on MPMoviePlayerController

The aim of this post is explain how to disable fullscreen mode  on MPMoviePlayerController. From the beginning you could think that there would be a flag to control that, but the reality is quite different. Since apple guys do not put hands on it, the rest we will have to deal with workarounds like this one.

The problem

My problem was that I wanted to embed a movie player in a scene, but movie player showed the fullscreen button mode. The aim of my scene was allow to play a movie in a part of the scene. Googling about this matter I found that this problem was known, but none of the solutions given worked fine to me, that’s why I want to report my personal solution.

The solution.

The solution consists in two independent actions. The first one is track all Movie player subviews, and once found the one that contains the fullscreen button view just hide it.

Add this chunk of code in the place where you initialise your player:

The call must be deferred because until the movie player is not presented, its sub collection of views is not built.

As movie player view is a tree of subviews, the unique I had to track this structure by using a recursive call:

A clarification, movieclip is an instance of MPMoviePlayerController. Since there is no identifier tag for the view I had to check its properties to know which view I had to hide. In my case was the view coordinates, it does not sound professional solution, but after days breaking stones I did not something better.

The second one is overwrite tap actions on movie player, because doble tap does a full screen. Also add the following chunk of code in the place where you initalise the movie player.

And its selector methods:

… for doing nothing.

If all was implemented as described, you should have to see that it has disappeared fullscreen icon and double tapping on video does not do anything at all.

Disable fullscreen mode on MPMoviePlayerController

Disable fullscreen mode on MPMoviePlayerController

This solution is also explained in Stackoverflow .