4

我真的很想使用 Carthage 来安装 Alamofire 和 SwiftJSON,但我无法让它工作。每次构建都失败。

这是我的 Cartfile(指向 Xcode 6.3 的正确分支):

github "Alamofire/Alamofire" "xcode-6.3"
github "SwiftyJSON/SwiftyJSON" "xcode6.3"

Alamofire 无法构建并出现以下错误:

error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /ur/bin/gcc-4.2 -v -E -dM -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1" UserInfo=0x7fbfb9e4d5d0 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /ur/bin/gcc-4.2 -v -E -dM -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2015-02-18 23:15:51.859 xcodebuild[53900:6388252] Warning:  Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /ur/bin/gcc-4.2
Reason:   /ur/bin/gcc-4.2 -v -E -dM -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1
2015-02-18 23:15:51.865 xcodebuild[53900:6388253] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /ur/bin/gcc-4.2 -v -E -dM -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1" UserInfo=0x7fbfbbb474d0 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /ur/bin/gcc-4.2 -v -E -dM -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2015-02-18 23:15:51.865 xcodebuild[53900:6388253] Warning:  Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /ur/bin/gcc-4.2
Reason:   /ur/bin/gcc-4.2 -v -E -dM -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -x c -c /dev/null 2>&1
2015-02-18 23:15:52.448 xcodebuild[53900:6388249]  DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-6269/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:77
Details:  Failed to load dependencies output contents from ``/Users/devonboyer/Library/Developer/Xcode/DerivedData/Alamofire-gpmlmgkqhnaqwsdibrprtyuyoqpu/Build/Intermediates/Alamofire.build/Release-iphonesimulator/Alamofire iOS.build/Objects-normal/x86_64/Alamofire.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Alamofire.d” couldn’t be opened because there is no such file." UserInfo=0x7fbfb9e774f0 {NSFilePath=/Users/devonboyer/Library/Developer/Xcode/DerivedData/Alamofire-gpmlmgkqhnaqwsdibrprtyuyoqpu/Build/Intermediates/Alamofire.build/Release-iphonesimulator/Alamofire iOS.build/Objects-normal/x86_64/Alamofire.d, NSUnderlyingError=0x7fbfb9e71f00 "The operation couldn’t be completed. No such file or directory"}. User info: {
    NSFilePath = "/Users/devonboyer/Library/Developer/Xcode/DerivedData/Alamofire-gpmlmgkqhnaqwsdibrprtyuyoqpu/Build/Intermediates/Alamofire.build/Release-iphonesimulator/Alamofire iOS.build/Objects-normal/x86_64/Alamofire.d";
    NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread:   <NSThread: 0x7fbfb9e1a3a0>{number = 7, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **


The following build commands failed:
    CompileSwift normal x86_64 /Users/devonboyer/Desktop/Reach/Reach/Carthage/Checkouts/Alamofire/Source/Alamofire.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)

SwiftyJSON 无法构建并出现此错误:

Scheme SwiftyJSONOSX is not currently configured for the build action.

我真的很想弄清楚为什么这不起作用,因为我认为迦太基可能真的很棒。请注意,除了按照 Cartage git repo 上的说明进行操作外,我什么也没做。只需运行cartage update,就发生了这种情况。有任何想法吗?

xcode-select 路径正确指向 Xcode 的 beta 版本

/Applications/Xcode-Beta.app/Contents/Developer

4

1 回答 1

0

我决定暂时绕过 Carthage 来构建 SwiftyJSON。我采取了以下步骤(看起来比实际复杂)

1.) 从 github 克隆 SwiftyJSON

2.) 切换到 xcode6.3 分支

3.) 在 Xcode 6.3 中打开 SwiftyJSOn(现在非测试版)

4.)删除调试配置(强制它构建发布配置)

5.) 选择 SwiftyJSON 项目并打开右侧栏并将“项目格式”更改为 Xcode 6.3 兼容

在此处输入图像描述

6.) 构建项目

7.) 打开 DerivedData 并导航直到找到 SwiftyJSON.framework

8.) 将 SwiftyJSON.framework 移动到你的 $(SRC_ROOT)/Carthage/Build/iOS/

9.) 你的项目现在应该能够找到 SwiftyJSON

祝你好运,神速

于 2015-04-10T00:58:49.617 回答