Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access my app’s derived data folder itself?

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?

like image 468
Yakov Manshin Avatar asked Oct 29 '20 19:10

Yakov Manshin


People also ask

Where can I find derived data?

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.

Can I delete derived data folder?

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.

Should I delete derived data Xcode?

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.

Why is the appdata folder hidden by default?

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.

How do I access appdata folder?

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.

Where do iOS apps store data?

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.

What is the difference between AppData and roaming folder?

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.


2 Answers

You were close. This should work:

${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
like image 192
Mofawaw Avatar answered Oct 17 '22 07:10

Mofawaw


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
like image 24
Fatih Aksu Avatar answered Oct 17 '22 07:10

Fatih Aksu