0

I'm a beginner to swift 3 and cocoapods and i want to implement this https://github.com/luowenxing/MTImagePicker image picker for my project.

I've installed the pod into my project and am using the .xcworkspace file.

However, I'm facing problems as i've errors like:

  • No such module 'MTImagePicker'
  • Use of unresolved identifier 'MTImagePickerController'
  • Use of undeclared type 'MTImagePickerAssetsModel'

I've moved the MTImagePicker folder into my project as instructed.

But I'm still having this problem.

Any help is much appreciated.

Thank you so much!

Edited:

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

Solution: I got my stuffs working by doing this: https://stackoverflow.com/a/39435421/7498313

I marked Faris Sbahi's answer as the correct answer as I believe his answers can help beginners like me to set up the cocoapods and implementation of the project.

Thank you so much! :)

Community
  • 1
  • 1
  • I'd recommend you find other pod for that as the latest supporting version of `MTImagePicker` is Swift 2.2. Anyhow, make sure you Clean (cmd + k) and then Build (cmb + b) before trying to import. – Marcos Griselli Feb 13 '17 at 01:47
  • How do you see the version of the pods? – codingStudent Feb 13 '17 at 01:53
  • Most pods have a Requirements section in their readme (what you see when you enter the link you shared). He states it works on Xcode 7.3 and Swift 2.2 – Marcos Griselli Feb 13 '17 at 01:55
  • Oh... i saw 'iOS7.0+' and i thought that it's suitable for iOS7.0 and above.. Hmm.. I even tried this https://github.com/yahoo/YangMingShan and I can't make it work too :\ – codingStudent Feb 13 '17 at 01:58
  • Make sure your framework is added in both Embedded Binaries and Linked Frameworks and Libraries – HardikDG Feb 13 '17 at 03:13

1 Answers1

0

import MTImagePicker at the top of your class.

Update your Podfile to

Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!

target 'BPMatters' do
  # Pods for BPMatters
  pod 'MTImagePicker', '~> 1.0.1'

end 
target 'BPMattersTests' do
    inherit! :search_paths
    # Pods for testing
end

target 'BPMattersUITests' do
    inherit! :search_paths
    # Pods for testing
end

After updating your Podfile to this, run pod install and ensure no errors are returned. After doing so, open the xcworkspace file and when you attempt to build ensure that the target is BPMatters.

Be sure that in the side pane you see something like this: Pods

With a folder for MTImagePicker

Faris Sbahi
  • 646
  • 7
  • 15