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

vtwuwzda  于 2023-06-24  发布在  其他
关注(0)|答案(1)|浏览(78)

我正在使用Qt,它生成自己的XCode项目来制作iOS应用程序。对于这个应用程序,我想包括一个cocoapod依赖(哨兵)。但是我不知道如何将子项目框架添加到主项目中。这可能吗?
以下是如何安装和添加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添加它,它工作得很好。

尽管我可以启用集成并创建工作区。尝试构建和运行工作区会导致更多我希望避免的bug。

ryoqjall

ryoqjall1#

能够通过首先构建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

相关问题