10
votes

am using CocoaPods 1.2 and i have a project with 2 targets, one is the main iPhone app and the other one is cocoa touch framework library.

I have no problem adding pods to my iphone target, my main problem is that i cannot add any pods to that other shared library target.

here is an example of my pod file:

platform :ios, '9.0'

target 'MyApp' do
  use_frameworks!
  pod 'EVReflection'
end

target 'MyLibrary' do
  use_frameworks!
  pod 'EVReflection'
end

adding pods to the main app MyApp works just fine but not to the other target, any ideas why this happens?

i have tried to use abstract_target but with no luck. i even tried to deintegrate and reintegrate but also not working.

the problem only happens when trying to add pods to universal framework library, adding pods to any other type of targets work just fine.

Any help would be appreciated.

2
Does cocoapods give you an error? Or is Xcode complaining?Dave Weston
No error from cocoapods or xcode, pods install successfully and xcode runs just fine, but when u try to import the pod in the library it says module not foundAhmed Galal
I'm pretty sure I've done this in the past and not had an issue, but I'll put together a little sample and see what I find.Dave Weston

2 Answers

12
votes

Here is my whole procedure

  1. crate a new swift app project.
  2. create a new cocoa touch framework target.
  3. in the project directory , run pod init
  4. Tyr This Podfile

    # Uncomment the next line to define a global platform for your project
    platform :ios, '9.0'
    
    target 'SOQ' do
      use_frameworks!
    end
    
    target 'SOQFW' do
      use_frameworks!
    end
    
    pod 'EVReflection'
    

after pod install, in both my two targets SOQ (swift app) and SOQFW (cocoa touch framework) can import EVReflection in *.swift and user class EVObject without a problem.

sample code is

import EVReflection

class User: EVObject {
    var id: Int = 0
    var name: String = ""
    var friends: [User]? = []
}

you can give it a try.

My development environment is os x 10.12 , xode 8.2.1 , cocoapods 1.1.1

1
votes

I created a sample project here: https://github.com/dtweston/PodFrameworkTest

My Podfile was the exact same as you posted in your question.

I was able to import and use the framework in both the main app and the framework library.

In the framework:

public class LibUser: EVObject {
    var id: Int = 0
    var name: String = ""
    var friends: [LibUser]? = []
}

In the app (you can see this also references the framework's LibUser class):

class AppUser: EVObject {
    var id: Int = 0
    var name: String = ""
    var friends: [LibUser]? = []
}

I'm also on macOS 10.12 and Xcode 8.2.1. I'm using cocoapods 1.2.0, and it also worked fine with Cocoapods 1.2.0-rc1

I wonder what's different between your setup and mine. If you look at the Info for the project that contains your App and framework, are the Cocoapods config files set up correctly?