0

I am new to Xcode. After a few days of "normal" use, where I didn't get any problems of any kind, Xcode stopped working properly.

The auto code completion now gives me only the methods ("M"). If, for example, I'm in "ViewController.swift" and write if ..., an error appears and does not show me the hint. It seems as if it doesn't "import" the right libraries.

img1 http://cl.ly/image/1u3J120y3A1J/Image%202015-01-22%20at%207.32.57%20PM.png

img2 http://cl.ly/image/0r1a1x210U17/Image%202015-01-22%20at%207.33.13%20PM.png

img3

Chris
  • 6,914
  • 5
  • 54
  • 80
giamar
  • 3
  • 4
  • I don't believe an if statement is valid there, which is why the autocomplete and compiler are blowing up. – Jon Shier Jan 22 '15 at 19:38

1 Answers1

1

Restart Xcode. Deleting the Derived Data Xcode folder should fix the issue. You can do this by heading to ~/Library/Developer/XCode/DerivedData and deleting all the subfolders in it.

By the way, in the first screenshot you can't use an if statement that way (outside any function). So this may not be a problem of Xcode.

I am seeing your second screenshot: you can't type init. It doesn't make sense.

In the third screenshot you are trying to import something, but you must import modules outside any class.

Cesare
  • 9,139
  • 16
  • 78
  • 130
  • The "If statement" was for example. Any text I write it just hints me "M" completions – giamar Jan 22 '15 at 18:42
  • Did you try restarting Xcode and deleting the DerivedData's subfolders? – Cesare Jan 22 '15 at 18:43
  • Yes, I also tried delete and reinstall Xcode 3 times – giamar Jan 22 '15 at 18:44
  • In the first screenshot you seem to be typing `init`, which doesn't make sense. Does the code work alone? I mean, when you create an app, do you get any kind of errors? – Cesare Jan 22 '15 at 18:46
  • No errors when i start a new project. Neither if i write inside `override func viewDidLoad() { super.viewDidLoad()` (inside that all works great) – giamar Jan 22 '15 at 18:48
  • That's good. In this image (http://i.stack.imgur.com/ofY5E.png) you are trying to import something but `import` statements should only be typed outside any class. – Cesare Jan 22 '15 at 18:49
  • This means Xcode isn't the problem. Try, for example, typing this code, inside the class, but outside the `func viewDidLoad()`: `func Hello() { println("Hello! Xcode is working fine")}`. Are you getting any errors? – Cesare Jan 22 '15 at 18:50
  • @CeceXX import is outside the class. and belong the init... you should use convenience initializers... May i think, that you aren't such deep in swift yet? I'm not really good in it too :-( :D – regetskcob Jan 22 '15 at 18:54
  • @DanielBocksteger what do you mean? – Cesare Jan 22 '15 at 18:59
  • @CeceXX Thanks for your support, now everyone has settled. Before even declare a "IBOutlet" gave error. I deleted "Derive Date" but kept giving me error, maybe because I had not restarted the mac. After reboot now everything works! I'm so happy ;) – giamar Jan 22 '15 at 19:02