How can I setup a project to operate like the 'Window-Based Application' project template from XCode 4.0, in 4.2+? - objective-c

I'm using XCode 4.2, and I'm struggling with how to create a Single or MultiView application from an Empty Application project.
Previously, XCode had a Window-Based Application template, and it has been removed. After a bit of Googling, I found this highly indexed article that walks through the process of creating an Empty Application project, and manually setting up like the previous Window Based application template.
The problem that I am having is that the books that I own (that aren't to old) reference the Window-Based application, and even after following the instructions on the above linked tutorial, I can't get my projects to work. I'm missing something that bridges the gap between this web tutorial and the projects that are defined in the books.
Could some one either point me to a source or give a decent, high-level walkthrough on how to define a Single-View application, starting from an Empty Application project?

The "Empty project" already creates all window stuff for you. All you need to add is a UIViewController and link it in the app delegate.
To set the UIViewController you should use -[UIWindow setRootViewController:]. The UIViewController is the only part missing from the empty project that needs to be added for the application to work.

Related

Add a custom framework in a custom framework

I am developing an iOS Real Framework with XCode. This Framework (A) needs an external framework (B) to compile. For example:
A FRAMEWORK
+Frameworks
-B FRAMEWORK
It is imported in A by using:
#import<BFRAMEWORK/bframework.h>
I create the A.framework to be linked in a project.
The problem is when I link this A Framework in a project. The project returns "BFRAMEWORK/bframework.h" not found.
I want to include B framework in A.framework so not to need to add B framework also in my project. For example:
MY PROJECT
+Frameworks
-A.Framework (with B Framework included inside).
Do you know how to do this? or another way to do this?
Thank you!
I was able to create this structure with iOS-Universal-Framework: https://github.com/kstenerud/iOS-Universal-Framework.
I created a Static iOS Framework 'FrameworkB' with 1 method, which is imported in a second Static iOS Framework 'Framework A' with 1 method that's calling FrameworkB's method. I then created an iPad app which imports FrameworkA and calls the method. Code runs fine and prints from FrameworkA (which fetches from FrameworkB) and of course FrameworkB is not imported. Please note that all frameworks have to be built for the same profile (i used iPad), otherwise you'll get linker errors.
Maybe you add BFramework in compile sources?
Or add headers in header search paths?
or set dependency in build settings.
I think you are looking for OTHER_LDFLAGS = -ObjC

How do I create a file with the iOS\Cocoa Touch\Objective-C class template in Xcode

Forgive how simple this might sound but I'm stuck and need help. I am putting In App Purchases into may first app, which is not yet released. (So I'm very new)
I have been using a tutorial by Ray Wenderlich. I have just finished starting the Master Detail Application Template. Now it says I need to create a IAPHelper class which will be my class for the IAP the step I am on says to "create a file with the iOS\Cocoa Touch\Objective-C class template". However when I open Xcode and I select new project, I don't see this option. It has Single View Application etc.. the closest thing I see is Cocoa Touch Static Library.
Can someone tell me how I "create a file with the iOS\Cocoa Touch\Objective-C class template". I'm lost, do I do it from inside the Master Application Template? Or do I use some other template name like utility or empty application or Cocoa Touch Static Library? Or do I not have this in my version of Xcode? Or am I totally coming at this the wrong way? ahhhh!lol
I have Xcode 4.3.2
I know this is probably a no-brainer for some but not for me :(
Thanks for the help :)
In the current project you are working in, right click on a file and click "New File..." or go to File>New>File and then you will probably want a Objective-c class objection under Cocoa Touch
You need to do this in the same project which you have done till now. What you are trying to do is to create new project where as the tutorial is asking you to create new file. You have to do this in the same project which you are working on. In order to do that there is an option in file menu to add a new file to project.

iOS - Execute precompiled app from a server

I'm looking for executing a .xib (with its own controllers and libraries) precompiled on a server, downloading it on runtime.
Is it possible?
Thanks!
EDIT:
So could somebody give me an example of a program that uses NSBundle that executes other app?
And how do I create the bundled application?
I don't think you can import a xib into the application's bundle at run-time (which you would have to in order for this to happen). Others may know more and correct me!
I can think of a couple of ways you could try to do this, but are you aiming to get it in to the store?
This is expressly prohibited by Apple Developer Guidelines.
A .xib file is just a data file, so there shouldn't be any problem loading one that's outside your app's bundle. I can't say I've ever tried it, but as long as it's in a bundle, you should be able to:
Create an instance of NSBundle using the path to the bundle containing the .xib you want to load. See +[NSBundle bundleWithPath:] for that.
Load the .xib using the bundle you created in the previous step with any of the normal .xib-loading methods, such as -[UIViewController initWithNibNamed:bundle:] or +[UINib nibWithNibName:bundle:].
with it's own controllers and libraries
That part won't work. iOS doesn't allow dynamic linking to frameworks other than the ones provided by the system, so there's no way to load your code. If you can build all the code you need into your app, though, you should still be able to use downloaded .xib's as described above. That would let you do things like update the way your views are laid out or what targets and actions your controls are connected to.

Xcode 4 'QuartzCore/CIColor.h' file not found

I'm running Xcode 4 and trying to follow the steps in Apple's Image Kit Programming Guide (which is written for Xcode 3) on how to work with an Image View and the IKImageView class. I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, but when I try to Run my application I get this error:
Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
Does anyone know what could be a reason?
Peter Hosey replied:
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
I didn't import any specific headers directly, I just choose File>Add Files to... then choose /system/Frameworks and choose two folders which contain those frameworks, after that they appeared in my project navigator view as they should, but the code wouldn't compile any more. It shows me NSColor.h file which is found in the AppKit framework, points at this line: #import and says Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found. I have no clue why it wouldn't compile. CI stands for Core Image. I'm now reading a guide on Core Image, maybe this will help. I'd like to post a screenshot but I can't (not enough rights yet).
I just imported the Quartz and Quartz Core frameworks (from /System/Frameworks directory) to my blank Cocoa Application project using File > Add Files to... menu, …
That's not importing; that's just adding it to the project (and hopefully the target). Importing is what you do with the #import directive.
… but when I try to Run my application I get this error: Lexical or Preprocessor Issue 'QuartzCore/CIColor.h' file not found
You're not supposed to import specific headers directly, and especially not from sub-frameworks (such as Core Image, sub-framework of QuartzCore). Only import a framework's overall header, which usually has the same name as the framework.
The problem was that the Guide I used was written for Xcode 3 so when I tried to import/add some frameworks to my project using "File>Add files" menu as described, it did add those frameworks and I could see them in the project navigator, but something went wrong. In Xcode 4 you should use a different way to add/import Frameworks by using the Project Editor> Summary tab> Linked Frameworks and Libraries> Click "+" and then choose the Frameworks you need. That fixed the issue.

How to find out what the first view controller that gets loaded in an iPhone app is?

I think that looking at others' code is a good way to learn. I'm trying to learn iOS programming like this, but one thing that's confusing is when I look at a new project there's always a bunch of view controllers, and I don't know which one loads first.
Is there an entry in the plist file which says which view controller gets loaded first? How do you go about picking apart someone else's code in an Xcode project?
In the project there's a space called Main Interface / Main Storyboard that looks like this:
Target > General > Deployment Info > Main Interface:
But if they set it in code, then use ⇧+⌘+F on the project and search for 'rootViewController'.