【问题标题】:xcodebuild archive failure: picking the wrong SDK?xcodebuild 存档失败:选择错误的 SDK?
【发布时间】:2020-09-10 22:36:13
【问题描述】:

我正在使用 fastlane 发布应用程序。构建应用程序的简化版 xcodebuild 命令如下:

xcodebuild -workspace App.xcworkspace -scheme App 
           -configuration Release -sdk iphoneos13.6 
           -destination 'generic/platform=iOS' clean archive

给出失败(添加样本):

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
 ^
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/symbolize.cc:55:
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/utilities.h:73:
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/base/mutex.h:141:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/pthread.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:33:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
 ^

我看到它正在选择 MacOSX.sdk,我希望它选择 Xcode 目录中存在的 iPhoneOS sdk。这是失败的原因吗?还是别的什么?

xcrun 输出:

» xcrun --show-sdk-platform-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform

» xcrun --sdk iphoneos --show-sdk-platform-path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform

【问题讨论】:

  • 项目使用的 Base SDK 是什么?查看构建设置并搜索 SDK
  • @puio Base SDK 是 iOS

标签: ios xcode xcodebuild fastlane


【解决方案1】:

Xcode 正在使用/Library/CommandLineTools 中的 SDK。相反,它应该使用 Xcode 应用程序中的那些。运行

 xcode-select -r

xcode-select -s "/Applications/Xcode.app/Contents/Developer"

验证人

xcode-select -p

其中一些可能需要sudo

【讨论】:

    【解决方案2】:
    xcodebuild -workspace App.xcworkspace -scheme App 
               -configuration Release -sdk iphoneos
               -destination 'generic/platform=iOS' clean archive
    

    xcodebuildman page

    -sdk [<sdkfullpath> | <sdkname>]
               Build an Xcode project or workspace against the specified SDK,
               using build tools appropriate for that SDK. The argument may be an
               absolute path to an SDK, or the canonical name of an SDK.
    
    1. 使用xcrun --sdk iphoneos --show-sdk-path检查SDK路径。
    2. 检查您的 Mac 中的 SDK。在我的 Mac 中,有 iPhoneOS.sdkiPhoneOS13.7.sdk
    • iPhoneOS13.7.sdk 是一个符号链接,它的来源是iPhoneOS.sdk
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.7.sdk
    

    另外,

    • 你也可以使用xcodebuild -showsdks查看所有的sdks
    • 不同设备的不同参数
      • iOS:-sdk iphoneos
      • 模拟器:-sdk iphonesimulator
      • watchOS:-sdk watchos
      • macOS:-sdk macosx

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 1970-01-01
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      相关资源
      最近更新 更多