【发布时间】:2017-02-12 16:22:20
【问题描述】:
我是 swift 3 和 cocoapods 的初学者,我想为我的项目实现这个 https://github.com/luowenxing/MTImagePicker 图像选择器。
我已将 pod 安装到我的项目中并正在使用 .xcworkspace 文件。
但是,我遇到了一些问题,因为我有如下错误:
- 没有这样的模块“MTImagePicker”
- 使用未解析的标识符“MTImagePickerController”
- 使用未声明的类型“MTImagePickerAssetsModel”
我已按照指示将 MTImagePicker 文件夹移动到我的项目中。
但我仍然有这个问题。
非常感谢任何帮助。
非常感谢!
已编辑:
Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'BPMatters' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for BPMatters
source 'https://github.com/CocoaPods/Specs.git'
pod 'MTImagePicker', '~> 1.0.1'
target 'BPMattersTests' do
inherit! :search_paths
# Pods for testing
end
target 'BPMattersUITests' do
inherit! :search_paths
# Pods for testing
end
end
@objc protocol MTImagePickerControllerDelegate:NSObjectProtocol {
// Implement it when setting source to MTImagePickerSource.ALAsset
optional func imagePickerController(picker:MTImagePickerController, didFinishPickingWithAssetsModels models:[MTImagePickerAssetsModel])
// Implement it when setting source to MTImagePickerSource.Photos
@available(iOS 8.0, *)
optional func imagePickerController(picker:MTImagePickerController, didFinishPickingWithPhotosModels models:[MTImagePickerPhotosModel])
optional func imagePickerControllerDidCancel(picker: MTImagePickerController)
}
///third party image picker////
func thirdPartyImagePicker(){
let imagePicker = MTImagePickerController.instance
imagePicker.mediaTypes = [MTImagePickerMediaType.Photo,MTImagePickerMediaType.Video]
imagePicker.imagePickerDelegate = self
imagePicker.maxCount = 10 // max select count
imagePicker.defaultShowCameraRoll = true // when set to true would show Camera Roll Album like WeChat by default.
//default is MTImagePickerSource.ALAsset
imagePicker.source = MTImagePickerSource.ALAsset
//imagePicker.source = MTImagePickerSource.Photos (Work on iOS8+)
self.presentViewController(imagePicker, animated: true, completion: nil)
}
///third party image picker end///
Screenshot of Terminal after pod install
解决方案:我通过这样做让我的东西正常工作:https://stackoverflow.com/a/39435421/7498313
我将 Faris Sbahi 的答案标记为正确答案,因为我相信他的答案可以帮助像我这样的初学者设置 cocoapods 和实施项目。
非常感谢! :)
【问题讨论】:
-
我建议您为此寻找其他 pod,因为
MTImagePicker的最新支持版本是 Swift 2.2。无论如何,请确保在尝试导入之前先清理 (cmd + k),然后构建 (cmb + b)。 -
如何查看 pod 的版本?
-
大多数 pod 在其自述文件中都有一个要求部分(当您输入您共享的链接时会看到什么)。他说它适用于 Xcode 7.3 和 Swift 2.2
-
哦...我看到'iOS7.0+',我认为它适用于iOS7.0及更高版本..嗯..我什至试过这个github.com/yahoo/YangMingShan,但我做不到它也可以:\
-
确保您的框架已添加到嵌入式二进制文件和链接框架和库中