Seamlessly glue multiple storyboards together without writing a single line of code.
Facts:
- 3 Storyboards
- 16 View controllers (tab bar controller, container view controllers, etc.)
- 0 lines of code
- Works with
UITabBarController
(replaces the tab). - Works with container view controllers and any other kinds of view controllers.
- No code required!
- iOS 8.1+
- Xcode 6.1
CocoaPods is a dependency manager for Cocoa projects.
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
$ gem install cocoapods
To integrate Glue into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
use_frameworks!
pod 'Glue', '~> 0.0.3'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Glue into your Xcode project using Carthage, specify it in your Cartfile
:
github "nubbel/Glue" ~> 0.0.3
If you prefer not to use either of the aforementioned dependency managers, you can integrate Glue into your project manually.
- Add Glue as a submodule by opening the Terminal,
cd
-ing into your top-level project directory, and entering the commandgit submodule add https://github.com/nubbel/Glue.git
- Open the
Glue
folder, and dragGlue.xcodeproj
into the file navigator of your app project. - In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
- Ensure that the deployment target of Glue.framework matches that of the application target.
- In the tab bar at the top of that window, open the "Build Phases" panel.
- Expand the "Target Dependencies" group, and add
Glue.framework
. - Expand the "Link Binary with Libraries" group, and add
Glue.framework
. - Click on the
+
button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and addGlue.framework
.
Copy the GlueViewController.swift
file to your project, it doesn't have any dependencies.
Suppose you have two storyboards A
and B
. In order to glue them together, follow these steps:
- In storyboard
A
place a view controller where you want a view controller fromB
to appear. - Select the view controller and go to the Identity Inspector. Set "Custom Class" to
GlueViewController
, the "Module" should then automatically be set toGlue
. - In the Attributes Inspector you'll then find a new section labelled with "Glue View Controller". Set "Storyboard Name" to
B
and you're done!
The options can be set on the GlueViewController
instance either in the Attributes Inspector under "Glue View Controller" (courtesy of IBDesignable
& @IBInspectable
) or in the Identity Inspector as "User Defined Runtime Attributes". Finally, you could also subclass GlueViewController
and override the properties there, but who wants to write code?
Storyboard Name (storyboardName
): The name of the storyboard you want to link this GlueViewController
instance to. If empty the current storyboard will be used.
View Controller Identifier (viewControllerIdentifier
): The "Storyboard ID" as defined in the Identity Inspector of the view controller you want to link this GlueViewController
instance to. If empty the initial view controller of the specified storyboard will be used.
You can find an example project in the Example directory. Here's a short demo video: http://youtu.be/lQzjHntOKZg
This project is licensed under the terms of the MIT license. See the LICENSE file.
- Create an issue to discuss about your idea
- Fork it (https://github.com/nubbel/Glue/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request