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

Importing header/source files with same names and different paths #8289

Open
vojerr opened this issue Nov 18, 2018 · 13 comments
Open

Importing header/source files with same names and different paths #8289

vojerr opened this issue Nov 18, 2018 · 13 comments
Labels
t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!

Comments

@vojerr
Copy link

vojerr commented Nov 18, 2018

Cocoapods version: 1.5.3
Xcode version: 10.0

Consider following structure of local pod dependency with objective-c sources:
dependency -> folder1 -> MyClass.h
dependency -> folder1 -> MyClass.m
dependency -> folder2 -> MyClass.h
dependency -> folder2 -> MyClass.h

Files MyClass in folder1 contains implementation of class, named MyClass1
Files MyClass in folder2 contains implementation of class, named MyClass2
It's general case, while using j2objc, that class names are different to files(different packages in java with same class names).

After importing this local dependency to cocoa pods workspace, files from both folders are imported to Xcode project, but from only from one folder are imported into project build phases (but twice). It breaks compilation.

cocoapodsbug

Sample project, demonstrated issue:
https://github.com/vojerr/CocoapodsHeadersBug

@segiddins
Copy link
Member

You'll need to use a header_mappings_dir if you want to be able to import both headers, but that doesnt explain why both .ms aren't being added correctly

@segiddins segiddins added the t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome! label Nov 21, 2018
@vojerr
Copy link
Author

vojerr commented Nov 22, 2018

@segiddins
In case of using header_mappings_dir, one of headers still remains not imported in "project headers", sources phase remains same.

cccc

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

I have the same issue.

I'm try to provide a pure C/C++ project, from a standalone Xcode project, into CocoaPods podspec syntax. The original Xcode project it's here : https://github.com/dreampiggy/libx265-Xcode

It have 3 directory which contains the same name source file .cpp, but the content are exact different. I can successfully config and build with Xcode or Carthage.

However, I can not write any correct way to port this into CocoaPods source_files syntax.

@dreampiggy
Copy link

The Xcode project of framework (manage by my own hands) can build success.
image

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

I try the Podspec syntax. However, the generate project source files list is totally wrong. Which treat any same name source files (for example, yuv.cpp), without consider its path. And cause build failsure.

s.source_files = 'source/x265.{h,cpp}', 'source/x265_config.h', 'source/common/*.{h,c,cpp,hpp}', 'source/input/*.{h,c,cpp,hpp}', 'source/output/*.{h,c,cpp,hpp}', 'source/encoder/*.{h,c,cpp,hpp}'
s.public_header_files = 'source/x265.h', 'source/x265_config.h'
s.preserve_paths = 'source/**/*'

The generate Pods.xcproj:

image

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

Right now, I can not find a way to solve this for CocoaPods.

I thin it’s bug not feature. Because I’ve already use that preserve_paths to keep the source files directory structure. So that it should not be put as plane. However, seems CocoaPods assume something about filename but not full paths.

Now, I have to pre-built the static library (.a) and provide it to my user. It's a litttle suck...Hope for a fix.

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

The podspec is here. You can have a try of that with pod 'libx265', :git => 'https://github.com/dreampiggy/x265.git'

https://github.com/dreampiggy/x265

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

OK. I found a hack way to pass this bug. It's to use Pod subspec to allow same filename exist in one Pod. 🐶

And, it take me hours to fix that pod spec lint issue, because by default, all the subspecs combination (Mine is 5, the all combinations nearlly 20...) it's hard to pass. So I polish the hack of Podspec to pass. I think that pod spec lint --help should point out the --subspecs=xxx usage. Or it takes so much of time to find the way out. (Because why I use subspecs is to solve this bug. The code are actually an entire framework components, without any internal dependency, I have to manually create the dependency... 🐱 )

The final achievement: https://github.com/SDWebImage/libx265-Xcode/blob/3.0/libx265.podspec#L44-L47

The Pod is now on trunk. The x265 codec: https://cocoapods.org/pods/libx265

@dreampiggy
Copy link

dreampiggy commented Feb 2, 2019

And, during that Podspec, I found another usage issue of CocoaPods subspecs.

Is there are any way, to make one subspec, contains Project Headers only (wihtout any Public Headers or Private Headers ?). I found that there are no way to do this. 😕

I try this workaround, it works in local :path usage. But however, this does not pass the pod spec lint

  s.subspec 'common' do |ss|
    ss.dependency 'libx265/core'
    ss.source_files = 'source/common/*.{h,c,cpp,hpp}'
    ss.public_header_files = 'source/x265.h'# dummy to mark all as project header
  end

@amorde
Copy link
Member

amorde commented Feb 3, 2019

Yes this is a bug, we've marked it as a defect but no one has taken the time to fix it.

PRs are welcomed :)

Is there are any way, to make one subspec, contains Project Headers only (wihtout any Public Headers or Private Headers ?)

Headers included in source_files are Project by default - I think this can be overridden on the subspec level but if the root spec includes them in public_header_files then you might need to override it as you have done in your example

@dreampiggy
Copy link

Yes this is a bug, we've marked it as a defect but no one has taken the time to fix it.

PRs are welcomed :)

Is there are any way, to make one subspec, contains Project Headers only (wihtout any Public Headers or Private Headers ?)

Headers included in source_files are Project by default - I think this can be overridden on the subspec level but if the root spec includes them in public_header_files then you might need to override it as you have done in your example

I’ll try to provide the solution to fix this. Maybe after the vacation. Though I’m not famaliar with Pods, but I have a little ruby language experience....

@hasayakey
Copy link

facing this problem.
in my case, i have some c++ file for different platforms with some file's name in the same.

@Alexufo
Copy link

Alexufo commented Jan 27, 2022

I have the same problem #11172

It solve the issue!
ivpusic/react-native-image-crop-picker#680 (comment)

install! 'cocoapods',
         :deterministic_uuids => false

@vojerr I have the same sources for react-native and flutter module project. For RN I have this issue but flutter project have not. I dont understand the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!
Projects
None yet
Development

No branches or pull requests

6 participants