如何通过cli嵌入子项目框架?

How to embed sub-project frameworks through cli?

提问人:cj- 提问时间:6/20/2023 最后编辑:cj- 更新时间:6/21/2023 访问量:34

问:

我正在使用 Qt,它生成自己的 XCode 项目来制作 iOS 应用程序。对于这个应用程序,我想包括一个cocoapod依赖项(Sentry)。但是我不知道如何将子项目框架添加到主项目中。这可能吗?

以下是 Podfile 的安装和添加方式:

# 1. Copy a Podfile to the build directory.
pods.commands = cp $$PWD/ios/Podfile $$OUT_PWD/Podfile
# 2. Install the pod (without integration).
pods.commands += && cd $$OUT_PWD && /usr/local/bin/pod install
# 3. Add the Pods project to the main project.
pods.commands += && python3 -m pbxproj file \
    --target AgraGPS \
    $$shell_path($$OUT_PWD/AgraGPS.xcodeproj/project.pbxproj) \
    $$OUT_PWD/Pods/Pods.xcodeproj
    --sign-on-copy

还有 Podfile:

platform :ios, '11.0'

install! 'cocoapods',
    :integrate_targets => false

target 'AgraGPS' do
  use_frameworks!

  pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.8.0'
end

通常,当我想包含一个框架时,我会做这样的事情:

embed.commands = pip3 install pbxproj
embed.commands += && python3 -m pbxproj file \
    --target AgraGPS \
    $$shell_path($$OUT_PWD/AgraGPS.xcodeproj/project.pbxproj) \
    $$shell_path($$PWD/../Library/build/bin/Lib.framework) \
    --sign-on-copy
PRE_TARGETDEPS +=      embed
QMAKE_EXTRA_TARGETS += embed

但是我该如何参考这些框架呢?使用框架名称不起作用。我仍然可以通过 XCode 添加它,它运行良好。

Adding the dependency through XCode by going to General, Frameworks, Add

虽然我可以启用集成并创建工作区。尝试构建和运行工作区会导致更多我想避免的错误。

xcode qmake ios框架 pbxproj

评论


答:

0赞 cj- 6/21/2023 #1

能够通过首先构建 Pods 项目(而不是将其添加到主项目)来使其工作。比我能够正常嵌入框架。

embed.commands += && /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild install \
    -project $$shell_path(Pods/Pods.xcodeproj) \
    -destination generic/platform=iOS \
    -destination-timeout 1
debug {
    embed.commands += -configuration Debug
} else {
    embed.commands += -configuration Release
}
embed.commands = && python3 -m pbxproj file \
    --target AgraGPS \
    $$shell_path($$OUT_PWD/AgraGPS.xcodeproj/project.pbxproj) \
    $$shell_path($$OUT_PWD/build/Debug-iphoneos/Pod/Pod.framework) \
    --sign-on-copy
# Still need to add each framework individually
PRE_TARGETDEPS +=      embed
QMAKE_EXTRA_TARGETS += embed