Xcode6 Beta6 - Unknown class SCNView in Interface Builder file - swift

I created a new Swift project and made a couple of changes according to this tutorial as follows:
Modified the GameViewController.swift as shown in the tutorial.
Created GameScene.swift as shown in the tutorial.
NOTE: I am not listing the source code here verbatim as I believe it has no part in this error, but I'll gladly do so if anyone thinks otherwise.
Then I should be able to just compile and run the project to load a background image. Instead, I get the following error message during compilation.
I noticed there are some variations of this kind of error on SO, and I tried the following suggestions with no success:
iOS Simulator (Menu) -> Reset Content and Settings -> Reset
Window -> Organizer -> (Select my project) Delete Derived Data
Xcode -> Preferences -> Locations -> Selected Xcode 6.0 (6A280e) for Command Line Tools
What else can I do to get past the error? More importantly, perhaps, what's causing this error in the first place?

Looks like you chose SceneKit when creating your project from the template, instead of SpriteKit as the tutorial specifies.

Related

Xcode autocomplete/suggestion box not showing relative to current line

I am started using XCode and for some reason my autocomplete/suggestion box not showing below the current line of code as expected.
I can change the location and size with my mouse and maybe after changing it by mistake it's stuck but I didn't found any "change to default" settings or other people reporting about this issue.
Image from my editor you can see there the box is always shown in this location
Someone helped me the solution was:
try restarting Xcode
completely
and also if it doesn't fix it try to delete your archives and user data
Xcode -> preferences -> Locations - > delete derived data and archives
My Fix Was:
Exit Xcode totally then delete derived data and archives

Xcode breakpoints not showing current objects

I've recently run into a really frustrating problem. When I set a breakpoint, and my program stops, the objects aren't shown in Xcode. I don't get the typical 'self' or any of my other objects. I tried restarting Xcode and my computer. I don't really know what else to do.
I'm running Xcode 4.6.1. Has anyone else run into this problem?
I usually get this error when I have compiler optimization turned on. The compiler will generate code which does not necessarily follow your code logic flow.
Go to your project in the navigator -> Target -> Build settings -> Search for optimization level -> expand optimization level -> select the debug line -> change to none in both columns of your project and target.
Hope this helps.

I get: Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MKMapView'

Of course I googled and used the search within stackoverflow.
I found some similar discussions:
Could not instantiate class named MKMapView
http://forums.bignerdranch.com/viewtopic.php?f=49&t=490
NSInvalidUnarchiveOperationException: cannot decode object of class (UITableViewCellContentView)
... and lots of copies of that :)
However, I am not using SDK 3.2 but 5.0 (one of the linked discussions suggest it was an error in some beta version of SDK 3.2).
The other discussions and answers suggest that the framework MapKit were not included properly.
I tried to include it several ways, following those instructions.
I am still getting this error. It is thown on
[super loadView];
within my own view controller's
- (void)loadView {
method. The view itself is build within IB. Beside other items is has an MKMapView.
I am using MKMapView in two of my xcode projects. Both were started in xcode 3.2 and now migrated to xcode 4.
Within one of the projects the code works fine and in the other one I get this runtime error.
I did not identify any significant difference between these projects' setups that could explain this diffrent behaviour to me.
A current workaround is to take off any code (and IB item) that is relatd to a Map View. But in the end I'd rather include that map view because it does serve a purpose :)
Any suggestion is appreciated.
Hermann
Go to your target settings - not project level but target level. Click on Build Phases, then expand Link Binary with Libraries. Ensure that MapKit.framework is listed and add it if not.
Using Xcode 7.2 adding Framework can be done in 3 ways.
1. Under Targets Select Project -> Click on General Tab -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.
2. Under Targets Select Project -> Click on Capabilities -> Under Maps -> Click On Switch Button.
3. Under Targets Select Project -> Click on Build Phases -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.

Xcode 4 no code completion

I have been using Xcode 4 for 2 weeks and I noticed that I don't get code completion macros for if-else and switch statements.
Like this article describes: http://macdevelopertips.com/xcode/xcode-code-completion-macros.html
I had it working in the beginning, but it suddenly stopped.
Have you tried deleting the project's derived data (which contains the project index used by Code Sense)?
To do so, open the organizer (Window -> Organizer), then the Projects tab. Select your project then hit the delete button next to the derived data path (to the right). Confirm and let it re-index your project.

Rename a class in Xcode: Refactor... is grayed out (disabled). Why?

Why is Refactor... grayed out (disabled) in Xcode?
I'd like to rename a class.
Select the class's symbol in its header file - i.e. the bit just after #interface. Then the refactoring stuff should be enabled.
If you are using Objective-C++ (i.e. mix Objective-C with C++ code) then refactoring is disabled in xcode since it does not support refactoring of C++ code.
Refactor might also be disabled if affected files (most likely the file with your class in it) are not saved.
I've been using Xcode for 5 years now, and refactoring has never worked correctly (even xcode 4.6 has major bugs where it WILL corrupt your source code!).
The workaround has always been (still works 100%, even in cases where Apple's code fails)
use shift-command-f to find all uses of the file
select "replace" in the search settings
"replace-all"
do the following for the .h file, and REPEAT IT FOR THE .m FILE (if you have one):
right click the original file, and select "show in finder"
delete the file from xcode (select "delete references only" when asked)
rename the .h (and .m if you have one) in Finder
in Xcode, select "Product -> (hold down Alt) -> Clean Build Folder"
quit xcode (you can usually get away with not doing this - but NOTE: there are some other MAJOR bugs in Xcode where it crashes itself if you don't do this)
re-open xcode
drag/drop the .h and .m back into Xcode
wait a few seconds (some of Xcode's core methods are asynchronous - allowing it to corrupt your project)
finally, when it seems to be doing nothing (and your hard disk isn't making any noise any more): cmd-b to re-build
I have a 100% success rate with this method. I just tried refactoring with Apple's "Refactor -> Rename" in latest xcode and it failed - again!
(this time with the incorrect error: "Unable to determine the language of", one of those error messages where Apple put the wrong text in place)
I'm going to my project at finder, then change files name by get info.
After that, at xcode -> Project Navigator I delete the files.
At end, I click right on the class and Add files to ..., and add these files again.
It worked for me.
For me I realized Refactor was disabled because the Xcode project I had opened was referencing a Base SDK that was missing. Edit Project Settings and in the Build tab set the Base SDK to one that you have (like for me this was iOS 4.2). This enabled Refactor for me.
Also, it could happen that you renamed the filename for the class, either outside xcode or by ctrl-clicking the filename and then renaming it.
xcode refuses to refactor if filename does not match with the class name.
Go to your class' header file and find the line that looks similar to this:
#interface YourClassName
Right click on the class symbol (e.g. YourClassName) and you should be able to select Refactor -> Rename...
I just tried this and it works in Xcode 5.
This may be a bit late, but I stumbled across this post because I was unable to refactor my "ViewController.swift" file to "WhateverViewController.swift". I tried selecting the file in the Project Navigator and then selecting "Editor -> Refactor" from the top menu, but 'rename' is always greyed out.
Instead, what worked was selecting the ViewController name from the editor. So if you have:
class ViewController: UIViewController {
// Code here...
}
Highlight the "ViewController" word and then select Refactor from the menu or right-click and select Refactor -> rename.
Hopefully that helps...
Had this problem as well. I ran through trying to find missing SDKs, saving files, and looking for Objective-C++ code as mentioned above, and all it took to fix my machine was rebooting XCode.
Seems a little buggy still.
BTW, this was for XCode 4.0.1
Refactoring works If you first change the file name in the project navigator.