Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulemap path works for local pod development but not when the pod is installed from remote #7619

Closed
bryanboyko opened this issue Apr 11, 2018 · 19 comments
Labels
s1:awaiting input Waiting for input from the original author

Comments

@bryanboyko
Copy link

bryanboyko commented Apr 11, 2018

Report

What did you do?

Create my_framework with a VungleSDK dependency as a pod (VungleSDK is included by CocoaPods as a .framework as opposed to being a collection of source files which CocoaPods then packaged as a framework).

Expose Objective-C VungleSDK module to my_framework Swift files with the following code from module.modulemap

module VungleSDK [system] {
    header "../../../../Pods/VungleSDK-iOS/VungleSDK.framework/Headers/VungleSDK.h"
    export *
}

The potentially relevant portion of my podspec:

  s.xcconfig         = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
  s.libraries        = 'xml2'
  s.swift_version    = "4.0"

  s.requires_arc     = true
  s.platform         = :ios, '8.0'
  s.static_framework = true

 s.subspec 'Vungle' do |d|
    d.dependency 'VungleSDK-iOS', '5.4.0'
    d.source_files = ['MYSDK/ThirdParty/*.swift', 'MYSDK/ThirdParty/Vungle/**/*']
    d.xcconfig = { 'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/MYSDK/ThirdParty/Vungle/ModuleMap' }
    d.preserve_paths = 'MYSDK/ThirdParty/Vungle/ModuleMap/module.modulemap'
  end

The above setup works for local development, but not when my_framework is installed by CocoaPods from a remote source.

I used the answers from the below CocoaPods issue to get local development working #5271

My header path in the module map looks gross. I'm guessing it's causing this issue. I couldn't find how to make the path work after digging around the web.

Likely there is an answer in the clang docs? I'm finding them difficult to decipher.. http://clang.llvm.org/docs/Modules.html#module-declaration

What did you expect to happen?

The module map path that works for local pod development of my_framework should also work when my_framework is installed from a remote source

What happened instead?

XCode build error

Could not build Objective-C module 'VungleSDK'

CocoaPods Environment

Stack

   CocoaPods : 1.5.0.beta.1
        Ruby : ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
    RubyGems : 2.7.6
        Host : Mac OS X 10.12.6 (16G29)
       Xcode : 9.2 (9C40b)
         Git : git version 2.14.3 (Apple Git-98)
Ruby lib dir : /usr/local/Cellar/ruby/2.5.0_2/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 01a6310775e35c4d06ede009c44635600971f4ed
               MYSDK-Specs - git@github.com:MYSDK/Specs.git @ fc84b2d94a911a9b9484114c9add939ca6694e76
               mysdk - https://github.com/MYSDK/Specs.git @ 58c1c0279879e0375c07ab825bf014b27d1e5f58
               Specs - git@github.com:MYSDK/Specs.git @ 58c1c0279879e0375c07ab825bf014b27d1e5f58

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.2
cocoapods-packager    : 1.5.0
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

Podfile

platform :ios, '8.0'

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/MYSDK/Specs.git'

def common_deps

  use_frameworks!

  pod 'SwiftLint'
  pod "VungleSDK-iOS", "5.4.0"
 
end

target 'MYSDK' do

  common_deps

  target 'MYSDKTests' do
    inherit! :search_paths

    pod 'Quick'
    pod 'Nimble'
  end


end

Project that demonstrates the issue

Let me know if a sample project will be helpful and I will make one.

@dnkoutso
Copy link
Contributor

dnkoutso commented Apr 11, 2018

Not sure for the core problem but one thing to note:

d.xcconfig = { 'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/MYSDK/ThirdParty/Vungle/ModuleMap' }

Are you intentionally changing this? xcconfig actually changes the user xcconfig and not the pod one. Generally not advised as it changes the users project. Unless you really intended to do this.

@bryanboyko
Copy link
Author

bryanboyko commented Apr 11, 2018

@dnkoutso thanks for the quick reply

I added SWIFT_INCLUDE_PATHS change based on the solution suggested in #5271

I just tried removing the d.xcconfig line from the podspec. When I re-pod installed, I got the error No such module 'VungleSDK'

