BUG - addTargetDependency - If project doesn't contain PBXTargetDependency or PBXContainerItemProxy
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ios, javascript, nodejs
Hướng nghiên cứu
Bắt đầu trong lib/pbxProject.js tại addTargetDependency và kiểm tra bộ kiểm thử hiện có để xem mức độ bao phủ của addTarget hoặc addTargetDependency. Tái hiện trường hợp .xcodeproj chỉ có một Target mà không có PBXTargetDependency hoặc PBXContainerItemProxy, sau đó thêm một bài kiểm thử hồi quy. Công việc được hoàn tất khi các dependency được tạo hoặc xử lý chính xác và các kiểm thử hiện có vẫn vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
One Line Summary
addTargetDependency misses some dependency links if PBXTargetDependency or PBXContainerItemProxy are not present.
Affected Projects
Calls made to addTarget or addTargetDependency with any .xcodeproj that only has one target, these do NOT have PBXTargetDependency or PBXContainerItemProxy.
Details
The root cause
The following if statement in the addTargetDependency function skips the dependencies and other steps if it is missing.
https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
Possible fixes
Option 1 - Smallest number changes
A simple way to fix this would be to use short-circuit evaluation where these vars are assigned to handle null, undefined, or if no key exists when reading from hash.project.objects.
https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L834-L835
This could become the following to fix this issue:
pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency] || {},
pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy] || {};
I have tested this on some projects on my machine and was able to successfully run an App Extension on an iOS device to confirm the solution works.
Option 2 - Larger Refactor - Fix some clean up
Same fix as option 1, but clean up the hard coded strings.
- Put these at the top of the file:
const PBX_TARGET_DEPENDECY = "PBXTargetDependency";
const PBX_CONTAINER_ITEM_PROXY = "PBXContainerItemProxy";
- Use them here and remove the old vars:
const pbxTargetDependencySection = this.hash.project.objects[PBXTargetDependency] || {};
const pbxContainerItemProxySection = this.hash.project.objects[PBXContainerItemProxy] || {};
Workaround
// Add code anytime before calling addTarget or addTargetDependency
const projObjects = xcodeProject.hash.project.objects;
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
Related issues
PR #12 also made a note of this issue:
2.
addTargetDependency()is indirectly called as well fromproj.addTarget('AppExtension', 'app_extension'). In my project,PBXTargetDependencyandPBXContainerItemProxysections did not yet exist which results in the necessary dependencies not being set up properly for building the extension with the main app. Create these sections if they do not exist.
They attempted to fix this in a similar way I am suggesting with commit 2e09d78efdb1d667dd513a3c97c46dc448305f5f.
This PR was not merged however, so this is still an active issue.
There is another issue #37, that references PR #12, notes that targetDependency is still an issue.
Submitting a PR - Is this an active library?
It has been over a year since there has been a release or even a commit. If the maintainers could chime in I'd be happy to create one.
I have read the CONTRIBUTING.md guide, is there any more to it than that? I see there is a good number of tests, I'll make sure to add one to cover the code change. Lastly let me know which of the possible fixes you prefer or if you have another idea.
- Ngôn ngữ chính
- JavaScript
- Star
- 217
- Fork
- 102
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/cordova-node-xcode
-
Add & Improve JSDocs Đang mởenhancement
apache/cordova-node-xcode#171 · 1 người được giao ·
-
🔖 New release Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
apache/cordova-node-xcode#162 · 4 bình luận · 2 reaction ·
-
Install .xcframework Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 28/100
apache/cordova-node-xcode#139 · 2 bình luận ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
apache/cordova-node-xcode#138 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
apache/cordova-node-xcode#137 · 2 reaction ·
Tất cả issue của apache/cordova-node-xcode
Issue tương tự
-
Update HugeIcons library Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
antfu-collective/icones#398 ·
-
ECmail.com Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
wesbos/burner-email-providers#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
components-web-app/docs#92 ·