如何访问我的应用程序的派生数据文件夹本身? [英] How to access my app’s derived data folder itself?
问题描述
我正在将iOS应用的Firebase依赖关系从CocoaPods转移到Swift Package Manager.
Firebase的Crashlytics要求在构建应用程序时执行脚本(使用运行脚本"构建阶段).在CocoaPods时代,我曾经使用 Google记录的方式来调用脚本:" $ {PODS_ROOT}/FirebaseCrashlytics/run"
.
切换到SPM后,Firebase文件不再位于 $ {PODS_ROOT}
中,并且根本没有此类变量.我知道我现在需要的文件位于 DerivedData
文件夹中,特别是位于〜/Library/Developer/Xcode/DerivedData/MyApp-abcde/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
.问题是 MyApp-abcde
文件夹不容易引用.
我发现的中级帖子建议使用 $ {BUILD_DIR}
构建变量(对于上面的示例,它将解析为<…>/MyApp-abcde/Build/Products
),并调用 dirname
命令以向上移动目录层次结构.
此hack仅适用于运行该应用.当我尝试对其进行存档时, $ {BUILD_DIR}
解析到了另一条路径,即<…>/MyApp-abcde/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath
.我尝试了其他一些构建变量,例如 $ {SYMROOT}
来代替 $ {BUILD_DIR}
,但是根据操作的不同,它们也会产生不同的路径.>
那么,问题来了……
是否可以使用以下方式可靠地引用我的应用程序的派生数据文件夹的根(即〜/Library/Developer/Xcode/DerivedData/MyApp-abcde
)Xcode的构建变量?
您已经关闭.这应该起作用:
$ {BUILD_DIR%Build/*} SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
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?
You were close. This should work:
${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
这篇关于如何访问我的应用程序的派生数据文件夹本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!