apache / apache/cordova-node-xcode

pbxProject.prototype.addFramework: automatically create Frameworks Group if it does not exist

未关闭
#28 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
217
派生
102
平均合并
2 天 3 小时
30 天内合并 PR
6

描述

**This is a feature proposal**

**Initial Situation**:

Your xcode project tree looks like this:
bildschirmfoto 2018-12-09 um 22 28 11

You have a Xcode project without a `Framworks` group and you want to add a new framework using `pbxProject.prototype.addFramework`.

**Current behaviour**:

The `Frameworks` group is created but not added to the `mainGroup` of the project which references all files (that are not part of a subgroup) and all groups (that are no subgroups).

If you open the updated xcode project with xcode you see the following:

bildschirmfoto 2018-12-09 um 22 15 28

This is because xcode cannot find a reference to the `Frameworks` group on the `mainGroup` and therefore "autofixes" the project by adding the library added with `pbxProject.prototype.addFramework` to a newly generated group `Recovered References`.

**Expected behaviour**:

The `Framework` group is created and also automatically added to the `mainGroup`.

When you open the project in xcode it should look like this:

bildschirmfoto 2018-12-09 um 22 23 26

**Current workaround:**

Add the `Frameworks` group to `mainGroup`manually:

```js
const project = xcode.project(projectPath);
project.parseSync();

project.addFramework(path.resolve(frameworksDirectory, 'GoogleInterchangeUtilities.framework'), {
customFramework: true,
embed: true,
link: true,
});

const mainProject = project.getPBXGroupByKey(project.getFirstProject().firstProject.mainGroup);
if (!mainProject.children.some(children => children.comment === 'Frameworks')) {
const [groupKey] = Object.entries(project.hash.project.objects['PBXGroup']).find(
([, group]) => group.name === 'Frameworks',
);
project.addToPbxGroup(groupKey, project.getFirstProject().firstProject.mainGroup);
}
```

If you are okay with this feature proposal I would love to implement it!

贡献指南

打开贡献指南

调研方向

从 pbxProject.prototype.addFramework 开始,跟踪 Frameworks 组和 project mainGroup 的处理方式。使用 issue 中的 workaround 作为行为参考。当缺失的 Frameworks 组既被创建又被 mainGroup 引用,从而使 Xcode 不将 framework 放入 Recovered References 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
ios, javascript, nodejs
领域
mobile
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。