I’m in the middle of moving my iOS app’s Firebase dependency from CocoaPods to Swift Package Manager.
Firebase’s Crashlytics requires a script to be executed while the app is building (using the Run Script build phase). Back in the CocoaPods days, I used to call the script the way documented by Google: "${PODS_ROOT}/FirebaseCrashlytics/run"
.
After I’ve switched to SPM, Firebase files are no longer in ${PODS_ROOT}
, and there’s no such variable available at all. I know the file I need is now located in the DerivedData
folder, specifically it’s at ~/Library/Developer/Xcode/DerivedData/MyApp-abcde/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
. The problem is, the MyApp-abcde
folder is not easily referenced.
A Medium post I found suggested using the ${BUILD_DIR}
build variable (in regard to the example above, it would resolve to <…>/MyApp-abcde/Build/Products
), and calling the dirname
command to move up the directory hierarchy.
This hack worked only for running the app. When I tried to archive it, ${BUILD_DIR}
resolved to another path, namely <…>/MyApp-abcde/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath
. I tried a few more build variables, such as ${SYMROOT}
, in place of ${BUILD_DIR}
, but they also produce different paths depending on the operation.
So, here comes the question…
Is there a way to reliably reference my app’s derived data folder’s root (i.e. ~/Library/Developer/Xcode/DerivedData/MyApp-abcde
) using Xcode’s build variables?
DerivedData is a folder located in ~/Library/Developer/Xcode/DerivedData by default. It's the location where Xcode stores all kinds of intermediate build results, generated indexes, etc. DerivedData location can be configured in Xcode preferences (Locations tab). So now and then you run into odd build problems.
Delete Derived DataChoose Window -> Organizer. Select the Projects tab. Select your project on the left. Next to the Derived Data line, there click the Delete button.
Xcode can often do some strange things that causes build problems etc. One of the go to methods to try and fix these issues is to delete derived data.
Typically, you won't have to worry about the data inside the AppData folder – that is why it is hidden by default. It is only used by application developers to store the necessary data required by the application. Everyday Windows users will only need to access or view the AppData folder if they need to create a backup of their application data.
There are two ways you can access the AppData folder. You can either access it manually or by using the "AppData" variable name. You can view the AppData folder manually by going into your Users folder, which is there in the C drive. In my case, the path is C:UsersADMIN.
iOS apps store data locally in different ways like plist(similar to shared_pref in android), NSUserDefaults, Core data(sqlite), Keychain. Theses files can be found using any file explorer utility under the application folder. No, that folder doesn't exist by default under iOS unless you (or somebody else) created it.
The Roaming folder is used to store data that will be synced across multiple Windows systems. This is often used for storing settings like bookmarks, saved passwords, and so on. There are two ways you can access the AppData folder. You can either access it manually or by using the "AppData" variable name.
You were close. This should work:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
Crashlytics run script
To build&run from Xcode:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
To archive for distribution from Xcode Server at CI/CD:
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
To work for both at the same time:
if [[ "${XCS_DERIVED_DATA_DIR}" == "" ]]; then
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
else
${XCS_DERIVED_DATA_DIR%/*}/Dependencies/checkouts/firebase-ios-sdk/Crashlytics/run
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With