Xcode 9 无法使用 pod 构建 Swift 4 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44780972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 9 fails to build Swift 4 project with pod
提问by Nick Gaens
When attempting to build my Swift 4 project in Xcode 9 beta 2, some code signing error occurs after which the build of my app is discontinued.
尝试在 Xcode 9 beta 2 中构建我的 Swift 4 项目时,发生了一些代码签名错误,之后我的应用程序的构建停止了。
The error that is shown in Xcode:
Xcode 中显示的错误:
/usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements '/Users/nickgaens/Library/Developer/Xcode/DerivedData/Emprova_Swift-bbvmoytlhlbqpueyftstselvwhdj/Build/Products/Debug-iphonesimulator/Emprova GPS Swift.app/Frameworks/Alamofire.framework'
/Users/nickgaens/Library/Developer/Xcode/DerivedData/Emprova_Swift-bbvmoytlhlbqpueyftstselvwhdj/Build/Products/Debug-iphonesimulator/Emprova GPS Swift.app/Frameworks/Alamofire.framework: No such file or directory
As you might notice, the --sign
argument is followed by a single -
character.
您可能会注意到,--sign
参数后跟一个-
字符。
My setup:
我的设置:
- Xcode 9 beta 2 (9M137d) with its bundled Swift 4-version
- Cocoapods v1.2.1 with Podfile
- Xcode 9 beta 2 (9M137d) 及其捆绑的 Swift 4 版本
- 带有 Podfile 的 Cocoapods v1.2.1
platform :ios, '10.0'
target 'Emprova GPS Demo Swift' do
use_frameworks!
pod 'Alamofire', '~> 4.5.0'
pod 'AlamofireNetworkActivityIndicator', '~> 2.2.0'
pod 'KeyClip'
pod 'Localize-Swift', '~> 1.7.1'
pod 'FMDB'
end
target 'Emprova GPS Swift' do
use_frameworks!
pod 'Alamofire', '~> 4.5.0'
pod 'AlamofireNetworkActivityIndicator', '~> 2.2.0'
pod 'KeyClip'
pod 'Localize-Swift', '~> 1.7.1'
pod 'FMDB'
end
- I didn't change a single letter of any of the added pods files.
- I opened
Pods.xcodeproj
to check and double checkBuild Settings
-Code Signing Identitiy
of the Alamofire pod/target, but it is set toDon't Code Sign
. - I already checked my Keychain Access app to see if the
Apple Worldwide Developer Relations Certification Authority
wasn't expired (it isn't) and is marked as trusted (it is). - I already emptied the DerivedData directory multiple times (
~/Library/Developer/Xcode/DerivedData
) and performed aClean
(both viaCmd+K
andCmd+Alt+Shift+K
to no avail. - I already attempted to set the Xcode 'Command Line Tools' (
Preferences
-Locations
-Command Line Tools
) to bothXcode 8.3.3 (8E3004b)
andXcode 9.0 (9M137d)
to no avail.
- 我没有更改任何添加的 pods 文件的单个字母。
- 我打开
Pods.xcodeproj
来检查,并仔细检查Build Settings
-Code Signing Identitiy
在Alamofire荚/目标的,但它被设置为Don't Code Sign
。 - 我已经检查了我的 Keychain Access 应用程序,看看
Apple Worldwide Developer Relations Certification Authority
它是否没有过期(它不是)并且被标记为受信任(它是)。 - 我已经多次清空 DerivedData 目录 (
~/Library/Developer/Xcode/DerivedData
) 并执行了一次Clean
(通过Cmd+K
和Cmd+Alt+Shift+K
都无济于事。 - 我已经尝试将 Xcode 的“命令行工具”(
Preferences
-Locations
-Command Line Tools
)设置为两者Xcode 8.3.3 (8E3004b)
,Xcode 9.0 (9M137d)
但无济于事。
Completely ran out of ideas after having spent multiple hours searching for a solution. Does anyone have a clue why Xcode 9 no longer builds my project?
在花了几个小时寻找解决方案后,完全没有想法。有没有人知道为什么 Xcode 9 不再构建我的项目?
Also, link to my issue on Alamofires GitHub page, for the sake of completeness: #2183.
另外,为了完整起见,链接到我在 Alamofires GitHub 页面上的问题:#2183。
采纳答案by Nick Gaens
I found out what's wrong! Xcode continued using the .xcodeproj
file to open my project when selecting it on the welcome screen, but Cocoapods
requires the .xcworkspace
file to be used! There's a visual distinction between both entries on Xcode's Welcome screen afterwards: difference between Xcode workspace and project on Welcome screen.
我发现出了什么问题!.xcodeproj
在欢迎屏幕上选择它时,Xcode 继续使用该文件打开我的项目,但Cocoapods
需要使用该.xcworkspace
文件!之后 Xcode 的欢迎屏幕上的两个条目之间存在视觉区别:欢迎屏幕上的Xcode 工作区和项目之间的区别。
Opening the workspace shows two projects in Xcode's Project Navigator
: one for my app and a second one named Pods
, which embodies all installed pods. Building the app no longer shows weird build errors.
打开工作区会显示 Xcode 中的两个项目Project Navigator
:一个用于我的应用程序,另一个名为Pods
,它包含所有已安装的 pod。构建应用程序不再显示奇怪的构建错误。