Cocoapods: Search path not propagated to test target

Created on 20 Jul 2017  路  4Comments  路  Source: CocoaPods/CocoaPods

Report

What did you do?

  1. Create a Swift project with unit tests
  2. pod init to create a Podfile
  3. Add pod 'Firebase' to Podfile under use_frameworks!
  4. Run pod update
  5. Open the generated xcworkspace
  6. Add import Firebase to the AppDelegate.swift
  7. Add @testable import <ProjectName> into <ProjectName>Tests.swift

What did you expect to happen?

Header imports from the Firebase pod are added to the testing target, causing
tests to build and run successfully.

What happened instead?

A "Missing required module 'Firebase'" build error will appear. The directory
from the Firebase pod is not added to the testing target's
Header Search Paths even though inherit! :search_paths is set.

CocoaPods Environment

Stack

   CocoaPods : 1.2.1
        Ruby : ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin16.0]
    RubyGems : 2.2.2
        Host : Mac OS X 10.12.5 (16F73)
       Xcode : 9.0 (9M174d)
         Git : git version 2.13.0.rc1.294.g07d810a77f-goog
Ruby lib dir : /Users/wilsonryan/.rbenv/versions/2.1.3/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 92958bc76be648b458ed2cdf50ea7a5185aef134

(This does happen on previous Xcode versions as well).

Installation Source

Executable Path: /Users/wilsonryan/.rbenv/versions/2.1.3/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-playgrounds : 1.2.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.2.0
cocoapods-try         : 1.1.0

Project that demonstrates the issue

Example project can be found here.

Discussion

This is fixable on the user's side by explicitly adding
"${PODS_ROOT}/Firebase/Core/Sources" to the test target's
Header Search Paths, but it shouldn't be necessary. There may be a fix for the
Podspec that can alleviate this issue in which case we're happy to do so!

The current podspec for the Firebase pod can be found here
and the high level structure for all of Firebase is as follows:

  • Each Firebase product ships their own CocoaPod separate from the podspec above: FirebaseCore, FirebaseAuth, FirebaseDatabase, and more.
  • Firebase is an umbrella pod that contains multiple subspecs, all parts of Firebase:

    • Core is the default subspec that provides the umbrella header that imports any Firebase SDK that is available to the user.

    • There are multiple other subspecs based on products including Auth, Database, Messaging, etc.

    • Each of these subspecs depend on their equivalent external pods

    • Subspec Auth depends on FirebaseAuth

    • Subspec Database depends on FirebaseDatabase

    • etc.

At the moment, the spec relies on the user_target_xcconfig flag in the Core
subspec to explicitly add ${PODS_ROOT}/Firebase/Core/Sources to
HEADER_SEARCH_PATHS. This isn't recommended, and the regular
target's case can be solved by explicitly adding
"public_header_files": [ "Core/Sources/Firebase.h" ], to the podspec, removing
preserve_paths and replacing it with module_map as seen below.

Current Core Subspec

{
  "dependencies": {
    "FirebaseAnalytics": "4.0.2",
    "FirebaseCore": "4.0.3"
  },
  "name": "Core",
  "preserve_paths": [
    "Core/Sources/module.modulemap"
  ],
  "source_files": [
    "Core/Sources/Firebase.h"
  ],
  "user_target_xcconfig": {
    "HEADER_SEARCH_PATHS": "$(inherited) ${PODS_ROOT}/Firebase/Core/Sources"
  }
},

"Fixed" Core Subspec

{
  "dependencies": {
     "FirebaseAnalytics": "4.0.2",
     "FirebaseCore": "4.0.3"
   },
   "name": "Core",
   "module_map": "Core/Sources/module.modulemap",
   "public_header_files": [
     "Core/Sources/Firebase.h"
   ],
   "source_files": [
     "Core/Sources/Firebase.h"
   ]
},

This is cleaner but unfortunately it doesn't solve the issue of the test target
not working out of the box.

If this is a simple Podspec fix we're happy to make the change, otherwise I
believe this is currently a bug.

Most helpful comment

Was using 1.4.0 and just upgraded to 1.5.0 and this seems to be broken again using Xcode 9.3 and the latest version of Firebase.

To be specific, this issue appears to have come back. https://github.com/firebase/firebase-ios-sdk/issues/58

All 4 comments

I'm still having this issue, I'm on cocoapods 1.3.1, the steps to reproduce this are exactly the same as above. Ended up adding "${PODS_ROOT}" as a recursive header search path in the test target.

@cyupa The fix is in CocoaPods 1.4.0

Upgraded to 1.4.0 Beta 2 and it works. Thanks, @paulb777!

Was using 1.4.0 and just upgraded to 1.5.0 and this seems to be broken again using Xcode 9.3 and the latest version of Firebase.

To be specific, this issue appears to have come back. https://github.com/firebase/firebase-ios-sdk/issues/58

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pallaviMN picture pallaviMN  路  3Comments

evermeer picture evermeer  路  3Comments

spencerkohan picture spencerkohan  路  3Comments

k06a picture k06a  路  3Comments

hmistry picture hmistry  路  3Comments