xcodebuild exportArchive undefined method downcase for nil:NilClass

Posted

技术标签:

【中文标题】xcodebuild exportArchive undefined method downcase for nil:NilClass【英文标题】: 【发布时间】:2017-03-21 15:55:04 【问题描述】:

我在尝试导出存档时看到此错误:

2017-03-08 16:33:01.413 xcodebuild[61048:2742229] [MT] IDEDistribution: Step failed: <IDEDistributionThinningStep: 0x7fe3d72312f0>: Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo=NSLocalizedDescription=No applicable devices found.
error: exportArchive: No applicable devices found.

Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found." UserInfo=NSLocalizedDescription=No applicable devices found.

我没有做任何应用瘦身:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>enterprise</string>
    <key>teamID</key>
    <string>MYTEAMID</string>
    <key>thinning</key>
    <string>&lt;none&gt;</string>
    <key>uploadBitcode</key>
    <false/>
</dict>
</plist>

当我查看这里提到的目录时:

2017-03-21 08:47:20.275 xcodebuild[24493:1421657] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/36/28z3md3x08xcljbsh6tvv4xrcr93wf/T/UniversalFree_2017-03-21_08-47-20.274.xcdistributionlogs'.

我在IDEDistribution.standard.log 中看到了这个错误

2017-03-21 15:47:25 +0000  Scanning IPA...
2017-03-21 15:47:48 +0000  /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:2341:in `platformIdentifierForVersionMinLoadCommand': undefined method `downcase' for nil:NilClass (NoMethodError)
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1236:in `block in GetMachOImagesFromOToolInfoForFile'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1196:in `each'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1196:in `GetMachOImagesFromOToolInfoForFile'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1294:in `MakeFileSystemNode'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1322:in `block in MakeFileSystemNode'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1321:in `each'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1321:in `MakeFileSystemNode'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1322:in `block in MakeFileSystemNode'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1321:in `each'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1321:in `MakeFileSystemNode'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1085:in `initialize'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1871:in `new'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:1871:in `ProcessIPA'
        from /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool:2428:in `<main>'
2017-03-21 15:47:49 +0000 [MT] /Applications/Xcode-7.app/Contents/Developer/usr/bin/ipatool exited with 1

然后导出失败。我该如何处理?

【问题讨论】:

【参考方案1】:

回答我自己的问题,因为我无法在网上找到直接的答案。虽然我并不完全清楚造成这种情况的原因,但堆栈跟踪表明问题出现在ipatool 中的GetMachOImagesFromOToolInfoForFile 中。似乎期望它处理的每个项目的loadCommands 将具有LC_VERSION_MIN_(.+) 形式的密钥,但似乎并非所有项目都是这种情况(如果有人可以确定原因并更新此答案,很多赞赏)。无论如何,您可以对ipatool 进行以下修改以“修复”此问题(新文件是左侧文件)。

TL/DR:编辑/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool

对于 Xcode 7...

608,610d607
<     if (self.machoFile == nil)
<       return "<MachOImage nil #self.arch>"
<     end
1239,1242d1235
<     if (versionMinLoadCommandName == nil)
<       next
<     end
1302c1295
<       if (machoImages && machoImages.length > 0)
---
>       if machoImages

对于 Xcode 8...

750,752d749
<     if (self.machoFile == nil)
<       return "<MachOImage nil #self.arch>"
<     end

1438,1440d1434
<     if (versionMinLoadCommandName == nil)
<       next
<     end
1510c1504
<       if (machoImages && machoImages.length > 0)
---
>       if machoImages

【讨论】:

以上是关于xcodebuild exportArchive undefined method downcase for nil:NilClass的主要内容,如果未能解决你的问题,请参考以下文章

Xcode 9:xcodebuild -exportArchive 错误读取文件:info.plist

xcodebuild exportArchive undefined method downcase for nil:NilClass

Xcode Server Bot 集成在 xcrun xcodebuild -exportArchive "Exporting installable product" 上停止

xcodebuild exportarchive:“AppStore 配置文件”不是“iOS 应用程序开发”配置文件

将 -exportArchive 与未签名存档一起使用时,是不是可以指定权利文件?

xcodebuild archive 导出ipa包