情况
我刚刚迁移到最新的 XCode12.4,因此我已将所有依赖项预编译为xcframeworks
. 现在我xcconfig
用来链接其中一些框架。我有一个应用程序,它使用了几个预编译xcframeworks
的 .
这是一个共享文件Dependencies/Frameworks.xcconfig
,可以轻松访问所有依赖项,并且与预编译的依赖项位于同一存储库中。
/// Path into xcode specific builds
FRAMEWORKS_PATH_12_4 = Frameworks/XCode12.4
FRAMEWORKS_PATH_11_5 = Frameworks/XCode11.5 // old path, obsolete
FRAMEWORKS_PATH_10_3 = Frameworks/XCode10.3 // old path, obsolete
/// All firebase related frameworks
FIREBASE_FRAMEMWORKS = -framework FirebaseAnalytics -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseCrashlytics -framework FirebaseInstallations -framework GoogleAppMeasurement -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb
/// Summary of all Frameworks provided by this repo
ALL_FRAMEWORKS = -framework ZipArchive -framework Alamofire -framework RxSwift -framework RxCocoa -framework RxRelay -framework Snapkit -framework SVGKit -framework Lottie -framework AudioKit -framework NSLoggerSwift $(FIREBASE_FRAMEMWORKS)
现在我的应用程序中的框架链接到 2 个框架,它看起来像这样
/// Include the dependency repo definitions
#include "../Dependencies/Frameworks.xcconfig"
/// Define this for the carthage build step
DEPENDENCIES_PATH[config=RC] = $(SRCROOT)/../Dependencies/$(FRAMEWORKS_PATH_12_4)
DEPENDENCIES_PATH[config=Release] = $(SRCROOT)/../Dependencies/$(FRAMEWORKS_PATH_12_4)
DEPENDENCIES_PATH[config=T1] = $(SRCROOT)/../Dependencies/$(FRAMEWORKS_PATH_12_4)
DEPENDENCIES_PATH[config=Debug] = $(SRCROOT)/../Dependencies/$(FRAMEWORKS_PATH_12_4)
/// Setup search paths
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEPENDENCIES_PATH)/**
/// Include required frameworks
OTHER_LDFLAGS = $(inherited) -framework Alamofire -framework ZipArchive
问题
现在,当我针对通用设备构建或存档时,一切都很好。但是当我为模拟器构建时,我得到了这个错误
Could not find module 'Alamofire' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7
我认为这是由于这里的递归搜索路径
/// Setup search paths
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEPENDENCIES_PATH)/**
当我删除递归搜索路径时,出现此错误
No such module 'Alamofire'
解决方法
似乎可行的方法是告诉编译器xcframework
像这样深入查看内部
/// Setup search paths
FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*] = $(inherited) $(DEPENDENCIES_PATH)/Alamofire.xcframework/ios-arm64_armv7 $(inherited) $(DEPENDENCIES_PATH)/ZipArchive.xcframework/ios-arm64_armv7
FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*] = $(inherited) $(DEPENDENCIES_PATH)/Alamofire.xcframework/ios-arm64_i386_x86_64-simulator $(DEPENDENCIES_PATH)/ZipArchive.xcframework/ios-arm64_i386_x86_64-simulator
但老实说,我在项目中有几十个依赖项,维护它非常乏味。
问题
我如何告诉我的框架xcconfig
文件它应该在正确的架构文件夹xcframework
中查找实际的framework
?