一些常用的工具性脚本和配置
程序员文章站
2024-02-21 17:09:22
...
-
下面的脚本用于自动将工程打包为一个二进制 Framework(用于私有 Framework 的二进制打包):
#!/bin/sh carthage build --no-skip-current path=$(dirname $0) path=${path/\./$(pwd)} path=${path##*/} echo $path carthage archive $path
-
一个简单的 Carthage 脚本, 用于自动下载和编译依赖:
#!/bin/sh carthage update --platform iOS --cache-builds --no-use-binaries
-
一个比较通用的 gitignore 文件:
# Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore ## Build generated build/ DerivedData/ ## Various settings *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata/ ## Other *.moved-aside *.xcuserstate ## Obj-C/Swift specific *.hmap *.ipa # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # Pods/ #Podfile.lock # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. Carthage/Checkouts Carthage/Build */Carthage/Checkouts */Carthage/Build # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md fastlane/report.xml fastlane/screenshots .DS_Store *.swp #.gitignore fastlane/README.md fastlane/test_output/report.html fastlane/test_output/report.junit *.framework.zip
-
一个适用于高度注重可维护性工程中 swiftlint 配置文件(借鉴若干资料, 并在两个生产工程中实践, 算法工程的话建议参考 Raywenderlich 网站的):
disabled_rules: # rule identifiers to exclude from running # - colon # - comma # - control_statement # - for_where # - force_unwrapping opt_in_rules: # some rules are only opt-in - empty_count - missing_docs - closure_end_indentation - closure_spacing # - force_unwrapping #- implicitly_unwrapped_optional - operator_usage_whitespace - redundant_nil_coalescing included: # 包含目录`--path` is ignored if present. - ./ excluded: # 排除目录, 这个是在包含目录之前进行排除的 - Carthage - Pods - Demo force_cast: warning # implicitly force_try: severity: warning # explicitly # 行宽 line_length: 120 # 类型体的长度 type_body_length: - 300 # warning - 400 # error # 方法或函数体的长度 function_body_length: 15 # 方法或函数的参数个数限制 function_parameter_count: 4 # 文件的长度限制 file_length: warning: 500 error: 600 # 代码单元结点分支个数 cyclomatic_complexity: warning: 5 error: 10 # 类型名称的长度规定 type_name: min_length: 2 # only warning max_length: # warning and error warning: 40 error: 50 excluded: iPhone # excluded via string # 标识符长度规定 identifier_name: min_length: # only min_length error: 2 # only error excluded: # excluded via string array - T reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)
-
在 Xcode 工程中配置 Carthage:
-
新建一个 Run Script, 添加内容:
/usr/local/bin/carthage copy-frameworks
另外如果想要在比如 debug 模式下才复制的话(比如使用 FLEX 的时候), 可以这样:
if [ "$CONFIGURATION" == "Debug" ]; then /usr/local/bin/carthage copy-frameworks fi
-
在其中的 input file 里面添加诸如下面的内容:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
-
同时对应在 output file 中添加如下类似如下内容:
$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework
-
-
配置 Swiftlint 的简单流程:
首先将需要的
.swiftlint.yml
配置文件写好, 放到想要进行语法检查的目录或根目录.-
新建一个 Run Script, 添加内容:
swiftlint swiftlint autocorrect
-
如果要打开或关闭某个语法检查功能:
// swiftlint:disable function_body_length // swiftlint:enable function_body_length
下一篇: 可能会用到的CSS样式