apache / apache/cordova-node-xcode

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

オープン
#28 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
217
フォーク
102
平均マージ
2日 3時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。