I'm not familiar with module maps, but it seems like this is an issue with the header path in my module map, which works to incorporate my_framework is a development pod, but not when it's installed as a pod from a remote source.

@dnkoutso
Copy link
Contributor

@bryanboyko I think it would be best to provide a sample app for us to repro and diagnose.

@dnkoutso dnkoutso added s1:awaiting input Waiting for input from the original author s6:need sample Needs a sample project that reproduces the issue labels Apr 11, 2018
@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Apr 11, 2018
@bryanboyko
Copy link
Author

@dnkoutso ok coming up

@bryanboyko
Copy link
Author

@dnkoutso project is up at https://github.com/bryanboyko/PodFrameworkWithVungleDependency

The sample app is currently set up with a pod install from the remote source. Run the sample app to see the build error.

Switching the sample app podfile to point to the local version of the SDK will cause the sample app to run successfully

@dnkoutso
Copy link
Contributor

@bryanboyko thanks! miiight be related to #7616? You can apply the fix manually or use bundler and try it out?

@bryanboyko
Copy link
Author

@dnkoutso thanks will take a look

@bryanboyko
Copy link
Author

@dnkoutso I'm having a bit of trouble figuring out how to apply the fix manually.

I followed the PR code to the xcconfig_helper.rb class. Since I've got static_framework = true in my podspec, im assuming self.add_static_dependency_build_settings function will be hit and then add_framework_build_settings will be hit.

add_framework_build_settings makes the following calls

build_settings = {
            'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
          }
build_settings['OTHER_LDFLAGS'] = "-framework \"#{name}\"" if include_ld_flags

That means I just need to add VungleSDK to the FRAMEWORK_SEARCH_PATHS and OTHER_LDFLAGS in the sample app's build settings?

@dnkoutso
Copy link
Contributor

@bryanboyko for 1.6.0 all of the build settings are being re-written. Sorry haven't had time to look over this issue.

@dnkoutso dnkoutso removed the s6:need sample Needs a sample project that reproduces the issue label Apr 19, 2018
@dnkoutso
Copy link
Contributor

@bryanboyko from a very quick look this might be fixed by the build settings revamp #7631

@bryanboyko
Copy link
Author

@dnkoutso no worries.

Looking forward to the next Cocoapods release.

@bryanboyko bryanboyko changed the title Modulemap path works for local pod development but not when is installed from remote Modulemap path works for local pod development but not when the pod is installed from remote Apr 25, 2018
@stale
Copy link

stale bot commented Jul 24, 2018

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

@stale stale bot added the s1:awaiting input Waiting for input from the original author label Jul 24, 2018
@stale
Copy link

stale bot commented Jul 31, 2018

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@stale stale bot closed this as completed Jul 31, 2018
@klein-thibault
Copy link

@bryanboyko I'm experiencing the same issue that you mentioned here, did you end up solving your issue?

@mitchross
Copy link

@bryanboyko I would like to know also!

@amadeu01
Copy link

amadeu01 commented May 1, 2020

@bryanboyko Im facing the same issue, how did you fix ?

@Jageen
Copy link

Jageen commented Jun 21, 2020

@brentnycum I am having same issue, did you solved it?

@Jageen
Copy link

Jageen commented Jun 21, 2020

Hello @dnkoutso It issue is closed and it seems that @brentnycum did found solution but can you put some more light over solution ?
Can you let me know what might @brentnycum did to solve his problem ?

@SeanTrinhHai
Copy link

SeanTrinhHai commented Oct 3, 2022

Incase anyone is still looking the answer just like me before, modulemap file directory is different when we using remote pod instead of local pod. Therefore, you might have to modify header path in modulemap file a bit to math with new directory in remote version, in my case:

module InsiderMobile [system] {
// Framework complier
// header "../../../../Pods/InsiderMobile/InsiderMobile.framework/Headers/Insider.h"

// App complier
header "../../../../../../Pods/InsiderMobile/InsiderMobile.framework/Headers/Insider.h"

export *

}

I change the header directory before deploy pod and it work fine for my application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s1:awaiting input Waiting for input from the original author
Projects
None yet
Development

No branches or pull requests

7 participants