安装 cocoa pod 后出现“ld: directory not found for option”构建错误

Getting `ld: directory not found for option` build error after installing cocoa pod

我为我的 Xcode 项目安装了一个新的 cocoa pod (LaunchDarkly),但是在尝试构建项目时我的 CI 服务器出现以下错误:

⚠️  ld: directory not found for option '-F/Users/runner/Library/Developer/Xcode/DerivedData/ProjectName-hlaqakonueydmsgzoxgekwjpjyds/Build/Products/Debug-iphonesimulator/LDSwiftEventSource'

⚠️  ld: directory not found for option '-F/Users/runner/Library/Developer/Xcode/DerivedData/ProjectName-hlaqakonueydmsgzoxgekwjpjyds/Build/Products/Debug-iphonesimulator/LaunchDarkly'

❌  ld: framework not found LDSwiftEventSource
❌  clang: error: linker command failed with exit code 1 (use -v to see invocation)

我该如何解决这个问题?

我意识到问题是我仍在构建 .xcodeproj 文件,如下所示:

xcodebuild build-for-testing
        -project ProjectName.xcodeproj
        -scheme ProjectName
        -destination 'platform=iOS Simulator,name=iPhone 12,OS=latest'
        -testPlan UnitTests
        | xcpretty

但是因为我现在在我的项目中使用 cocoa pods,所以我需要使用 .xcworkspace file 来构建它:

xcodebuild build-for-testing
        -workspace ProjectName.xcworkspace
        -scheme ProjectName
        -destination 'platform=iOS Simulator,name=iPhone 12,OS=latest'
        -testPlan UnitTests
        | xcpretty