apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 986 forks source link

fix: Resolve Xcode stale files warnings #1496

Closed dpogue closed 1 month ago

dpogue commented 1 month ago

Platforms affected

iOS

Motivation and Context

Closes GH-1372.

Description

To get output app/ipa files in the expected places, we were overriding the SYMROOT value for command-line builds. However, this doesn't get applied when building in Xcode, and then it complains about "Stale files" in the Derived Data folder due to some things having been compiled with one SYMROOT value and others with a different one.

Setting SYMROOT is a hack anyways, what we really want to do is set an install path and force the app bundles to be installed into the destination folders after they are built. This allows Xcode to use the same Derived Data path for all builds, and avoids cluttering the Cordova destination folders with intermediate build artifacts.

Except, that we can't do this for iOS app bundles because changing the install path corrupts the xcarchives that are produced as part of exporting an ipa bundle. So we need to make all this INSTALL_PATH and DEPLOYMENT_ROOT stuff conditional based on whether we're building for a Simulator, Catalyst/macOS, or for a real iOS device.

Testing

Alternated building a project in both Xcode and command-line and ensured that there were no warnings about stale files.

(Note if you are trying this yourself, it needs to be a new project that has not been built already, otherwise you need to clean it to remove any existing stale files pre-dating this change)

Checklist

codecov-commenter commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.89%. Comparing base (92df3b7) to head (472d6bf).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1496 +/- ## ======================================= Coverage 80.89% 80.89% ======================================= Files 16 16 Lines 1842 1842 ======================================= Hits 1490 1490 Misses 352 352 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.