No Swift settings in Xcode 5 project

妖精的绣舞 提交于 2019-12-10 15:46:54

问题


I am trying to add some Swift code to an existing project created in Xcode 5 and I get a crash whenever I try to automatically generate a bridging header. Looking in my project settings, I think it is because there are no Swift Compiler settings. Anyone know of a way to migrate a project to Xcode 6 settings or do I need to re-create the project?


回答1:


The only solution I've found for this is to create a new target. Make sure to select "Swift" as the language choice for the new target. Something in the creation of a target with this selection enables the Swift build settings.

Update: Creating a new target containing Swift worked because of what it contained. When I removed the template Swift files from the new target the Swift-specific build settings disappeared from the project again.

The real indicator to Xcode on whether to show those build settings is whether the target contains at least one .swift file. So, the easiest solution is to simply add a new Swift file. This also triggers Xcode to prompt you about automatically creating an Objective-C bridging header - which you'll need in any project that has some Objective-C in it.




回答2:


I was able to work around this by manually adding some Swift settings to the project.pbxproj file.

In the attributes block of the PBXProject section, add:

LastSwiftUpdateCheck = 0720;

In the XCBuildConfiguration section, add this to the Debug build settings for the project (the first and larger block of settings):

SWIFT_OPTIMIZATION_LEVEL = "-Onone";

And add this to the Debug build settings for the target:

OTHER_SWIFT_FLAGS = "-DDEBUG";

And this to the Release build settings for the target:

OTHER_SWIFT_FLAGS = "";

When you reopen the project, the Swift settings will be available.




回答3:


Most of the swift settings were missing for me.

Adding a new Swift file to my target, also added the build settings.

Removing the only swift file, seemed to have also removed all the build settings. So make sure you have a swift file in your list of compiled sources.



来源:https://stackoverflow.com/questions/24169377/no-swift-settings-in-xcode-5-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!