Why is XCode giving me UITableViewController templates without the normal methods? - ios

I've started trying some build-a-blog-reader tutorials and noticed that when I add a new UITableViewController file to control a new tableview, it doesn't give me all the methods.
All the tutorials walk me through adding a new file, selecting Cocoa Touch Class, then giving it a name and selecting UITableViewController from the presets. Yet my default file doesn't even have the viewDidLoad function by default, let alone all the methods that seem to flow in via these tutorial videos.
It seems I've done a few of these in the past and I actually had access to those, so did I turn something off inadvertently? How do I get it back? Or is this part of some new XCode update?

When you are adding a new Cocoa Touch class, make sure you're under the iOS section of the options, and not the OS X ones.
For some reason, even when you're working on an iOS project and you try to add a new file, the options will take you to the OS X files and not the iOS ones. So just go to "Source" under "iOS" and when you create your Cocoa Touch class from there it will correctly import UIKit instead of Cocoa and it will also include the necessary UITableViewController methods.

Select Cocoa Touch Class instead of Swift File when you create a new file.

Related

Cant use framework view in storyboard

I have created a framework from swift code, and it contains a few UIView subclasses. I can initialize it by code, but when I add it in storyboard, then when running I get an error:
Unknown class FindloFinalAugmentedRealityView in Interface Builder file.
Why is that? I was able to use this class in UI when it was not closed in framework
OK one change, I have found, that I need to specify a module for this to work. The only problem is that Xcode is not showing this module in list, I need to write it by my onw. Is this the only way this can work, or can I do something to make it show on the list?

Add custom framework to Standard Library in Xcode

I've looked everywhere and no article gives me exactly the solution I'm looking for.
Is there a way to "install" a custom framework into Xcode?
For example, let's say I've created a framework called 'MyAwesomeFramework' which is really reusable (for example contains a lot of useful UIView extensions). Now what I want to do is be able to just create any new project and type import MyAwesomeFramework to use it, instead of having to add the respective Xcode Project to the project I want to use it in.
Apple Documentation
There are a few different options. You can manually add them via drag and drop or use one of many framework managers such as Carthage or Cocoapods.
Whatever method you choose has a few steps and can be a bit daunting initially so I’d recommend following a tutorial of some sort(I used YouTube). If done correctly you will be able to just import like you would do any other library.

Cocoa Touch Framework not recognised

I have a Utility Cocoa Framework, a class with a bunch of utility methods. I use this framework in several other app, without any problem. I just created a new app, and app is not able to recognise methods. Any idea why? I have not upgraded Xcode.
Embedded library set:
Utility method is public:
I have go though on this tutorial: https://www.youtube.com/watch?v=86cPaa3FrRg
ahh, .. I forget to select to run on Device, simulator not an option for me

How to create and use an iOS Framework for sharing code with Extensions

How does the minimal setup and usage of a custom iOS framework look like? I starting to look into this in order to share code with a Today Extension.
Here's what I did so far
Added a new Target choosing the Cocoa Touch Framework template and called it TesterKit
Inside the framework I created a new class TestClass.swift
Inside TestClass.swift I created a simple class method class fund tester() printing a string for testing
Looking at my app I can see that TesterKit has been added as Embedded Binaries and Linked Frameworks and Libraries, however it is red
In order to use this new Framework in the app, I added import TesterKit to the top of my AppDelegate
Then I tried to call the class method from the Framework using TestClass.tester(). But instead of showing the log message I get a …
"Use of unresolved identifier"
→ What am I doing wrong? Any wrong assumptions here?
Note: I already watched the WWDC sessions 416 "Building Modern Frameworks" and found the Framework Programmign Guide. If there are any example projects showing how to use such new custom iOS Frameworks, ideally using Swift + integrating this with Today Extensions, that might be helpful, too.
It seems like your import is not failing which means the framework is actually set up correctly...try making the function public.
public func tester() { print("tester()" }

iOS How to use private API?

I don't want to submit this app to AppStore. I've tried for many times but met so many problems :(
I use class-dump to get all the header files of UIKit.framework. In the UIApplication.h generated by class-dump, I saw the method I want to use----launchApplicationWithIdentifier.
Then I put UIApplication.h in my project and import it. Compile, I got a lot of "Redefinition of enumerator...." error because in the UIKit.framework I use previous, there's another UIApplication.h. But this file doesn't have the method launchApplicationWithIdentifier.
If I delete the previous UIKit.framework and import the folder generated by class-dump. Then it appears like a framework but if I unfold it, it's empty.
Then I want to make all generated header files a framework file ant replace the previous UIKit.framework. But I don't know how. As we can see, under the system framework directory, there's a file which has the same name as the framework and has a 'executed shell script' icon. How can I made this file?
I really got confused. Someone can give me a hand? Thank you.
Just specify the private methods in a category interface above the class implementation where you want to use it, like this:
#interface UIApplication (Private)
- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;
#end
Don't import the whole class-dump file and link with the original UIKit framework.
You must be very careful when using private API. These methods can change or be removed in future iOS versions!
Check if the method really exists with respondsToSelector: at runtime and be prepared for the case that it does not exist.
I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).

Resources