Bazel Xcode Interface Builder: How to do Outlet connect - ios

I am a newbie of Bazel user. I used do the Outlet connection via Xcode Interface Builder (Open as project). But recently I have to use Bazel to build an iOS app. So I just follow the Bazel iOS tutorial: https://bazel.build/tutorials/ios-app. I open the source files UrlGetViewController.h and UrlGetViewController.xib (open as file, not project). Added an extra outlet in the UrlGetViewController.h file as:
#property (weak, nonatomic) IBOutlet UITextField *testTF;
I just can't see that testTF outlet appear on the UrlGetViewController.xib.
Please advice me how to do the outlet connection in this case. Thankyou

Related

Can't link IBOutlet to XIB File XCode 6

I've been following a tutorial on how to create a custom info window for the Google Maps SDK and when I try to connect the UILabel declarations in the obj-c file to the labels in the XIB file, nothing happens. I can't even connect the labels in the XIB file to the interface declaration and create them that way. Here's a link to an image of my setup:
Is this a bug with the new version of XCode or am I doing something wrong?
Go to Identity inspector and make sure that you conect your .xib with proper class.
You should have there CustomInfoWindow

Static library, bundle and IB Designable

I'm trying to use the IB Designable and IB Inspectable in my UIButton but seems there are some errors.
In the Issue Navigator, the bundle file:
Storyboard :
IB Designables : Failed to update auto layout status: Failed to load designabled from path (null)
So I wonder if there are any configurations to do to use it in a static lib or something like that ?
This is
#import <UIKit/UIKit.h>
IB_DESIGNABLE
#interface CustomUIButton : UIButton
#property (nonatomic) IBInspectable int cornerRadius;
#end
My custom button I want to live render is inside a view controller
Unfortunately it isn't possible to use IBDesignables with static libraries (or static frameworks).
This isn't a great answer but I want to give some context on why.
It seems that the way Interface Builder loads classes to be shown as designables is by actually dynamically loading the dynamic framework that you create (and not your app's binary), and using the classes directly (after changing them using the Objective-C runtime quite a bit).
You can see that Interface Builder isn't loading your app, and just the individual frameworks with these steps:
Create a new Xcode project
Create a new framework target in the project
Add a class that is IBDesignable
In the storyboard from your app create a view and set its class to your framework's IBDesignable class
Click "Refresh All Views" in the "Editor" menu
In your DerivedData folder for the project, in the IBDesignables directory, you can see that only your framework target has been built.
Interface builder actually loads your framework using dlopen manually. You can also see that to facilitate this when building your framework, Interface Builder actually adds 2 RPATHs to your binary, so the dependencies can be found in the custom paths (you can view this with otool -L frameworkbinary). This method of loading your binary isn't possible with static libraries.
For what it's worth I think the best workaround for this is to build dynamic frameworks, instead of static libraries, but only for IBDesignable builds. You'll have to do some configuration work to do this, and it isn't easy to work around Xcode to have this work, but if you try it, you can use either the build path, or the environment, to differentiate IBDesignable builds vs "normal" builds.
EDIT: IB Designable and IB Inspectable do not seem to work with static libraries, so if you're using a static library, either consider using a dynamic framework (iOS 8 only) or move your component outside the static library, if possible.
For issues related with Cocoapods, use the following solution:
This is related to this question.
Here's the solution:
1) Install Cocoapods (0.36.0.beta.1) or newer;
2) Add use_frameworks! to your Podfile
See more here.

IBOutlets not showing on XCode 6.1 (6A1052d)

