服务器之家

服务器之家 > 正文

简陋的swift carthage copy-frameworks 辅助脚本代码

时间:2021-01-09 17:55     来源/作者:iOS122

在看 carthage 时,其中需要配置一个 copy-frameworks 脚本,此脚本特殊的地方,需要手动填写 Input Files 和 Output Files.一个一个填写,很糟心~

观察了下,对应修改的是 xxx.xcodeproj/project.pbxproj 中这个文本文件的特定位置的字段,类似于:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* 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 脚本如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 辅助脚本代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://www.cnblogs.com/ios122/p/8284898.html

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部