jazzy: Cannot find ObjC headers from subfolders

I’m having issues with jazzy finding source files.

  • In my objC project I’m using subfolders to organize files.
  • I have an umbrella header containing imports:
    • when importing a file via #import "<Filename>.h"
      • compiler builds
      • jazzy cannot find the filename (fatal error: '<Filename>.h' file not found)
    • when importing a file via #import <Subfolder/Filename.h>
      • compiler doesn’t build
      • jazzy finds the file but cannot find the imports included in that header file (maybe bc. they also are in another subfolder of the project)

Any ideas how to fix that issue? I’d also be interested in an example - would greatly appreciate if anybody could provide a link to a repo using objC that organizes files in subfolders and got jazzy working.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like the JazzyObjCSubfolders project’s .jazzy.yaml file should have had ObjectiveCJazzy for framework_root instead of BRTObjectiveCJazzy (in addition to the other compatibility fixes i had to make: objc_mode: to objc: and version: to module_version:).

With this correct directory name, my experiment calling sourcekitten with it and the added subdirectories arguments succeeded.

A change to jazzy’s sourcekitten.rb to add those additional -I arguments for each subdirectory of framework_root seems to work for both JazzyObjCSubfolders and my own project:

--- a/lib/jazzy/sourcekitten.rb
+++ b/lib/jazzy/sourcekitten.rb
@@ -122,8 +122,14 @@ module Jazzy
           arguments += ['--objc', options.umbrella_header.to_s, '--', '-x',
                         'objective-c', '-isysroot',
                         `xcrun --show-sdk-path --sdk #{options.sdk}`.chomp,
                         '-I', options.framework_root.to_s]
+          # add additional -I arguments for each subdirectory of framework_root
+          Pathname.new(options.framework_root.to_s).children.collect do |child|
+            if child.directory?
+              arguments += ['-I', child.to_s]
+            end
+          end
         end
       elsif !options.module_name.empty?
         arguments += ['--module-name', options.module_name, '--']
       else

I don’t know if this should always be done or controlled by a command line/config file option though. Also, there could be a better way to find subdirectories instead of visiting every file. I’ll leave it to someone else to figure those out & make this fix for real.