XCode wont let me use a Static Library View in my xib files - iphone

I created a new project of type Static Linked Library.
I have moved the code (previously working in the app) to the library leaving all the xib files in the app.
I have changed the export directory and added the library file from the derived data folder so it gets the compiled version and links to it.
I have added the library to the bundle and have verified it is in the app using iPhone Explorer
I have verified that the xib file recognized the new view type by removing and selecting the custom view type in the custom class field of the identity inspector.
I have changed all of the #import commands to reflect the <> VS "" change and have gotten the app to compile.
however none of the methods of my custom class can be executed. and an NSLog reports that the class is its base counterpart as opposed to the custom derived class.
I am at a loss and have spend a long time converting all the code I have to work in a library. I am hoping someone can help with this.

On this issue, it turns out that Objective C's compiler does not load the categories and custom classes in the libraries by default. There are 2 ways to overcome this.
And here are your options.
Create an Activation type method on the category that will be called to "Activate" that Class or Category. This will need to be done before the application loads any nib files. And seems like a bit of a pain in the butt. This was however how I originally overcame this issue.
Add linker flags that will tell objective C to load all libraries and attach any and all Categories and Classes within the libraries before executing the application. (this will need to be done, on top of #import(ing) the correct files from their correct locations. I will provide a graphic below. and provide the flags for search purposes
-ObjC is the first one I added, but -all_load really did the trick.
I hope that others can benefit from this experience.

Related

Issue setting data for Radar Chart in iOS charts

I am using the charting library here https://github.com/danielgindi/Charts/ however I am having a couple of issues.
First, I have no idea how to set the data for a radar chart type and second, I have an error when apply the RadarChart to uiview. The error is
Unknown class RadarChartView in Interface Builder file.
The app still runs and I can see an empty uiview.
I have looked at the demo app and through the documentation but I am still unsure how to actually set any data to the chart.
Thanks
If you looked at ChartsDemo app, why you still not unsure how to use it? The code is straightforward. Otherwise I am still copy pasting code from ChartsDemo, which is meaningless.
For the class, you need to choose Charts module for your IB: https://github.com/danielgindi/Charts/issues/59
downloaded library
reembedded it with the option "Embedded Content Contains Swift Code"
In Storyboard where I defined the class for the charts view as "LineChartView", I also have to set the module manually to "Charts".

Custom control within framework not configurable or visible in Xcode

I have created a small selection of custom controls that are tagged #IBDesignable to enable visual configuration within IB. They work perfectly in their parent project/workspace and, as I wanted them to be reusable, I've created a framework.
After importing the framework into another project, I can access the classes programmatically but there is no visual representation in IB and none of the #IBInspectable properties are displayed in the attributes inspector. There are no errors reported during build or run phases. I guess I'm missing something somewhere but does anyone have any pointers?
It would appear that this is not currently possible (using Carthage as a dependency manager at any rate) without considerable effort with workarounds. This kind of defeats the object IMO!
For now it seems that you need to import the framework project into the product project. Explanation here but, for now, this seems dead in the water.

Swift 1.2 drag and drop controls and views in Cocoa

I'm building one application where I need to make a simple window and be able to drag&drop files onto this window. In this app I have to then parse file path and write out all paths of dropped files in table or nice order (one under another). App doesn't need to take more than one file at once, but this might be a feature for future.
Up to now I have managed to make simple drag&drop in NSView (which I extended with custom class). App is correctly registering drag&drop events and I get all file path and I have also figured how to get file names out of those strings.
My question is: How can I move this "drag&drop" to NSTableView, as I wish to have file names in nicely in table?
I have tried to put tableview under NSView but it doesn't work and if I extend NSTableView class it just registers that there was drag&drop event but nothing else happens.
Do I have to extend other class or how to make this work? I'm implementing NSDraggingDestination protocol in custom class and using performDragOperation function.
I would like to have:
- whole app window can take drag&drop-ed files, not matter where I drop it it has to accept file and put file name into table
I'm sorry if this might sound trivial but I have just started learning swift and developing OS X apps and I'm not used to this new API and don't really know how all things works here.

Unknown class in Interface Builder file

Why am I still getting this error when I run my iPhone app? The file is a ViewController that I have been working to delete and replace, but it just won't die. As far as I know, I don't have any reference (string or otherwise) to this file in my project.
I have deleted the related file (I'm trying to get rid of it.)
I have cleaned the project and rebuilt.
I have "Reset Content and Settings" in my simulator.
I have done a grep (grep -i -r "TheClassName" *) and nothing matches except my UserInterfaceState.xcuserstate file.
I have searched the code using XCode's Find/Replace tab.
I have double checked my Build Phases and am pretty sure it isn't in there (its a large project).
Any other ideas? I've spent way too many hours trying to figure this simple thing out; I must be missing something.
Thanks!
Check your nibs or storyboard, and make sure none of your views are set to the class!
I finally fixed the problem after trying it on multiple machines over the course of almost 2 days! I will not be thwarted!
I tracked the problem down to a call to setViewControllers on a UINavigationController which is called on initialization of the application. I was always being passed 3 objects (there are 3 panes in the navigation controller). Even though I had deleted the third object, as previously explained, three objects would always be passed in. The class type of the first two was correct, but the third would just be a UIViewController. Curiously, this view controller had a nibName which corresponded to the object file and Xib file that I had previously deleted. Of course, when view was called on this borked UIViewController, it would crash since the corresponding nib had obviously been deleted. Remember, the textual name of this object or Xib could not be found in my directory with grep, so I have absolutely no idea how in the world it came into existence when I ran my app.
So, I figured the app may not have been cleaned properly. I double and triple checked this. I even validated that my Workspace settings were correct (File->Project Settings->Advanced). The app was indeed being recompiled fresh every time.
Secondly, I started thinking that perhaps the object was being set by some other means. Working backwards, I added some breakpoints and found out that initWithCoder was being called on the parent UINavigationController--this was eventually working down to call the setViewControllers on the object and assigning the three view controllers (one of which was the offending one). I could easily see from the call stack that the Nib file that was being loaded was deserializing something offensive.
So, I started digging into my Xib file. Of course, the object name wasn't in the file (as expected since the grep didn't find anything). I deleted and recreated the portion of the Xib that included my root UINavigationController. This ended up changing the Object ID and ref within the Xib file.
Secondly, I created a new Xib and UIViewController with the same names as the one which I had previously deleted, hoping that Xcode might be happy if I created and then re-deleted them. I then compiled, re-deleted them, updated by Xib file yet again, reverified with grep that yes, indeed, nothing existed with that name.
And it worked. After spending multiple days on this issues, I'm fairly sure that there is a bug here in the interface builder, but do I want to revisit this problem to file a bug report? Absolutely not...
In my case, I solved an issue by name of Custom class name of View instead of Custom class of ViewController. By mistake i added like this for view as shown below.
It Should be for ViewController like this.
This is in my case, for you may be it's related with another component.
This happens when the view class is in a framework. Select the framework's module. Example with a CocoaPod: HSegmentControl.
Make sure when you add or rename or move files around especially in folders, that when you add them you:
A. Create Groups, not references they don't usually read in.
B. Check the boxes for the apporpriate "Product(s) or Target(s)" you want to add the source to.
Another thing to try :
I had to toggle "Inherit from Target" under the "Module" control of "Custom Class."

XCode class models: how to view Framework classes?

I'm using XCode 3.1.4, I'd like to browse the iOS framework classes visually, eg. the UIKit.framework classes.
I believe this is possible with Class Model facility, the documents here http://developer.apple.com/tools/xcode/xcodefuture.html suggest so:
The Xcode class modeler works with Objective-C, C++, and Java source code files and can give you a look at just a few classes, every class in your project, or even all of the classes in a framework.
I made a Class Model and selected Add All to include everything including the framework's .framework files. However on the generated diagram where I see UITableViewCell, it has no arrows pointing up from it, even though I know this class inherits from UIView. I've played with clicking various ways, the menus and Info but can't see how to see the full inheritance tree of UITableViewCell.
Can anyone advise?
This is what I did to make it work:
Select the project:
Then choose Quick Model:
Then you get a ridiculously large model with all the classes in it.
If you wanted the classes from just one framework, you could select just that framework in the files list, instead of the whole project.
I see the same thing in the Xcode Class Modeler, so it may be an issue with the tool or a choice made by its authors.
The method you used should give you a correct model, however you may need to move classes around to be able to see the arrows as there are way too many lines present if you model everything at once. The quick model will give the same results using the selection (i.e. if you select your project itself you get everything, and if you select a group of classes you will just get them.