在监视目标中使用 fastlane 和可可豆荚进行构建的问题

Posted

技术标签:

【中文标题】在监视目标中使用 fastlane 和可可豆荚进行构建的问题【英文标题】:Problem with building with fastlane and cocoa pods in a watch-target 【发布时间】:2020-06-25 09:35:57 【问题描述】:

在我们的项目中,我们有 3 个白标。我们为这些目标中的每一个添加了一个配套的手表应用程序(带有扩展名)。到目前为止一切顺利。

现在我要集成的新目标不是我们的 pod 文件。为了便于修改,我创建了一个伪继承结构:

# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'


def base_pods
  # Pods for App
  pod 'SwiftLint', '0.39.2'
  pod 'JWTDecode', '2.4.1'
  ...
end

def base_app_pods
  platform :ios, '11.0'

  base_pods

  # Pods for the Phone App
  ...
end

def base_watch_pods
  platform :watchos, '6.2'

  base_pods

  # Pods for the Watch App
  ...
end

def tests
  unit_tests
  ui_tests
end

def unit_tests
  target 'UnitTests' do
    inherit! :search_paths
    ...
  end
end

def ui_tests
  target 'UITests' do
    inherit! :search_paths
    base_app_pods
    ...
  end
  target 'OtherUITests' do
    inherit! :search_paths
    base_app_pods
    ...
  end
end

target 'Target1' do
  base_app_pods
  tests
end

target 'Target2' do
  base_app_pods
end

target 'Target3' do
  base_app_pods
end

target 'Target1 Watch Extension' do
  base_watch_pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "SpecificPod"
      target.build_configurations.each do |config|
        config.build_settings['ENABLE_BITCODE'] = 'NO'
      end
    end
    target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '5.0'
    end
  end
  installer.pods_project.build_configurations.each do |config|
    if config.name == 'Release'
      config.build_settings['ARCHS'] = 'arm64'
    end
  end
end

我跑了pod install,它跑了过去。然后我用 Xcode 构建了这个应用程序,它也陷入了低谷。

但后来我尝试使用fastlane gym 运行它。我们的车道看起来像这样

desc "build app"
lane :buildApp do
  gym(
    workspace: ENV['WORKSPACE'],
    scheme: ENV['SCHEME'],
    export_options: ENV['PATH_TO_EXPORT_OPTIONS']
  )
end

在像这样构建时,我收到了这个错误:

[10:41:46]: ▸ ⚠️  ld: directory not found for option '-F/Users/user/Library/Developer/Xcode/DerivedData/Target1-csmvfsiijdtrxkeiafycryotnjmz/Build/Intermediates.noindex/ArchiveIntermediates/Target1/BuildProductsPath/Release-watchos/JWTDecode-watchOS'
[10:41:46]: ▸ ⚠️  ld: directory not found for option '-F/Users/user/Library/Developer/Xcode/DerivedData/Target1-csmvfsiijdtrxkeiafycryotnjmz/Build/Intermediates.noindex/ArchiveIntermediates/Target1/BuildProductsPath/Release-watchos/KeychainAccess-watchOS'
[10:41:46]: ▸ ❌  ld: framework not found JWTDecode
[10:41:46]: ▸ ❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)

任何想法,可能导致此问题和/或如何解决此问题?

Xcode 版本:11.5 Fastlane 版本:2.149.1 Cocoapods 版本:1.9.1

【问题讨论】:

好的,我尝试在 Xcode 中存档,结果同样的错误。所以它可能与 Fastlane 无关。 【参考方案1】:

好的,我修复了它,购买删除了观察目标的硬设置架构:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "SpecificPod"
      target.build_configurations.each do |config|
        config.build_settings['ENABLE_BITCODE'] = 'NO'
      end
    end
    if target.name.include?("Watch") || target.name.include?("watchOS")
      isWatch = true
    end
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.0'
      if config.name == 'Release' && !isWatch
        config.build_settings['ARCHS'] = 'arm64'
      end
    end
  end
end

【讨论】:

以上是关于在监视目标中使用 fastlane 和可可豆荚进行构建的问题的主要内容,如果未能解决你的问题,请参考以下文章

无法使用可可豆荚归档 xcode 中的构建

带有可可豆荚的 GHUnit

使用带有可可豆荚的本机反应时发出警告

尝试在 Swift 项目中使用 Objective C 可可豆荚,桥接文件编译为 Swift 代码

使用可可豆荚的 Parse 1.7.1 中缺少 PFImageView

由于可可豆荚中的内部保护错误快速类功能而无法访问