如何将 Hamcrest 添加到 XCODE?
How to add Hamcrest to XCODE?
我找不到实际的 hamcrest.framework - 只有源代码。要实际包含到 xcode 中需要采取哪些步骤?
我尝试编译源代码,但没有将其连接到我要创建的新项目。
我建议使用 cocoapods。它使将 third-party 库添加到您的项目变得更加容易。如果您在此处查看 OCHamcrest 页面:https://github.com/hamcrest/OCHamcrest
他们甚至会为您提供有关如何设置的说明。
其实很简单。在 Ray Wenderlich 的网页上有一个非常棒的教程!所以请查看:http://www.raywenderlich.com/97014/use-cocoapods-with-swift
1) 创建一个 XCode 项目(您要在其中使用 Hamcrest)
2) 关闭 Xcode
3) 打开 Terminal-Window 并转到 Xcode 项目文件的路径
4)(如果还没有安装)安装cocoapods:(这需要相当长的时间,所以不要惊慌)
sudo gem install cocoapods
pod setup --verbose // for verbose output
pod init // if it fails with error message you might not be in the correct path)
5) 打开 Pod-File
open -a Xcode Podfile
6) 编辑 Pod-File
platform :ios, "8.0"
use_frameworks!
7) 按照 github (swifthamcrest)
中的描述整合 hamcrest
target 'HamcrestDemoTests' do // name of your File
pod 'SwiftHamcrest'
end
8) 安全文件并开始安装
pod install
9) 使用 .xcworkspace
文件打开您的项目
10) 在您的测试套件中导入 Hamcrest
import XCTest
import Hamcrest
@testable import test
class testTests: XCTestCase {
不用担心找不到模块的初始错误。他们将在首次构建项目后消失。
我找不到实际的 hamcrest.framework - 只有源代码。要实际包含到 xcode 中需要采取哪些步骤? 我尝试编译源代码,但没有将其连接到我要创建的新项目。
我建议使用 cocoapods。它使将 third-party 库添加到您的项目变得更加容易。如果您在此处查看 OCHamcrest 页面:https://github.com/hamcrest/OCHamcrest
他们甚至会为您提供有关如何设置的说明。
其实很简单。在 Ray Wenderlich 的网页上有一个非常棒的教程!所以请查看:http://www.raywenderlich.com/97014/use-cocoapods-with-swift
1) 创建一个 XCode 项目(您要在其中使用 Hamcrest)
2) 关闭 Xcode
3) 打开 Terminal-Window 并转到 Xcode 项目文件的路径
4)(如果还没有安装)安装cocoapods:(这需要相当长的时间,所以不要惊慌)
sudo gem install cocoapods
pod setup --verbose // for verbose output
pod init // if it fails with error message you might not be in the correct path)
5) 打开 Pod-File
open -a Xcode Podfile
6) 编辑 Pod-File
platform :ios, "8.0"
use_frameworks!
7) 按照 github (swifthamcrest)
中的描述整合 hamcresttarget 'HamcrestDemoTests' do // name of your File
pod 'SwiftHamcrest'
end
8) 安全文件并开始安装
pod install
9) 使用 .xcworkspace
文件打开您的项目
10) 在您的测试套件中导入 Hamcrest
import XCTest
import Hamcrest
@testable import test
class testTests: XCTestCase {
不用担心找不到模块的初始错误。他们将在首次构建项目后消失。