From 85d454d958ba73e45609a44e0dff5ebb881aed4e Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 30 Jan 2017 20:52:13 +0100 Subject: [PATCH 01/11] adjusted compile script to adapt swift version and sdk depending on the output file --- Scripts/compile-output.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 Scripts/compile-output.sh diff --git a/Scripts/compile-output.sh b/Scripts/compile-output.sh new file mode 100755 index 0000000..195c4ba --- /dev/null +++ b/Scripts/compile-output.sh @@ -0,0 +1,27 @@ +# For now this script doesn't work completely, because: +# - Some of the templates are aimed for Swift 3, so compiling them with Swift 2.2 will fail +# - Some templates require some context, specially for the Storyboards we need to declare +# XXPickerViewController and CreateAccViewController dummy VC subclasses to be able to compile. +# +# Once we find a clean way to resolve those limitation, we could reactivate the script. +# You could also temporarly activate the script and ignore the errors listed above to check if those +# are the only errors or if we introduced unrelated errors that needs to be fixed + +for f in `find "Tests/Expected" -name '*.swift'` +do + if [[ $f == *"swift3"* ]]; then + TOOLCHAIN="" + else + TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" + fi + if [[ $f == *"macOS"* ]]; then + SDK="macosx" + TARGET="x86_64-apple-macosx10.12" + else + SDK="iphoneos" + TARGET="armv7s-apple-ios10.0" + fi + + echo "Checking $f template-generated fixture for build errors…" + xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET "$f" +done From 34ae68bf91a79e2549e6ae88ebe8c10091114f72 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 30 Jan 2017 20:54:38 +0100 Subject: [PATCH 02/11] travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bb64b6b..d19d350 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,3 +10,4 @@ env: script: - rake "$RAKETASK" + - Scripts/compile-output.sh From 207f58b3fbea322b1633d7a9ba09a69fad09337c Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 30 Jan 2017 23:41:15 +0100 Subject: [PATCH 03/11] change module to have better name --- Contexts/Storyboards-macOS/all.plist | 6 +++--- Contexts/Storyboards-macOS/customname.plist | 6 +++--- Fixtures/Storyboards-macOS/AdditionalImport.storyboard | 4 ++-- .../Expected/Storyboards-macOS/default-context-all.swift | 8 ++++---- .../Storyboards-macOS/default-context-customname.swift | 8 ++++---- .../Storyboards-macOS/lowercase-context-all.swift | 8 ++++---- .../Storyboards-macOS/lowercase-context-customname.swift | 8 ++++---- Tests/Expected/Storyboards-macOS/swift3-context-all.swift | 8 ++++---- .../Storyboards-macOS/swift3-context-customname.swift | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Contexts/Storyboards-macOS/all.plist b/Contexts/Storyboards-macOS/all.plist index 76905c5..b8cf877 100644 --- a/Contexts/Storyboards-macOS/all.plist +++ b/Contexts/Storyboards-macOS/all.plist @@ -4,11 +4,11 @@ extraImports - DBPrefsWindowController + PrefsWindowController modules - DBPrefsWindowController + PrefsWindowController sceneEnumName StoryboardScene @@ -25,7 +25,7 @@ customClass DBPrefsWindowController customModule - DBPrefsWindowController + PrefsWindowController identifier Preferences diff --git a/Contexts/Storyboards-macOS/customname.plist b/Contexts/Storyboards-macOS/customname.plist index f223729..11f350a 100644 --- a/Contexts/Storyboards-macOS/customname.plist +++ b/Contexts/Storyboards-macOS/customname.plist @@ -4,11 +4,11 @@ extraImports - DBPrefsWindowController + PrefsWindowController modules - DBPrefsWindowController + PrefsWindowController sceneEnumName XCTStoryboardsScene @@ -25,7 +25,7 @@ customClass DBPrefsWindowController customModule - DBPrefsWindowController + PrefsWindowController identifier Preferences diff --git a/Fixtures/Storyboards-macOS/AdditionalImport.storyboard b/Fixtures/Storyboards-macOS/AdditionalImport.storyboard index d8a543a..aa5ab9b 100644 --- a/Fixtures/Storyboards-macOS/AdditionalImport.storyboard +++ b/Fixtures/Storyboards-macOS/AdditionalImport.storyboard @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + diff --git a/Tests/Expected/Storyboards-macOS/default-context-all.swift b/Tests/Expected/Storyboards-macOS/default-context-all.swift index e7c0444..b93e1e9 100644 --- a/Tests/Expected/Storyboards-macOS/default-context-all.swift +++ b/Tests/Expected/Storyboards-macOS/default-context-all.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum StoryboardScene { static let storyboardName = "AdditionalImport" case PreferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = StoryboardScene.AdditionalImport.PreferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = StoryboardScene.AdditionalImport.PreferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } diff --git a/Tests/Expected/Storyboards-macOS/default-context-customname.swift b/Tests/Expected/Storyboards-macOS/default-context-customname.swift index 9ef817d..6b3eaa5 100644 --- a/Tests/Expected/Storyboards-macOS/default-context-customname.swift +++ b/Tests/Expected/Storyboards-macOS/default-context-customname.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum XCTStoryboardsScene { static let storyboardName = "AdditionalImport" case PreferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = XCTStoryboardsScene.AdditionalImport.PreferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = XCTStoryboardsScene.AdditionalImport.PreferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift index 22c9e2e..d0f79d0 100644 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift +++ b/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum StoryboardScene { static let storyboardName = "AdditionalImport" case preferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = StoryboardScene.AdditionalImport.preferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = StoryboardScene.AdditionalImport.preferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-customname.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-customname.swift index 3dc5a5d..daa0147 100644 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-customname.swift +++ b/Tests/Expected/Storyboards-macOS/lowercase-context-customname.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum XCTStoryboardsScene { static let storyboardName = "AdditionalImport" case preferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = XCTStoryboardsScene.AdditionalImport.preferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = XCTStoryboardsScene.AdditionalImport.preferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } diff --git a/Tests/Expected/Storyboards-macOS/swift3-context-all.swift b/Tests/Expected/Storyboards-macOS/swift3-context-all.swift index 0bfbc99..cd51de0 100644 --- a/Tests/Expected/Storyboards-macOS/swift3-context-all.swift +++ b/Tests/Expected/Storyboards-macOS/swift3-context-all.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum StoryboardScene { static let storyboardName = "AdditionalImport" case preferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = StoryboardScene.AdditionalImport.preferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = StoryboardScene.AdditionalImport.preferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } diff --git a/Tests/Expected/Storyboards-macOS/swift3-context-customname.swift b/Tests/Expected/Storyboards-macOS/swift3-context-customname.swift index 9bb1d22..1f1d7b9 100644 --- a/Tests/Expected/Storyboards-macOS/swift3-context-customname.swift +++ b/Tests/Expected/Storyboards-macOS/swift3-context-customname.swift @@ -2,7 +2,7 @@ import Foundation import Cocoa -import DBPrefsWindowController +import PrefsWindowController // swiftlint:disable file_length // swiftlint:disable line_length @@ -54,10 +54,10 @@ enum XCTStoryboardsScene { static let storyboardName = "AdditionalImport" case preferencesScene = "Preferences" - static func instantiatePreferences() -> DBPrefsWindowController.DBPrefsWindowController { - guard let vc = XCTStoryboardsScene.AdditionalImport.preferencesScene.controller() as? DBPrefsWindowController.DBPrefsWindowController + static func instantiatePreferences() -> PrefsWindowController.DBPrefsWindowController { + guard let vc = XCTStoryboardsScene.AdditionalImport.preferencesScene.controller() as? PrefsWindowController.DBPrefsWindowController else { - fatalError("ViewController 'Preferences' is not of the expected class DBPrefsWindowController.DBPrefsWindowController.") + fatalError("ViewController 'Preferences' is not of the expected class PrefsWindowController.DBPrefsWindowController.") } return vc } From ac7bc08758de114af8f9761c8c2084083d61ee90 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 00:08:56 +0100 Subject: [PATCH 04/11] Create and compile modules --- .gitignore | 1 + Scripts/Modules/CustomSegue.swift | 4 +++ Scripts/Modules/LocationPicker.swift | 4 +++ Scripts/Modules/PrefsWindowController.swift | 4 +++ Scripts/Modules/SlackTextViewController.swift | 4 +++ Scripts/Modules/swift2.3/.gitkeep | 0 Scripts/Modules/swift3/.gitkeep | 0 Scripts/compile-modules.sh | 25 +++++++++++++++++++ 8 files changed, 42 insertions(+) create mode 100644 Scripts/Modules/CustomSegue.swift create mode 100644 Scripts/Modules/LocationPicker.swift create mode 100644 Scripts/Modules/PrefsWindowController.swift create mode 100644 Scripts/Modules/SlackTextViewController.swift create mode 100644 Scripts/Modules/swift2.3/.gitkeep create mode 100644 Scripts/Modules/swift3/.gitkeep create mode 100755 Scripts/compile-modules.sh diff --git a/.gitignore b/.gitignore index 2c22487..3684189 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ ## Build generated build/ DerivedData/ +Scripts/Modules/**/*.swiftmodule ## Various settings *.pbxuser diff --git a/Scripts/Modules/CustomSegue.swift b/Scripts/Modules/CustomSegue.swift new file mode 100644 index 0000000..4b3bd5b --- /dev/null +++ b/Scripts/Modules/CustomSegue.swift @@ -0,0 +1,4 @@ +import UIKit + +public class CustomSegue: UIStoryboardSegue { +} diff --git a/Scripts/Modules/LocationPicker.swift b/Scripts/Modules/LocationPicker.swift new file mode 100644 index 0000000..36ed86b --- /dev/null +++ b/Scripts/Modules/LocationPicker.swift @@ -0,0 +1,4 @@ +import UIKit + +public class LocationPickerViewController: UIViewController { +} diff --git a/Scripts/Modules/PrefsWindowController.swift b/Scripts/Modules/PrefsWindowController.swift new file mode 100644 index 0000000..c687234 --- /dev/null +++ b/Scripts/Modules/PrefsWindowController.swift @@ -0,0 +1,4 @@ +import Cocoa + +public class DBPrefsWindowController: NSWindowController { +} diff --git a/Scripts/Modules/SlackTextViewController.swift b/Scripts/Modules/SlackTextViewController.swift new file mode 100644 index 0000000..52c2757 --- /dev/null +++ b/Scripts/Modules/SlackTextViewController.swift @@ -0,0 +1,4 @@ +import UIKit + +public class SLKTextViewController: UIViewController { +} diff --git a/Scripts/Modules/swift2.3/.gitkeep b/Scripts/Modules/swift2.3/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/Modules/swift3/.gitkeep b/Scripts/Modules/swift3/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/compile-modules.sh b/Scripts/compile-modules.sh new file mode 100755 index 0000000..cdfb33e --- /dev/null +++ b/Scripts/compile-modules.sh @@ -0,0 +1,25 @@ +SWIFT2_TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" +SWIFT3_TOOLCHAIN="" + +# compile macos modules +SDK=$(xcrun --show-sdk-path --sdk macosx) +TARGET="x86_64-apple-macosx10.12" +MODULES=("PrefsWindowController") + +for m in $MODULES; do + xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET + xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET +done + +#compile ios modules +SDK=$(xcrun --show-sdk-path --sdk iphoneos) +TARGET="armv7s-apple-ios10.0" +MODULES=("CustomSegue" "LocationPicker" "SlackTextViewController") + +for m in $MODULES; do + xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET + xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET +done + +# don't need this +rm Scripts/Modules/*.swiftdoc From 9c0311f8fe10af87a63ab3ff23c6a1af82af2e6a Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 00:09:13 +0100 Subject: [PATCH 05/11] Use compiled modules --- Scripts/compile-output.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Scripts/compile-output.sh b/Scripts/compile-output.sh index 195c4ba..541e803 100755 --- a/Scripts/compile-output.sh +++ b/Scripts/compile-output.sh @@ -1,18 +1,16 @@ -# For now this script doesn't work completely, because: -# - Some of the templates are aimed for Swift 3, so compiling them with Swift 2.2 will fail -# - Some templates require some context, specially for the Storyboards we need to declare -# XXPickerViewController and CreateAccViewController dummy VC subclasses to be able to compile. -# -# Once we find a clean way to resolve those limitation, we could reactivate the script. -# You could also temporarly activate the script and ignore the errors listed above to check if those -# are the only errors or if we introduced unrelated errors that needs to be fixed +# first compile the modules +echo "Compiling modules…" +./Scripts/compile-modules.sh +# compile each file for f in `find "Tests/Expected" -name '*.swift'` do if [[ $f == *"swift3"* ]]; then TOOLCHAIN="" + MODULES="Scripts/Modules/swift3" else TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" + MODULES="Scripts/Modules/swift2.3" fi if [[ $f == *"macOS"* ]]; then SDK="macosx" @@ -23,5 +21,5 @@ do fi echo "Checking $f template-generated fixture for build errors…" - xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET "$f" + xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET "$f" -I $MODULES done From a570917f1877e7de05f21c1dbe3f4affa6ded222 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 00:37:29 +0100 Subject: [PATCH 06/11] Define classes for the current module --- Scripts/Definitions.swift | 15 +++++++++++++++ Scripts/compile-output.sh | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Scripts/Definitions.swift diff --git a/Scripts/Definitions.swift b/Scripts/Definitions.swift new file mode 100644 index 0000000..56e27bf --- /dev/null +++ b/Scripts/Definitions.swift @@ -0,0 +1,15 @@ +#if os(iOS) || os(tvOS) || os(watchOS) + import UIKit + + class CreateAccViewController: UIViewController { + } + class XXPickerViewController: UIViewController { + } +#elseif os(OSX) + import Cocoa + + class CustomTabViewController: NSWindowController { + } + class NSControllerPlaceholder: NSWindowController { + } +#endif diff --git a/Scripts/compile-output.sh b/Scripts/compile-output.sh index 541e803..9e0cb8c 100755 --- a/Scripts/compile-output.sh +++ b/Scripts/compile-output.sh @@ -21,5 +21,5 @@ do fi echo "Checking $f template-generated fixture for build errors…" - xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET "$f" -I $MODULES + xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET -I $MODULES "Scripts/Definitions.swift" "$f" done From 48c4b30e3057c79001fcc290a9a4859f93ff99b2 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 00:39:28 +0100 Subject: [PATCH 07/11] compile modules as a rake task --- .travis.yml | 1 + Scripts/compile-output.sh | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d19d350..7da4dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,5 @@ env: script: - rake "$RAKETASK" + - Scripts/compile-modules.sh - Scripts/compile-output.sh diff --git a/Scripts/compile-output.sh b/Scripts/compile-output.sh index 9e0cb8c..72f0803 100755 --- a/Scripts/compile-output.sh +++ b/Scripts/compile-output.sh @@ -1,8 +1,3 @@ -# first compile the modules -echo "Compiling modules…" -./Scripts/compile-modules.sh - -# compile each file for f in `find "Tests/Expected" -name '*.swift'` do if [[ $f == *"swift3"* ]]; then @@ -12,6 +7,7 @@ do TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" MODULES="Scripts/Modules/swift2.3" fi + if [[ $f == *"macOS"* ]]; then SDK="macosx" TARGET="x86_64-apple-macosx10.12" From 2169c9c29cce98fe92c411410be5da368af3f0f1 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 09:46:35 +0100 Subject: [PATCH 08/11] fix module compilation --- Scripts/compile-modules.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Scripts/compile-modules.sh b/Scripts/compile-modules.sh index cdfb33e..a3a5730 100755 --- a/Scripts/compile-modules.sh +++ b/Scripts/compile-modules.sh @@ -4,9 +4,10 @@ SWIFT3_TOOLCHAIN="" # compile macos modules SDK=$(xcrun --show-sdk-path --sdk macosx) TARGET="x86_64-apple-macosx10.12" -MODULES=("PrefsWindowController") +MODULES=( "PrefsWindowController" ) -for m in $MODULES; do +for m in ${MODULES[@]}; do + echo "Compiling module ${m}… (macos)" xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET done @@ -14,9 +15,10 @@ done #compile ios modules SDK=$(xcrun --show-sdk-path --sdk iphoneos) TARGET="armv7s-apple-ios10.0" -MODULES=("CustomSegue" "LocationPicker" "SlackTextViewController") +MODULES=( "CustomSegue" "LocationPicker" "SlackTextViewController" ) -for m in $MODULES; do +for m in ${MODULES[@]}; do + echo "Compiling module ${m}… (ios)" xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET done From cb20822f492b282fa2dcca728d55d34d15e9b8f7 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 12:20:15 +0100 Subject: [PATCH 09/11] fix warning about public in internal module --- Tests/Expected/Images/dot-syntax-context-customname.swift | 6 +++--- Tests/Expected/Images/dot-syntax-context-defaults.swift | 6 +++--- .../Images/dot-syntax-swift3-context-customname.swift | 6 +++--- .../Images/dot-syntax-swift3-context-defaults.swift | 6 +++--- templates/images-dot-syntax-swift3.stencil | 6 +++--- templates/images-dot-syntax.stencil | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Tests/Expected/Images/dot-syntax-context-customname.swift b/Tests/Expected/Images/dot-syntax-context-customname.swift index 16f762c..2be0223 100644 --- a/Tests/Expected/Images/dot-syntax-context-customname.swift +++ b/Tests/Expected/Images/dot-syntax-context-customname.swift @@ -19,15 +19,15 @@ struct XCTImagesType: StringLiteralConvertible { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } diff --git a/Tests/Expected/Images/dot-syntax-context-defaults.swift b/Tests/Expected/Images/dot-syntax-context-defaults.swift index 29963ed..fa3a51a 100644 --- a/Tests/Expected/Images/dot-syntax-context-defaults.swift +++ b/Tests/Expected/Images/dot-syntax-context-defaults.swift @@ -19,15 +19,15 @@ struct AssetType: StringLiteralConvertible { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } diff --git a/Tests/Expected/Images/dot-syntax-swift3-context-customname.swift b/Tests/Expected/Images/dot-syntax-swift3-context-customname.swift index 4025a0b..11f4398 100644 --- a/Tests/Expected/Images/dot-syntax-swift3-context-customname.swift +++ b/Tests/Expected/Images/dot-syntax-swift3-context-customname.swift @@ -19,15 +19,15 @@ struct XCTImagesType: ExpressibleByStringLiteral { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } diff --git a/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift b/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift index df4df39..2f7923d 100644 --- a/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift +++ b/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift @@ -19,15 +19,15 @@ struct AssetType: ExpressibleByStringLiteral { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } diff --git a/templates/images-dot-syntax-swift3.stencil b/templates/images-dot-syntax-swift3.stencil index ad3a68a..2add6c6 100644 --- a/templates/images-dot-syntax-swift3.stencil +++ b/templates/images-dot-syntax-swift3.stencil @@ -20,15 +20,15 @@ struct {{enumName}}Type: ExpressibleByStringLiteral { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } diff --git a/templates/images-dot-syntax.stencil b/templates/images-dot-syntax.stencil index 0c2b931..025190e 100644 --- a/templates/images-dot-syntax.stencil +++ b/templates/images-dot-syntax.stencil @@ -20,15 +20,15 @@ struct {{enumName}}Type: StringLiteralConvertible { return UIImage(asset: self) } - public init(stringLiteral value: String) { + init(stringLiteral value: String) { self.value = value } - public init(extendedGraphemeClusterLiteral value: String) { + init(extendedGraphemeClusterLiteral value: String) { self.init(stringLiteral: value) } - public init(unicodeScalarLiteral value: String) { + init(unicodeScalarLiteral value: String) { self.init(stringLiteral: value) } } From f67239f248f7e4aa6e14a3057c8d6bd28ffa0f6a Mon Sep 17 00:00:00 2001 From: David Jennes Date: Tue, 31 Jan 2017 12:44:00 +0100 Subject: [PATCH 10/11] Fix duplicate rawcolor value --- Contexts/Colors/customname.plist | 16 ---------------- Contexts/Colors/defaults.plist | 16 ---------------- Fixtures/Colors/colors.clr | Bin 256 -> 647 bytes Fixtures/Colors/colors.json | 1 - Fixtures/Colors/colors.xml | 1 - .../Colors/default-context-customname.swift | 5 ----- .../Colors/default-context-defaults.swift | 5 ----- .../Colors/rawValue-context-customname.swift | 3 --- .../Colors/rawValue-context-defaults.swift | 3 --- .../Colors/swift3-context-customname.swift | 5 ----- .../Colors/swift3-context-defaults.swift | 5 ----- 11 files changed, 60 deletions(-) diff --git a/Contexts/Colors/customname.plist b/Contexts/Colors/customname.plist index 0a81b9a..b281ad6 100644 --- a/Contexts/Colors/customname.plist +++ b/Contexts/Colors/customname.plist @@ -52,22 +52,6 @@ rgba 33fe66ff - - alpha - ff - blue - cc - green - 66 - name - Cyan-Color - red - ff - rgb - ff66cc - rgba - ff66ccff - alpha cc diff --git a/Contexts/Colors/defaults.plist b/Contexts/Colors/defaults.plist index 1a91dd2..9af9772 100644 --- a/Contexts/Colors/defaults.plist +++ b/Contexts/Colors/defaults.plist @@ -52,22 +52,6 @@ rgba 33fe66ff - - alpha - ff - blue - cc - green - 66 - name - Cyan-Color - red - ff - rgb - ff66cc - rgba - ff66ccff - alpha cc diff --git a/Fixtures/Colors/colors.clr b/Fixtures/Colors/colors.clr index 15ddf6544d7117ea44228e2b4c23fa6fa5257de3..09bdd4283848ff2a9f52dc90c2d70f8f378dc4d9 100644 GIT binary patch literal 647 zcmZWmOK;Oa5S~ffG)W6}8y=}@%Ii>Y5KcpADv;x@z~Fj=?I7h+ z?Fl4)0|x{}a4Bc5NQg5EJ#c^{9FR~|A%wW$*MZ0EVP^K5@0;1#X3NlRM-VnK($m`) z%@^wYJ!089HS0WW-X@x3U*lCvyQRC=RoZbn{C7B z#uEeFlB{GxUX9lb)wb6MckCQu5!SIr8 z4rx>^)wGSaMog!>XYc5~r9jbCS4lkxiG5vGF0~!CX^^sIshy{zW2vjM;>UGasrXND zCp*BcA3T&k%wjCT2G}5rzULoM-V(hO8gUX zV<~7PiX{lja$Z?dOnc`a*xjA1ERYUaDTiOxElQ=6?gIS5?3$0-te+voU>L?=9A+R3 zMK}iwa2XoVgqxtl9aselcVP`4!XtPA8}JHV!#mi7kMJ43!WL}9clZH6;THl%F^O|{ r3Qyx%yoeR7;Tkf0fY0zbzQi~97C+!8{DR+b3w(=U;9)NGp~LOpCd;iI literal 256 zcmZSKE-oobP0TH+EJ#ghe8Jqpn910}#{TNslWTUgS7fU)`PnKO1k!pEMm4X7TdD7d63GcTQSN(-Ylmvd!eo-Wvcwka)> zr!&p~skCeU|F6y-tP!YZ+AJQ&qLR$yoYaualAKf&bB(^NMpylT-6b+5o?qY2g3> diff --git a/Fixtures/Colors/colors.json b/Fixtures/Colors/colors.json index a79d95e..473c9d8 100644 --- a/Fixtures/Colors/colors.json +++ b/Fixtures/Colors/colors.json @@ -1,5 +1,4 @@ { - "Cyan-Color" : "0xff66ccff", "ArticleTitle" : "#33fe66", "ArticleBody" : "339666", "ArticleFootnote" : "ff66ccff", diff --git a/Fixtures/Colors/colors.xml b/Fixtures/Colors/colors.xml index e2c1525..f4fc3d6 100644 --- a/Fixtures/Colors/colors.xml +++ b/Fixtures/Colors/colors.xml @@ -1,6 +1,5 @@ - #ff66cc #33fe66 #339666 #ff66ccff diff --git a/Tests/Expected/Colors/default-context-customname.swift b/Tests/Expected/Colors/default-context-customname.swift index 5301253..62329d6 100644 --- a/Tests/Expected/Colors/default-context-customname.swift +++ b/Tests/Expected/Colors/default-context-customname.swift @@ -33,9 +33,6 @@ enum XCTColors { /// /// Alpha: 100%
(0x33fe66ff) case ArticleTitle - /// - /// Alpha: 100%
(0xff66ccff) - case Cyan_Color /// /// Alpha: 80%
(0xffffffcc) case Translucent @@ -48,8 +45,6 @@ enum XCTColors { return 0xff66ccff case .ArticleTitle: return 0x33fe66ff - case .Cyan_Color: - return 0xff66ccff case .Translucent: return 0xffffffcc } diff --git a/Tests/Expected/Colors/default-context-defaults.swift b/Tests/Expected/Colors/default-context-defaults.swift index 2fe28a6..342d114 100644 --- a/Tests/Expected/Colors/default-context-defaults.swift +++ b/Tests/Expected/Colors/default-context-defaults.swift @@ -33,9 +33,6 @@ enum ColorName { /// /// Alpha: 100%
(0x33fe66ff) case ArticleTitle - /// - /// Alpha: 100%
(0xff66ccff) - case Cyan_Color /// /// Alpha: 80%
(0xffffffcc) case Translucent @@ -48,8 +45,6 @@ enum ColorName { return 0xff66ccff case .ArticleTitle: return 0x33fe66ff - case .Cyan_Color: - return 0xff66ccff case .Translucent: return 0xffffffcc } diff --git a/Tests/Expected/Colors/rawValue-context-customname.swift b/Tests/Expected/Colors/rawValue-context-customname.swift index 2f71fac..f1161b9 100644 --- a/Tests/Expected/Colors/rawValue-context-customname.swift +++ b/Tests/Expected/Colors/rawValue-context-customname.swift @@ -33,9 +33,6 @@ enum XCTColors: UInt32 { /// /// Alpha: 100%
(0x33fe66ff) case ArticleTitle = 0x33fe66ff - /// - /// Alpha: 100%
(0xff66ccff) - case Cyan_Color = 0xff66ccff /// /// Alpha: 80%
(0xffffffcc) case Translucent = 0xffffffcc diff --git a/Tests/Expected/Colors/rawValue-context-defaults.swift b/Tests/Expected/Colors/rawValue-context-defaults.swift index d6153e7..e61223b 100644 --- a/Tests/Expected/Colors/rawValue-context-defaults.swift +++ b/Tests/Expected/Colors/rawValue-context-defaults.swift @@ -33,9 +33,6 @@ enum ColorName: UInt32 { /// /// Alpha: 100%
(0x33fe66ff) case ArticleTitle = 0x33fe66ff - /// - /// Alpha: 100%
(0xff66ccff) - case Cyan_Color = 0xff66ccff /// /// Alpha: 80%
(0xffffffcc) case Translucent = 0xffffffcc diff --git a/Tests/Expected/Colors/swift3-context-customname.swift b/Tests/Expected/Colors/swift3-context-customname.swift index 43870e4..da78bd1 100644 --- a/Tests/Expected/Colors/swift3-context-customname.swift +++ b/Tests/Expected/Colors/swift3-context-customname.swift @@ -33,9 +33,6 @@ enum XCTColors { /// /// Alpha: 100%
(0x33fe66ff) case articleTitle - /// - /// Alpha: 100%
(0xff66ccff) - case cyanColor /// /// Alpha: 80%
(0xffffffcc) case translucent @@ -48,8 +45,6 @@ enum XCTColors { return 0xff66ccff case .articleTitle: return 0x33fe66ff - case .cyanColor: - return 0xff66ccff case .translucent: return 0xffffffcc } diff --git a/Tests/Expected/Colors/swift3-context-defaults.swift b/Tests/Expected/Colors/swift3-context-defaults.swift index 04dd614..97c22fe 100644 --- a/Tests/Expected/Colors/swift3-context-defaults.swift +++ b/Tests/Expected/Colors/swift3-context-defaults.swift @@ -33,9 +33,6 @@ enum ColorName { /// /// Alpha: 100%
(0x33fe66ff) case articleTitle - /// - /// Alpha: 100%
(0xff66ccff) - case cyanColor /// /// Alpha: 80%
(0xffffffcc) case translucent @@ -48,8 +45,6 @@ enum ColorName { return 0xff66ccff case .articleTitle: return 0x33fe66ff - case .cyanColor: - return 0xff66ccff case .translucent: return 0xffffffcc } From 418cd6ffd22e8323638d74351ab2602cd2c73f7f Mon Sep 17 00:00:00 2001 From: David Jennes Date: Sun, 12 Feb 2017 23:41:43 +0100 Subject: [PATCH 11/11] Move env. files to a fixtures subdir --- .gitignore | 2 +- {Scripts => Fixtures/stub-env}/Definitions.swift | 0 .../stub-env}/Modules/CustomSegue.swift | 0 .../stub-env}/Modules/LocationPicker.swift | 0 .../stub-env}/Modules/PrefsWindowController.swift | 0 .../stub-env}/Modules/SlackTextViewController.swift | 0 .../Modules => Fixtures/stub-env}/swift2.3/.gitkeep | 0 .../Modules => Fixtures/stub-env}/swift3/.gitkeep | 0 Scripts/compile-modules.sh | 13 ++++++++----- Scripts/compile-output.sh | 6 +++--- 10 files changed, 12 insertions(+), 9 deletions(-) rename {Scripts => Fixtures/stub-env}/Definitions.swift (100%) rename {Scripts => Fixtures/stub-env}/Modules/CustomSegue.swift (100%) rename {Scripts => Fixtures/stub-env}/Modules/LocationPicker.swift (100%) rename {Scripts => Fixtures/stub-env}/Modules/PrefsWindowController.swift (100%) rename {Scripts => Fixtures/stub-env}/Modules/SlackTextViewController.swift (100%) rename {Scripts/Modules => Fixtures/stub-env}/swift2.3/.gitkeep (100%) rename {Scripts/Modules => Fixtures/stub-env}/swift3/.gitkeep (100%) diff --git a/.gitignore b/.gitignore index 3684189..e1b4bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ ## Build generated build/ DerivedData/ -Scripts/Modules/**/*.swiftmodule +Fixtures/stub-env/**/*.swiftmodule ## Various settings *.pbxuser diff --git a/Scripts/Definitions.swift b/Fixtures/stub-env/Definitions.swift similarity index 100% rename from Scripts/Definitions.swift rename to Fixtures/stub-env/Definitions.swift diff --git a/Scripts/Modules/CustomSegue.swift b/Fixtures/stub-env/Modules/CustomSegue.swift similarity index 100% rename from Scripts/Modules/CustomSegue.swift rename to Fixtures/stub-env/Modules/CustomSegue.swift diff --git a/Scripts/Modules/LocationPicker.swift b/Fixtures/stub-env/Modules/LocationPicker.swift similarity index 100% rename from Scripts/Modules/LocationPicker.swift rename to Fixtures/stub-env/Modules/LocationPicker.swift diff --git a/Scripts/Modules/PrefsWindowController.swift b/Fixtures/stub-env/Modules/PrefsWindowController.swift similarity index 100% rename from Scripts/Modules/PrefsWindowController.swift rename to Fixtures/stub-env/Modules/PrefsWindowController.swift diff --git a/Scripts/Modules/SlackTextViewController.swift b/Fixtures/stub-env/Modules/SlackTextViewController.swift similarity index 100% rename from Scripts/Modules/SlackTextViewController.swift rename to Fixtures/stub-env/Modules/SlackTextViewController.swift diff --git a/Scripts/Modules/swift2.3/.gitkeep b/Fixtures/stub-env/swift2.3/.gitkeep similarity index 100% rename from Scripts/Modules/swift2.3/.gitkeep rename to Fixtures/stub-env/swift2.3/.gitkeep diff --git a/Scripts/Modules/swift3/.gitkeep b/Fixtures/stub-env/swift3/.gitkeep similarity index 100% rename from Scripts/Modules/swift3/.gitkeep rename to Fixtures/stub-env/swift3/.gitkeep diff --git a/Scripts/compile-modules.sh b/Scripts/compile-modules.sh index a3a5730..89ca2a4 100755 --- a/Scripts/compile-modules.sh +++ b/Scripts/compile-modules.sh @@ -1,3 +1,6 @@ +INPUT_PATH="Fixtures/stub-env/Modules" +OUTPUT_PATH="Fixtures/stub-env" + SWIFT2_TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" SWIFT3_TOOLCHAIN="" @@ -8,8 +11,8 @@ MODULES=( "PrefsWindowController" ) for m in ${MODULES[@]}; do echo "Compiling module ${m}… (macos)" - xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET - xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET + xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "$INPUT_PATH/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "$OUTPUT_PATH/swift3" -target $TARGET + xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "$INPUT_PATH/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "$OUTPUT_PATH/swift2.3" -target $TARGET done #compile ios modules @@ -19,9 +22,9 @@ MODULES=( "CustomSegue" "LocationPicker" "SlackTextViewController" ) for m in ${MODULES[@]}; do echo "Compiling module ${m}… (ios)" - xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift3" -target $TARGET - xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "Scripts/Modules/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "Scripts/Modules/swift2.3" -target $TARGET + xcrun $SWIFT3_TOOLCHAIN swiftc -emit-module "$INPUT_PATH/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "$OUTPUT_PATH/swift3" -target $TARGET + xcrun $SWIFT2_TOOLCHAIN swiftc -emit-module "$INPUT_PATH/$m.swift" -sdk $SDK -module-name "$m" -emit-module-path "$OUTPUT_PATH/swift2.3" -target $TARGET done # don't need this -rm Scripts/Modules/*.swiftdoc +rm $OUTPUT_PATH/*.swiftdoc diff --git a/Scripts/compile-output.sh b/Scripts/compile-output.sh index 72f0803..758f3a6 100755 --- a/Scripts/compile-output.sh +++ b/Scripts/compile-output.sh @@ -2,10 +2,10 @@ for f in `find "Tests/Expected" -name '*.swift'` do if [[ $f == *"swift3"* ]]; then TOOLCHAIN="" - MODULES="Scripts/Modules/swift3" + MODULES="Fixtures/stub-env/swift3" else TOOLCHAIN="--toolchain com.apple.dt.toolchain.Swift_2_3" - MODULES="Scripts/Modules/swift2.3" + MODULES="Fixtures/stub-env/swift2.3" fi if [[ $f == *"macOS"* ]]; then @@ -17,5 +17,5 @@ do fi echo "Checking $f template-generated fixture for build errors…" - xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET -I $MODULES "Scripts/Definitions.swift" "$f" + xcrun $TOOLCHAIN -sdk $SDK swiftc -parse -target $TARGET -I $MODULES "Fixtures/stub-env/Definitions.swift" "$f" done