-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: replace copy-www-build-step script with build phase #1158
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1158 +/- ##
=======================================
Coverage 74.86% 74.86%
=======================================
Files 13 13
Lines 1723 1723
=======================================
Hits 1290 1290
Misses 433 433 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to go through the bin/templates/project/__TEMP__.xcodeproj/project.pbxproj
diff and manually re-add all the quotation marks Xcode helpfully removed 🙄
Those are needed to support projects where __PROJECT_NAME__
contains spaces.
Fixed now. Good to know why they are there. I should have checked the diff again. These Xcode files are tricky. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been testing this locally, and it's actually copying the wrong files into Resources. It's pulling ../../config.xml
when it needs to pull the __PROJECT_NAME__/config.xml
file, and likewise with www
.
In Xcode, these are shown in a Staging group.
@dpogue How did you test that? What's the best way to reproduce this? I did quick tests and this www folder and config.xml look like the right one. I changed them to __Project_NAME/.. but then plugins won't work anymore because cordovas js files are missing. My test:
To me this looks like the right files get copied into the app. |
hmm, I was testing this as part of #1162 (which used this as a starting point) and getting "Connecting to device..." in the simulator, and log messages about the Console plugin not being found. This should work to reproduce:
|
This works fine for me. Is there another edge case where this could break? |
I'll try to poke at this a bit more today and see if I can figure out what was going wrong on my end |
I just tried the device plugin and indeed it gets stuck at deviceready with this errror:
I am not sure yet whats the issue. |
@@ -14,6 +14,8 @@ | |||
302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; }; | |||
302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; }; | |||
6AFF5BF91D6E424B00AB3073 /* CDVLaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */; }; | |||
857339E22710CC8900A1C74C /* config.xml in Copy config.xml */ = {isa = PBXBuildFile; fileRef = EB87FDF41871DAF40020F90C /* config.xml */; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the issue is that fileRef
here should be F840E1F0165FE0F500CFE078
to refer to __PROJECT_NAME__/config.xml
rather than ../../config.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we want the config.xml from the staging folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So probably the config copy is not origin of the plugin issue.
Interesting side fact. I just tried to run the osx platform on the M1 mac with this PR apache/cordova-osx#105 and got the same error:
|
Can’t we remove the duplicated www/config.xml and have a single one, that is what prepare command copies? I always found confusing having two, the staging one and the root one. |
The root one is the app developer-authored one, where they configure the app name, icons, preferences, and allow list. The root one is displayed in Xcode for convenience of the app developer if they are working in the native project, to make edits to config.xml (and www) and not have those changes overwritten when running The staging one must be in Xcode to be handled as a resource for copying into the app bundle. So I don't think we can get rid of either of them, despite how confusing it is to have both 😞 |
- Combined "Copy www" & "Copy config.xml" into "Copy Staging Resources" - Copy content from "Staging" group into Resources
@dpogue I have updated this PR to properly copy the correct content as well as simplify the build process. This PR is strictly focused on copying the app resources to the correct location. I have combined the build phases The contents of the "Staging" group are, The location of these resources come from:
And these are what Additionally, the combine build phase is not blindly copying an entire grouping. If users add things to that group, they would still need to update the build phase to include those items to be copied. I think from a Cordova perspective, users should not add anything to this grouping anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this (including with Catalyst) and it is working as expected. Also tested with cordova-plugin-device added, and was able to print out device information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @erisu for completing this and your good explanation. It's working as espected for me as well with all Mac configurations and an iOS simulator.
…#1158) * (refactor): move copy-www-build-step script to Xcode commands See apache#699 * select files to copy * copy config.xml from staging * feat: copy staging resources - Combined "Copy www" & "Copy config.xml" into "Copy Staging Resources" - Copy content from "Staging" group into Resources Co-authored-by: Erisu <erisu@apache.org>
Platforms affected
iOS and Mac (Catalyst)
Motivation and Context
We could move the build step of copying the www directory and config.xml to the Xcode "Copy files" commands to avoid issues from the manual script like changed paths or different paths between iOS and macOS.
See #699
Description
Up for discussion.
Some links: #699 (comment)
This is probably the most important reason for the script: https://issues.apache.org/jira/browse/CB-5397?focusedCommentId=13859057&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13859057
Testing
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)