From b49bc4894a1814a7ca2a1c445083b6d546cea7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B1=E7=9F=B3?= Date: Thu, 24 Nov 2016 18:12:31 +0800 Subject: [PATCH] fix: crash on xcode 8. https://github.com/Xcode-Snippets/Objective-C/issues/60 --- lib/xcodesnippet/commands/install.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/xcodesnippet/commands/install.rb b/lib/xcodesnippet/commands/install.rb index 826457d..d677293 100644 --- a/lib/xcodesnippet/commands/install.rb +++ b/lib/xcodesnippet/commands/install.rb @@ -55,11 +55,17 @@ def extract_front_matter! when ".mm" then "Xcode.SourceCodeLanguage.Objective-C++" else "" end - @snippet.title = front_matter["title"] || "" - @snippet.summary = front_matter["summary"] || "" - @snippet.completion_scopes = [front_matter["completion-scope"]] || front_matter["completion-scopes"] || "All" - @snippet.identifier = SecureRandom.uuid().upcase + @snippet.title = front_matter["title"] || @snippet.completion_prefix + @snippet.summary = front_matter["summary"] || @snippet.completion_prefix + if front_matter["completion-scope"] + @snippet.completion_scopes = [front_matter["completion-scope"]] + elsif(front_matter["completion-scopes"]) + @snippet.completion_scopes = front_matter["completion-scopes"] + else + @snippet.completion_scopes = "All" + end + @snippet.identifier = @snippet.completion_prefix @snippet.is_user_snippet = true - @snippet.version = 0 + @snippet.version = 2 end end