ããã«ã¡ã¯ï¼ã¨ã³ã¸ãã¢ã®æ³æã§ãã主ã«ãããªã®iOSã¢ããªã®éçºãæ å½ãã¦ãã¾ãã
ä»åã¯SwiftFormatã®å°å ¥ã«ã¤ãã¦ã話ãã¾ã
èæ¯
ã³ãããã§ã¯Swiftã¯raywenderlichã®swift style guideãã³ã¼ãã£ã³ã°ã®ã¹ã¿ã¤ã«ã¬ã¤ãã¨ãã¦ã³ã¼ããæ¸ãã¦ãã¾ãã
ã§ãããåéçºè ãå ¨ã¦ã®ã¹ã¿ã¤ã«ã¬ã¤ããè¦ãã¦ããããã§ã¯ãªããã¨ãã©ãã¹ã¿ã¤ã«ã¬ã¤ãããã¯ããã¦ãããã¤ã³ãã³ããæ¹è¡ãä»ã®ã³ã¼ãã¨ä¸ä¸è´ã ã£ãããã¦ã³ã¼ãã¬ãã¥ã¼ã§ææãããããã¨ãã£ããã¨ãããã¾ããã
ã¬ãã¥ã¼ã§ã¯ã³ã¼ãã£ã³ã°ã¹ã¿ã¤ã«ãæ°ã«ããããããã£ã¨ä»ã®ãã¨ã«æ³¨æãæã£ã¦ã¬ãã¥ã¼ãããã¨ã«åã注ãããã®ã§ã³ã¼ããã©ã¼ããã¿ã¼ãå°å ¥ãã¦ã¿ããã¨ã«ãã¾ããã
ãã©ã¼ããã¿ã¼ã®é¸å®
Swiftã®ã³ã¼ããã©ã¼ããã¿ã¼ã¯ããã¤ãåå¨ãã¦ãã¾ãã
ã¾ãã¯è©¦ãã«cocoapodsã«å¯¾å¿ãã¦ãã¦å°å ¥ã楽ãªSwiftFormatã«ãã¦ã¿ã¾ããã
ãªãcocoapodsãããã£ããã¨ããã¨ããã©ã¼ããã¿ã¼ã®ã¤ã³ã¹ãã¼ã«ã¯homebrewãªã©ã使ã£ã¦åèªã®ç°å¢ã«ã¤ã³ã¹ãã¼ã«ããã¨ããæ段ãããã¾ãããè¤æ°äººã§éçºãè¡ãå ´åã«åèªã®ã¤ã³ã¹ãã¼ã«ãã¦ãããã¼ã¸ã§ã³ã«éããçºçããæããããã¾ããcocoapodsã«ãã¦ããã°ã¤ã³ã¹ãã¼ã«ããããã¼ã¸ã§ã³ãåºå®ãããã®ã§æå³ããªããã¼ã¸ã§ã³ã使ããã¦ãã¾ãã¨ãã£ãæãããªããªãã¡ãªãããããããã§ãã
è¨å®
cocoapodsã§ã¤ã³ã¹ãã¼ã«ãã¦ãDebug Configurationã§ãã«ãããéã«èªåã§ãã©ã¼ãããããããã«è¨å®ãã¦ããã¾ãã
Podfile
pod 'SwiftFormat/CLI', :configurations => ['Debug']
Project
Xcodeã®Target->Build Phasesã«ä»¥ä¸ã追å ãã¾ã
if [ $CONFIGURATION = "Debug" ]; then "${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" . fi
.swift
.swift-versionããªããã°ä½æãSwiftã®ãã¼ã¸ã§ã³ãè¨è¼ãã¾ãã
5.0
.swiftformat
.swiftformatã«ã«ã¼ã«ãè¨è¼ãããã¨ã§ããã©ã«ãã®ã«ã¼ã«ãå¤æ´ãããã¨ãã§ãã¾ãã
ããã©ã«ãã®ã«ã¼ã«ã®ã¾ã¾ã ã¨diffãããããã¨ã«ãªã£ãã®ã§ä»¥ä¸ã®ä¸é¨ã®ããã©ã«ãã®ã«ã¼ã«ãdisableã«ãã¾ããã
--disable trailingCommas, strongOutlets, unusedArguments, hoistPatternLet, blankLinesAroundMark
ãããã«
ãã®ããã«å°å ¥ã¯ãã£ããã¨ã§ãã¦ãã¾ãã®ã§ãæ°è»½ã«è©¦ããã®ã§ããããã§ãï¼
次åã¯swift-formatã®ä½¿ãæ¹ã«ã¤ãã¦ç´¹ä»ãããã¨æãã¾ããã楽ãã¿ã«ï¼