Merge pull request #1477 from socialpoint/recognize-swift-files-as-source-code
Add support for .swift file for xcode
This commit is contained in:
commit
a1024748b1
@ -61,6 +61,17 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_ListsSwiftSources()
|
||||
files { "source.swift", "Info.plist" }
|
||||
prepare()
|
||||
xcode.PBXBuildFile(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXBuildFile section */
|
||||
4616E7383FD8A3AA79D7A578 /* source.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2BDAE0539CBF12983B9120 /* source.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_ListsResourceFilesOnlyOnceWithGroupID()
|
||||
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
|
||||
prepare()
|
||||
@ -3563,6 +3574,83 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnSwift4_0()
|
||||
workspace("MyWorkspace")
|
||||
swiftversion("4.0")
|
||||
prepare()
|
||||
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
|
||||
test.capture [[
|
||||
A14350AC4595EE5E57CE36EC /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
|
||||
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
OBJROOT = obj/Debug;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
SWIFT_VERSION = 4.0;
|
||||
SYMROOT = bin/Debug;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnSwift4_2()
|
||||
workspace("MyWorkspace")
|
||||
swiftversion("4.2")
|
||||
prepare()
|
||||
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
|
||||
test.capture [[
|
||||
A14350AC4595EE5E57CE36EC /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
|
||||
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
OBJROOT = obj/Debug;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
SWIFT_VERSION = 4.2;
|
||||
SYMROOT = bin/Debug;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.XCBuildConfigurationProject_OnSwift5_0()
|
||||
workspace("MyWorkspace")
|
||||
swiftversion("5.0")
|
||||
prepare()
|
||||
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
|
||||
test.capture [[
|
||||
A14350AC4595EE5E57CE36EC /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
|
||||
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
OBJROOT = obj/Debug;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
SWIFT_VERSION = 5.0;
|
||||
SYMROOT = bin/Debug;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
]]
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- XCBuildConfigurationList tests
|
||||
|
@ -41,6 +41,7 @@
|
||||
[".icns"] = "Resources",
|
||||
[".s"] = "Sources",
|
||||
[".S"] = "Sources",
|
||||
[".swift"] = "Sources",
|
||||
}
|
||||
if node.isResource then
|
||||
return "Resources"
|
||||
@ -140,7 +141,7 @@
|
||||
[".bmp"] = "image.bmp",
|
||||
[".wav"] = "audio.wav",
|
||||
[".xcassets"] = "folder.assetcatalog",
|
||||
|
||||
[".swift"] = "sourcecode.swift",
|
||||
}
|
||||
return types[path.getextension(node.path)] or "text"
|
||||
end
|
||||
@ -1262,6 +1263,15 @@
|
||||
end
|
||||
end
|
||||
|
||||
function xcode.XCBuildConfiguration_SwiftLanguageVersion(settings, cfg)
|
||||
-- if no swiftversion is provided, don't set swift version
|
||||
-- Projects with swift files but without swift version will refuse
|
||||
-- to build on Xcode but setting a default SWIFT_VERSION may have
|
||||
-- unexpected interactions with other systems like cocoapods
|
||||
if cfg.swiftversion then
|
||||
settings['SWIFT_VERSION'] = cfg.swiftversion
|
||||
end
|
||||
end
|
||||
|
||||
function xcode.XCBuildConfiguration_Project(tr, cfg)
|
||||
local settings = {}
|
||||
@ -1430,6 +1440,8 @@
|
||||
settings['WARNING_CFLAGS'] = '-Weverything'
|
||||
end
|
||||
|
||||
xcode.XCBuildConfiguration_SwiftLanguageVersion(settings, cfg)
|
||||
|
||||
xcode.overrideSettings(settings, cfg.xcodebuildsettings)
|
||||
|
||||
_p(2,'%s /* %s */ = {', cfg.xcode.projectid, cfg.buildcfg)
|
||||
|
@ -782,6 +782,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "swiftversion",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"4.0",
|
||||
"4.2",
|
||||
"5.0",
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "libdirs",
|
||||
scope = "config",
|
||||
|
Reference in New Issue
Block a user