This is quite a major problem: the Outlets are not appearing in IB.
To reproduce:
1) I declare a variable to be IBOutlet, for example in my view controller's .h file
#property (nonatomic, strong) IBOutlet UILabel* testlabel;
2) I open the storyboard, click on the viewcontroller.
- If this is a new project, there is no "Outlets" list.
- If this is an old project with outlets already defined, the "Outlets" list contains the previous outlets, but not the one I've added.
Has anyone had the same problem. This is really important, as I can't basically proceed unless I stop using Outlets. I can't find any info about it on the release notes.
EDIT I'm adding a video on youtube showing the problem, in case I haven't explained it properly. If I'm forgetting something obvious, I'm happy to be laughed at :) That said, I've always been following these same actions and Outlets have always been in the list.
EDIT 2 For clarity, I've removed the ivar declaration as it seemed to get most of the attention.
Outlets on Youtube
EDIT 3 Ok I seem to be hitting a problem seen previously on this question and this other question. Basically, if I open the custom class drop-down, I see only some "standard" classes, such as UIViewController. If I select any of these, I get the Outlets. For example, for UIViewController I always have that view->View. However, my project's classes are not in the drop-down. Entering the name manually seems to work, but in fact it's not. There must be some indexing issue (except I've already deleted everything from
~/Library/Developer/Xcode/DerivedData/
without success. If you wish to try, I've put my code on GitHub. This doesn't show the Outlets for me, but it does for a number of other people - so it's not a "bug" with the code strictly speaking. It's more an XCode issue. Any help would be welcome!
EDIT 4 I think here's the problem, pretty much: look on the right. The drop-down menu doesn't show the "ViewController.h" class. If I enter it manually, it seems to recognise it but in fact I suspect it doesn't. In previous times, I was always seeing the full list of my project's classes in the drop-down menu.
I've found a "solution", or workaround. Deleting the XCode data is not enough, and it's not enough to just restart it. The following sequence makes the Outlets magically re-appear and work properly:
Clean project
Close XCode
Delete all contents of ~/Library/Developer/Xcode/DerivedData/
Restart MacOs
By doing this, when you re-open XCode and it reindexes, it will show the outlets as expected.
just declare the IBOutlet like this:
#property (nonatomic, strong) IBOutlet UILabel* testlabel
Maybe a very dumb one, but have you tried Clean Project Folder, then deleting DerivedData (while Storyboard is not open), immediately quit Xcode, and opening up Xcode again, then building your project?
I ran into a similar problem, but it was due to a bug in Xcode (8.2) where Interface Builder doesn't show outlets in the Connection Inspector if those outlets have been declared with a _Nullable type annotation for Swift compatibility.
Using nullable inside #property's parentheses appears to work around the problem.
(I know the original poster's problem did not use type annotations or Xcode 8 so was slightly different, but the question summary matched my internet search so I mention this for future searchers.)

Is NSArrayController deprecated, what is its replacement?

I found an Xcode project that uses something called an NSArrayController like this
#import <Cocoa/Cocoa.h>
#interface MyDocument : NSPersistentDocument {
IBOutlet NSArrayController *itemsArrayController;
NSArray *_sortDescriptors;
IBOutlet NSTableView *itemsTableView;
}
I was trying to use the project, which implements drag and drop, as a guide for an app I'm currently building. There's nothing in Xcode documentation when I option click on NSArrayController and I tried to create an NSArrayController property but received a warning that it doesn't exist. Was it deprecated? What has its functionality been replaced by?
NSArrayController is part of the AppKit.framework which is only available on the MacOS platform.

'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MKMapView'

I am doing a project using storyboard(first time using story board).In one of the viewcontroller there is a view with a mapview and a tableview containing prototype cells.I have included the mapkit framework and mapkit headers are imported in the corresponding viewcontroller.But i am getting this wierd error.I checked with many posts and all are pointing to the case where framework is not included.But i have included everything and still getting this issue.i cleaned and built but still this issue.any suggestions
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MKMapView'
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface CategoryDetailViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,MKMapViewDelegate>
#property (weak, nonatomic) IBOutlet MKMapView *mapview;
#property (weak, nonatomic) IBOutlet UITableView *tableView;
#end
Make sure that the MapKit.framework is added to your project.
To verify/add the MapKit framework to your project:
Click on your project file in the left pane, then click on Build Phases.
Open up the Link Binary with Libraries
If you do not see the MapKit.framework, you'll want to add it by clicking on the plus sign.
In Swift using a newer version of Xcode, you only need to turn this capability on in the project settings and the error will go away.
It may sound simple but in the project folder of this app the mapkit files were copied,i removed it from this folder through finder and added the mapkit again.now its working.thanks for the comment by #Craig
I saw this problem when building a WatchKit extension for iOS. In addition to the linked binary I also had to add a file to Compiled Sources.

Resources