专栏首页iOS122-移动混合开发研究院简陋的swift carthage copy-frameworks 辅助脚本

简陋的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 */

所以,就像着,自动生成 inputPathsoutputPaths ,然后直接手动修改 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" ]
*/

参考:

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • BlocksKit初见:一个支持将delegate转换成block的Cocoa库

    简介 项目主页: https://github.com/zwaldowski/BlocksKit BlocksKit 是一个开源的框架,对 Cocoa 进行了扩...

    ios122
  • 实现iOS图片等资源文件的热更新化(零): 序

    必要的序 以后在写系列文章,准备把基本的规划和动机等,单独作为一个小的序言部分给独立出来.序言部分,可以较为完整地交待系列文章的写作动机,所展示的编码技术可能的...

    ios122
  • PBJVision 快速在应用中集成相机/拍摄功能

    PBJVision 简介 PBJVision, 是一个iOS相机操作的封装库,可以让你的应用快速简单地继承相机相关功能. 最新示例:点击下载 注意: 示例需要在...

    ios122
  • F-Stack Q&A 第二期

    Q1:请问再视频领域,媒体服务器,使用F-Stack是否合适? A1:F-Stack在纯推流的模式上是支持且合适的,如果有转码服务等计算密集型服务,需要等我们支...

    F-Stack
  • Spring Cloud Eureka

    注-第一个服务启动的时候存在java.net.ConnectException: Connection refused (Connection refused)...

    迹_Jason
  • Spark + Hadoop,基于WIFI探针的大数据分析系统

    本系统以Spark + Hadoop为核心,搭建了基于WIFI探针的大数据分析系统。

    机器学习AI算法工程
  • React高阶组件(译)

    本文作者:IMWeb zzbozheng 原文出处:IMWeb社区 未经同意,禁止转载 原文:https://daveceddia.com/extra...

    IMWeb前端团队
  • ant常见错误解决方案

    子勰
  • React高阶组件(译)

    原文:https://daveceddia.com/extract-state-with-higher-order-components/

    IMWeb前端团队
  • 准备数据集用于flink学习

    在学习和开发flink的过程中,经常需要准备数据集用来验证我们的程序,阿里云天池公开数据集中有一份淘宝用户行为数据集,稍作处理后即可用于flink学习;

    程序员欣宸

扫码关注云+社区

领取腾讯云代金券