Xcode switching between Swift 2.2 and Swift 3.0 - xcode

Ever since I downloaded the new Xcode and converted/updated my syntax, Xcode has been randomly switching between the above mentioned versions of Swift. I ran 'swift -version' in my Terminal and it confirmed (for the moment) that I am running Swift 2.2
I saw this question (Swift compiler is confusing version 2 and 3) but I'm too new to add a comment and ask more questions (like why can't I find that in the targets section of my project?).
How can I set my syntax so that it stays on Swift 3 and doesn't change without warning? This will be about the fourth time I've updated everything for the sake of testing/running my app.
Hopefully this is an issue for other people and this question helps them too - I feel awful asking when I'm new. I hope to be able to know enough to help other users soon.

You can set Swift in the Terminal to be the same version as Xcode 8's with xcode-select. Point it at Xcode beta like this:
sudo xcode-select --switch /Applications/Xcode-beta.app
You can also set the toolchain right in Xcode 8, in menu Xcode > Toolchains > Manage Toolchains:

Related

Xcode 6.3 autocompletion slow with bridging header (e.g Parse)

tl:dr
Xcode Update 6.3.1 solved the problem for me.
It's still lightly slower than before but I'll give that shame to my Evo 840.
the problem
Since I've installed the latest Xcode version (6.3) my projects with bridging headers seem to have problems with autocompletion. It's incredibly slow!
Is there any known workaround (except removing bridging headers...)?
EDIT:
Bug reports
20549109
20549764
20549768
EDIT (04/17/2015):
bugreport.apple.com marked this as a duplicate of
20445407
I had similar issues and after updating to xcode 6.3.1 and swift 1.2 they dissapeared.
Not appearing with xcode 7 & swift 2.0
Steps are as:
1. Just go in user->Library->Developer->Xcode->DeriveData and delete the Data of folder(Derive data).
2. Just restart your system.
3. It will work better.

Is it possible to build iphoneos6.1 projects in Xcode 5, preserving the behaviour of views laid out in an Xcode 4.6.3 storyboard?

Our build server was recently updated to use Xcode 5's xcodebuild. We've installed the iphoneos6.1 so that we can still use iPhone SDK 6.1 for some legacy projects that do not yet support iOS7. However, when we use xcodebuild to build these projects using -sdk iphoneos6.1, we still see problems with UIViewController's contents being laid out underneath navigation bars and tab bars.
Is there some way to build these projects that were developed with Xcode 4.6.3/base sdk iOS 6.1 using Xcode 5's xcodebuild, but preserving the views as they were laid out in the storyboard developed using Xcode 4.6.3? I took a look at the man page for ibtool, but I'm not seeing any option related to choosing a target SDK, or anything else that seems relevant to the "extends edges" problem I noted above.
Note that we haven't updated the storyboard using Xcode 5 - the project is continuing to be developed in Xcode 4.6.3, and only touches the Xcode 5 toolchain when our build server clones the project's git repo and builds using xcodebuild.
Yes. On the Storyboard, go to the Interface Build Document section and there are two selection items. One for Builds For and one for View As. You can select anything from 7.0 down to 4.3 for the Builds For and you can select '7.0 and later' or '6.1 and earlier'.
While it isn't exactly what you are looking for, you can keep both Xcode 4 and Xcode 5 in the same build environment and control which xcodebuild is run by using an environment variable (see man page for xcrun. We have just set this up on one of our build servers. In your build definition, just set the following environment variable:
DEVELOPER_DIR=<path to Xcode 4.app>/Contents/Developer
For us, it ended up as:
DEVELOPER_DIR=/Applications/Xcode-4.app/Contents/Developer
This overrides the xcode-select setting and allows you to use the correct Xcode environment. Again, this depends on the ability of your build system to set environment variables, plus having both versions of Xcode installed. You can download older versions of code at Downloads for Apple Developers

How do I open project version 1.0 with xcode 4.2?

