Customize storyboards bundled inside iOS Framework file - ios

I have a framework which has storyboard and xib files.
How do I make the storyboards within the framework customizable? i.e. people using my framework should be able to modify the storyboards to customize the look & feel.
When I imported my framework in another app project in XCode, I did not see the storyboard files within my framework. How to make them visible & editable?
Is it even advisable to use framework in this case or should I go with static library+resource bundles combination?

I finally did this,
Load custom xibs,storyboards dynamically. i.e. first try loading custom storyboards, if not present load default storyboard(use try catch to check).
Expose all viewcontroller outlets and event handling functions through header files.
Make connections between buttons in your custom framework and these header file outlets,event handlers. Done! Your Viewcontroller.m functions will be called on clicking on those buttons.

Related

IBDesignable controls in a framework

I've watched the excellent video on IBDesignable https://developer.apple.com/videos/play/wwdc2014-411/ and have created a framework with a control in, to be used by my main app (and shared, if necessary).
I've created a custom 'composite' control using IB, as per this great tutorial, http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6
The technique works well and I can now place my designable controls on my storyboard.
The problem is that I notice that all my IBOutlets and IBActions in my 'framework' appear in IB on my storyboard. But I wish to hide them! The functionality for the controls is hidden within the framework and the IBOutlets and IBActions have been created as such to facilitate their operation within that framework, with notification to the outside-world being handled via delegates or some other means.
This technique is compelling in that I can use it to create a reusable library of 'composite' controls but it would be useful to hide certain IBOutlets and IBActions from the library's implementors to ensure an element of 'security'
Can this be done?
Are there any flags to hide IBOutlet/IBAction elements within the framework?
When you speak of security, if you declare of #IBActions, #IBOutlets etc... as Internal, then they're private to your App's module.
In terms of frameworks, they consist of their own module (check in build settings, Module Name) and make sure "defines module" is enabled.
This ensures that your module is for starters "enabled" i.e. everything in your Framework (or app, or bundle which have their own modules defined) have their own environment.
From there, make sure that you've used the correct privacy when it comes to declarations:
Access control is explained is better detail here:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

Missing ViewController.xib in Xcode 5

I'm new to iOS programming and is currently following the tutorial at http://codewithchris.com/demo-app-with-xcode-and-interface-builder/
We first create a new project using the Single View Application library.
Question: About half way into the tutorial, it says Once you have ViewController.xib opened on the left pane and ViewController.m opened on the right pane... However there is no .xib file anywhere in the Project Navigator, and this is the first mention of an .xib file in the tutorial.
Am I supposed to get a .xib file somewhere along the way? If so, which step will create the .xib?
XIB is an older format of Interface Builder. In newer versions of Xcode, by default, the project is created with a storyboard (Main.storyboard in your project). The difference is that in storyboards, you can see all the views of your app at once (and transitions between them), and with XIBs you have to keep them separately.
I'm not sure about this (can't check it right now), but if you insist on using XIBs, there should be a checkbox somewhere during creating a project. Anyway, I recommend you getting familiar with the storyboards, they are supposed to be a successor to XIBs.
As I can see in the tutorial, the author says 'XIB' even if he has a storyboard in his project, probably because he got used to XIBs. All in all, they are very similar in usage.
Actually storyboards contain .xibs (in your project one .xib as you created single view app.) The xib is just the user interface file shown in your second screenshot.
You just have to click the "Show assintant editor" on top right (the button with the suit) to split the xcode window and see the xib alongside the viewcontroller header/or implementation files.

using iOS static library common view controller in storyboard?

We are in the process of creating a set of common components and common views that are reusable across several applications we have. In these libraries we have the .xib files and view controllers. We want to be able to use these in storyboards for the specific applications. Is this even possible?
I haven't seen an easy way to share reusable views or components from static libraries in storyboards yet.
Whats the recommended way to do this to keep from having code duplicated in every project?
Thanks..
Typically when making a static library for sharing, you can also include a bundle with resources (xib and image files for instance). Take a look at the FacebookSDK for instance. It contains a bundle with images and strings. Those can be loaded by the SDK code or the client app of the SDK.
For help on making a static lib with resources, see : https://github.com/jverkoey/iOS-Framework (thanks #jnjosh) or https://github.com/kstenerud/iOS-Universal-Framework. I've used the iOS-Universal-Framework on a shipping app recently. Works well.
In order to use xib files with storyboards, you can take one of two approaches:
Load the xib View Controllers in an action or segue called by the VC in the storyboard.
Or use the xib within the storyboard. See: Using XCode storyboard to instantiate view controller that uses XIB for its design
Also if it's just for internal use, I recommend simply making a shared repository of code + resources, rather than making a static library. The main benefit of the static library is ease of distribution outside of your team.

ios 5 - Code to Reflect on Storyboard

When you create an interface with Storyboard (OR normal IB) the code is generated at compile time for the app. In other words, it does not update the file of the ViewController it is linked to.
Is there a setting that allows for this?
For me I would see that as a great learning tool.
Like if I put a button on a certain place in a UIView, what would that look like in code?
Cheers Jeff
Unfortunately there is no such setting. XIB's and Storyboards are stored as XML files, and rendered into UI at runtime. On the other hand, when you create UI programmatically you write your code in Objective C using Cocoa Touch classes. There is no direct way to convert the XML into Objective C during development.

Go back from Storyboards to XIB

Not knowing that Storyboards are iOS5 only I created project that could be run even on iOS 2.0, but now I can't compile it with target lower than iOS5. Is there an easy way to go back to simple XIB file?
I don't think there's an automatic way to downgrade. Create new xib files for each view controller that needs them and link their view with the appropriate .h file. You should be able to copy and paste your whole UIView container view from storyboard to an xib though so it's really not that bad.
EDIT:
Also, I recently had to do this myself and a few things that weren't immediately obvious to me were that I also had to create a MainWindow.xib file, change your application plist, main.m, and my app delegate. Was definitely more complex than I expected but can confirm it can be done.

Resources