简陋的swift carthage copy-frameworks 辅助脚本
Posted iOS122
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简陋的swift carthage copy-frameworks 辅助脚本相关的知识,希望对你有一定的参考价值。
在看 carthage 时,其中需要配置一个 copy-frameworks 脚本,此脚本特殊的地方,需要手动填写 Input Files 和 Output Files.一个一个填写,很糟心~
观察了下,对应修改的是 xxx.xcodeproj/project.pbxproj 中这个文本文件的特定位置的字段,类似于:
/* Begin PBXShellScriptBuildPhase section */
750D68EC2000817C006235CD /* ShellScript */ =
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(SRCROOT)/Carthage/Build/ios/Alamofire.framework",
);
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/local/bin/carthage copy-frameworks";
;
/* End PBXShellScriptBuildPhase section */
所以,就像着,自动生成 inputPaths 和 outputPaths ,然后直接手动修改 project.pbxproj 文件,试了下,可行.简单 nodejs 脚本如下:
var glob = require("glob")
// options is optional
let frameWorks = glob.sync("**/*.framework",
cwd: "path/to/Carthage/Build/iOS/",
)
console.log(frameWorks)
let inputPaths = frameWorks.filter(p=>!p.includes("test")&&!p.includes("Test")).map((p)=>`$(SRCROOT)/Carthage/Build/iOS/$p`)
let outputPaths = frameWorks.filter(p=>!p.includes("test")&&!p.includes("Test")).map((p)=>`$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$p`)
console.log(inputPaths)
console.log(outputPaths)
/*
控制台的单引号,要手动全局替换为双引号.
[ "$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework",
"$(SRCROOT)/Carthage/Build/iOS/Bond.framework",
"$(SRCROOT)/Carthage/Build/iOS/Differ.framework",
"$(SRCROOT)/Carthage/Build/iOS/HEXColor.framework",
"$(SRCROOT)/Carthage/Build/iOS/KeychainAccess.framework",
"$(SRCROOT)/Carthage/Build/iOS/Kingfisher.framework",
"$(SRCROOT)/Carthage/Build/iOS/Lottie.framework",
"$(SRCROOT)/Carthage/Build/iOS/Moya.framework",
"$(SRCROOT)/Carthage/Build/iOS/ObjectMapper.framework",
"$(SRCROOT)/Carthage/Build/iOS/PKHUD.framework",
"$(SRCROOT)/Carthage/Build/iOS/ReactiveKit.framework",
"$(SRCROOT)/Carthage/Build/iOS/ReactiveMoya.framework",
"$(SRCROOT)/Carthage/Build/iOS/ReactiveSwift.framework",
"$(SRCROOT)/Carthage/Build/iOS/Realm.framework",
"$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework",
"$(SRCROOT)/Carthage/Build/iOS/Result.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxBlocking.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxCocoa.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxMoya.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxSwift.framework",
"$(SRCROOT)/Carthage/Build/iOS/SideMenu.framework",
"$(SRCROOT)/Carthage/Build/iOS/SnapKit.framework",
"$(SRCROOT)/Carthage/Build/iOS/SwiftyTimer.framework" ]
[ "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Bond.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Differ.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/HEXColor.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/KeychainAccess.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Kingfisher.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Lottie.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Moya.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ObjectMapper.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/PKHUD.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactiveKit.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactiveMoya.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ReactiveSwift.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Realm.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RealmSwift.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Result.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxBlocking.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxCocoa.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxMoya.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxSwift.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SideMenu.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SnapKit.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SwiftyTimer.framework" ]
*/
参考:
以上是关于简陋的swift carthage copy-frameworks 辅助脚本的主要内容,如果未能解决你的问题,请参考以下文章
将 swift 更新到 4.0 版后 Carthage Build 失败
Swift 3 会破坏与 Carthage 集成的动态框架吗?
SwiftyJson 无法导入在 3.0.2 中使用 Carthage 编译的 Swift 3.1 模块中
通过带有 Swift 支持的 Carthage 将 MailCore2 添加到 Xcode