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

Unable to import OS X frameworks using private headers and header_mappings_dir #5313

Closed
mrackwitz opened this issue May 13, 2016 · 5 comments
Assignees
Labels
s2:confirmed Issues that have been confirmed by a CocoaPods contributor t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!
Milestone

Comments

@mrackwitz
Copy link
Member

What did you do?

Integrated Realm in an OS X target.

What did you expected to happen?

The integrating target would build.

What happened instead?

The generated pod target for Realm itself builds, but it can't be imported. Clang complains about missing headers from the module map:

Realm.framework/Modules/module.modulemap:8:16: error: header 'RLMAccessor.h' not found
        header "RLMAccessor.h"
               ^

DataImporter.swift:20:8: error: could not build Objective-C module 'Realm'
import Realm
       ^

Inspecting the build products and comparing them with the binaries we build ourselves from our Xcode project, it turns out, that the PrivateHeaders symlink in the root directory of the framework bundle is missing. While the actual PrivateHeaders dir exists within Versions/A. My suspicion is that the custom copy files build phase, which ensures to retain the header layout of the header_mappings_dir creates the PrivateHeaders directory in a way Xcode doesn't expect, preventing the automatic creation of the symlink.

So this seems to be an instance of a more general error, which is only relevant for podspecs using header_mappings_dir, a custom module map and private headers, which are explicitly declared in the module map.

CocoaPods Environment

   CocoaPods : 1.0.0
       Xcode : 7.3 (7D175)

Project that demonstrates the issue

https://github.com/realm/realm-cocoa-converter/tree/to-0.102.0-update

@mrackwitz mrackwitz added the t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome! label May 13, 2016
@segiddins
Copy link
Member

If I understand, this is only an issue for OS X?

@mrackwitz
Copy link
Member Author

Yes, because it fails just because of the missing symlink, which is only present in the framework structure used by OS X.

@segiddins
Copy link
Member

Joy 😭

@mrackwitz
Copy link
Member Author

mrackwitz commented May 14, 2016

I see two ways how we could solve that:

  1. create a private dummy header, which uses Xcode's builtin copy header files build phase
  2. create the symlink ourselves by a shell script build phase

Adding a dummy header like in 1. outside of the header_mappings_dir, which would be added to the builtin copy header files build phase isn't allowed, because header files have to be children of the header_mappings_dir.

But it is possible to partially work around that from the podspec as seen below, but this doesn't follow the exact structure and could theoretically break AppStore-compatibility if not already now then possibly in the future.

s.osx.pod_target_xcconfig = {
  'PUBLIC_HEADERS_FOLDER_PATH' => '$(WRAPPER_NAME)/Headers',
  'PRIVATE_HEADERS_FOLDER_PATH' => '$(WRAPPER_NAME)/PrivateHeaders'
}

Note that the PUBLIC_HEADERS_FOLDER_PATH has to be overridden here as well. That's because once the PRIVATE_HEADERS_FOLDER_PATH is overridden, the symlink for the public headers is also not correctly created anymore. That doesn't make any sense to me.

@segiddins
Copy link
Member

I guess let's look into a build phase to make the symlinks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s2:confirmed Issues that have been confirmed by a CocoaPods contributor 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

2 participants