Xcode 9 fails to build Swift 4 project with pod

拟墨画扇 提交于 2019-12-01 04:05:14

问题


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.

The error that is shown in 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.

My setup:

  • Xcode 9 beta 2 (9M137d) with its bundled Swift 4-version
  • Cocoapods v1.2.1 with Podfile
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 check Build Settings - Code Signing Identitiy of the Alamofire pod/target, but it is set to Don'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 a Clean (both via Cmd+K and Cmd+Alt+Shift+K to no avail.
  • I already attempted to set the Xcode 'Command Line Tools' (Preferences - Locations - Command Line Tools) to both Xcode 8.3.3 (8E3004b) and Xcode 9.0 (9M137d) to no avail.

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?

Also, link to my issue on Alamofires GitHub page, for the sake of completeness: #2183.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/44780972/xcode-9-fails-to-build-swift-4-project-with-pod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!