I downloaded this Xcode project(version 1.0 as in contents.xcworkspacedata) from here
When I try to open it, got this error:
Failed to load project at '.../Lesson31_OSXCocoa/Lesson31_OSXCocoa.pbproj', incompatible project version.
How do I open project version 1.0 with xcode 4.2?
You're better off trying to find a newer tutorial, or just studying the code as-is, without expecting to build and run it.
Judging by the modification dates, this code is almost ten years old. Even if you can get a modern version of XCode to open it, there's no reason to think that the headers, libraries, etc., that it needs to compile and run will still be compatible. Moreover, ten years is a long time in software terms. While some of the content might still be applicable, it certainly won't be anywhere near the cutting edge (which itself won't be new by the time you've mastered it).
All that said, if you're really intent on working with that project file in XCode 4.2, the best way is probably to convert it the same way a continuously developed project would have: XCode by XCode.
You can download older versions of XCode from Apple here (requires free Apple developer account).
Some older version will be able to import that file and update it to a newer format.
Assuming you don't stop at that point and use that version of XCode, you can repeat the process with the updated project file and ever-newer versions of XCode until you've arrived at version 4.2.
Relatively easy to make a new project and add the appropriate files to it. Took less than 10 minutes (had to update the code in a few places). Note that I didn't spend much time cleaning up this old code - quite a few deprecated warnings. But it runs and works. I have Xcode 4.3.2 installed but hopefully you'll be able to open it with 4.2. Here's a link to it: Lesson31.zip
Note that the process for doing this (so you can do it for any others), is to create a new Mac OS X Cocoa Application project, add the files (except main.m) from the old project to the new project, and then add necessary libraries to fix link errors (OpenGL Framework). If there's a nib then you can open that in Xcode and copy the window with view and controller out of that project and paste them into the .xib file created with the new project. Then fix compiler warnings/errors as necessary (add a few (char*) coerces, remove reference to std::ios::nocreate which doesn't seem to be available, etc).

OSX 10.8: Where is eventkit.h?

Am I the only one, or do others also have an error when doing
#import <EventKit/EventKit.h>
For some reason, this file cannot be found (10.8, XCode 4.4) even if XCode suggests it to me after typing a few letters!
I tried this in a new project with Xcode 4.4. It worked fine.
Is your project you pinned to the 10.7 SDK? Check your Base SDK setting. It should be set to Latest OS X (OS X 10.8).
This is usually set in the project, but you may be overriding it in your target's settings as well.
Before XCode 4.4, I used to just drag a framework into the framework section of the navigator on the right. That worked and was intuitive. For some reason, it does not work for the EventKit framework (perhaps even all other frameworks). The framework is recognized, but breaks the #include. If it is done using the method in Adding Framework in Xcode 4, it works fine.

Getting "Missing SDK in target picChoice: iphoneos4.0" error when building a test release of my app in Xcode 4, pvw 5

I have opened a functioning Xcode 3x project in Xcode 4.0 pvw 5 and am getting the following error whei I try to build a debug version of the app: "Missing SDK in target picChoice: iphoneos4.0"
I am trying to find where and how to remedy this, and I am coming up with bupkus.
I apologize if this is not very clear, but I am rather flummoxed by Xcode 4 so far....
Your problem was probably that Xcode 4 only came with SDK 4.2, and the project pointed to 4.0.
It's pretty common!
The solution is to go to the project info | Build settings | Base SDK and setting it to "Latest iOS" so that you don't have to touch it for future updates.
When you close the window, you'll have to switch config from debug to release or distribution and back so that it updates and Xcode removes the "Missing SDK" problem.
I just wanted to put the full answer up here to help others who have the same problem ;)
Ok...I resolved this, but I did not properly track HOW I resolved it....
I think my Target's Base SDK was not set, and I set it to: Latest iOS (iOS 4.2)....
I think that's how I did it....
But, now it builds with no errors and loads onto my iPhone as expected.
That is exactly what you needed to do. Xcode 4 introduced the Latest iOS. If you wish to test the app for older versions, select target > summary > deployment target and set that to an older iOS version and then in simulator you will see more version options available to you.

Resources