Reusable / Shared View not showing in Simulator - ios

I created a Framework so that I can reuse views across several projects. I used this link to create the Framework. I can reference it in a project and the shared views do show in the storyboard. However, when I run it in the simulator, the sharable views are white. Attached are screen shots of what I'm experiencing. I'm using swift 3.0 and xcode 8.2.1.

In the Identity Inspector of the View, change the module of your class to the name of your framework.
References to custom classes need to have both the class name and module set in the Identity Inspector when using Storyboards. At the time when the custom class is set, your that class was in the app’s module, but now it’s in the framework.

Related

What is the general structure when coding an iOS project if there is any?

So a few weeks ago I got into Swift and before that I learned a bit Web dev. When learning web development there was always a certain structure to follow for any project. Like specifying where to get the stylesheet from, where to get the JS and that information was put into the head of an html. It is not easy to put my question into words, but is there a general structure for iOS projects? So far I realized that there is always an "import" for example at the beginning of any file to add a framework and then a class. But there is always just one class and all the code goes into that class, why? What else stays always the same for iOS projects?
There are a couple of ways you can approach developing an iOS project. But generally this is what you need to know.
All your UI related designs can be implemented in Main.storyboard file in your project. Here you can create a View Controller and add various UI elements to them like button, labels etc.
To make sure your views look the same across all device screen sizes, you need to use autolayouts which is the process of setting constraints to the UI elements so that they can be resized according to the screen size of the device they are being displayed on.
For each View Controller created you have to assign a class file which is a .swift file. In this class file you have a function by default called viewDidLoad(). This method is executed when the view is displayed on the screen after running the code.
For each UI element in a View Controller you can add IBOutlets and IBAction to their respective class file.
Here are a few links that can help you more:
Tutorial for autolayouts: https://www.raywenderlich.com/443-auto-layout-tutorial-in-ios-11-getting-started
Tutorial for Swift programming: https://www.raywenderlich.com/6338-swift-tutorial-part-1-expressions-variables-and-constants
Get started with iOS: https://codewithchris.com/how-to-make-an-iphone-app/
Some other useful links:
https://medium.com/ios-os-x-development/7-things-you-must-absolutely-do-before-writing-an-ios-app-a8bacf710c57
https://www.raywenderlich.com/477-design-patterns-on-ios-using-swift-part-1-2

Customize storyboards bundled inside iOS Framework file

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.

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

Xamarin DesignTime Custom Controls Render in XCode, edit control properties in DesignTime

I am developing an application on Xamarin.iOS and MvvmCross platforms. I use xib files instead of storyboards for design interfaces (navigation in my app based on ViewModels). How can I use Xcode's Interface Builder to render my custom controls & edit properties in IB?
Adding attributes [DesignTimeVisible (true)] for class and [Export ("Counter"), Browsable (true)] for properties does not work for XCode Interface Builder.
As far as I know in Objective-C classes there must be set #IBDesignable & #IBInspectable, if you want design time support in Xcode for custom controls.
I believe this is not possible with XCode Interface Builder since it needs to build the custom control in order to present it. And the XCode project generated by Xamarin is not buildable it is used only to track changes and generate C# code.
However you can take a look at the Xamarin Studio’s iOS designer. I think it has the feature you need.
Not exactly what you asked for but Xamarin do support basically the same thing, only using their iOS designer (which I have found rather flaky...)
https://developer.xamarin.com/guides/ios/user_interface/designer/ios_designable_controls_walkthrough/
edit: I just noticed the guy above also gave the same solution, his link is to the designer docs, mine is to the custom properties walkthrough so i'll leave it up :)

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.

Resources