Realm-cocoa: Realm.h not found via cocoapods

Created on 10 Jun 2016  路  15Comments  路  Source: realm/realm-cocoa

Goals

I've formatted my macbook and then I've made a fresh install of my development environment (latest XCode version, cocoapods 1.0.0). I've cloned an old Objective C project and downloaded all its dependencies using cocoapods. When i try to build it, it fails because of a missing Realm header. It's imported in my project as

#import "Realm.h"

Expected Results

The project builds as usual

Actual Results

Build failing: Realm.h not found

Steps to Reproduce

  1. Include Realm 0.98.1
  2. Import as #import "Realm.h"
  3. Build the project

Realm version: 0.98.1

Xcode version: 7.3

iOS/OSX version: 8.4

Dependency manager + version: cocoapods 1.0.0,

T-Help

Most helpful comment

@thegreatmichael faced with this issue by myself today :) My solution was to remove all Xcode's Derived Data (or alt+shift+cmd+K in project). Glad to hear that you also resolved this issue :)

All 15 comments

Are you able to upgrade to Realm 1.0? If yes, then that may fix your issue.

I've made an upgrade to Realm 1.0.0 and now the not found file has changed:

/Users/me/ios-project/Pods/Realm/include/Realm.h:21:9: 'Realm/RLMArray.h' file not found

Please try to clean the whole build folder path / DerivedData and build from scratch, see also https://github.com/realm/realm-cocoa/issues/3676 and https://github.com/realm/realm-cocoa/issues/3723

Hi! I have tried the first solution and the error persists: I'll list what I've done to make sure that I haven't missed anything:

First attempt

  1. Download a clean version of the project
  2. Go to the project's root
  3. Execute the following commands
pod cache clean Realm
pod cache clean RealmSwift #Actually I dont need this since I'm using objective C, but I've added it just in case
pod install
pod deintegrate || rm -rf Pods
pod install --verbose

Result: I'm getting Realm.h not found

I'll try the second approach asap.

Let us know if it helps. Also try to update CocoaPods and Realm to the latest versions.

I'm closing this since we haven't heard back from @lucasp90 in a little while.

I'm sorry! I'm sure I'll be able to look at it next week.

I also have the same issue, umbrella header not found. It seems like a bug of Cocoapods, public headers treat as private headers.

Update
Build success after setting User Header Search Paths to empty instead of ${PODS_ROOT}

@loveforgeter If you have cocoapods 1.0, make sure your build settings for "user paths" or something hasn't been overriden in your target

Well, I had to change my Macbook due to a hardware issue, so I ended up making a fresh install of cocoapods.

gem install cocoapods
pod setup --verbose
cd my/projects/folder
git clone <my repo>
cd path/to/my/repo
pod install

Without making any changes to the repo I'm getting "Realm.h not found"

After that, I've tried updating Realm to the latest version (1.0.1) I've finally made it pass the realm build (now I'm getting an error when I try to get the path of the default realm configuration, but I guess this is because of the library update and I'll read the docs to check it).

So, upgrading to the latest Realm version worked for me

Thanks for letting us know, @lucasp90! Glad to hear that everything is fine now :)

I seem to be having this issue. I have tried everything above (from #3676, #3723, and see below for my output from the verbose install mentioned at the end of https://github.com/realm/realm-cocoa/issues/3735#issuecomment-226522681 )

(please forgive my attempt at removing sensitive info from the message because i don't know what would be sensitive, and may have made the message useless?)

this is the error

CompileSwift normal arm64 /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile.swift
    cd /Users/tgm/dev/project-name/ProjectName
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile1.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile2.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile3.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile4.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile5.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile6.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile7.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile8.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile9.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFile0.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFilea.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFiles.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFiled.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFilef.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFileg.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFileh.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFilej.swift /Users/tgm/dev/project-name/ProjectName/ProjectName/SomeSourceFilek.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk -I /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/BrightFutures -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/MMDrawerController -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/Realm -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/RealmSwift -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/Result -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/SIOSocket -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/Sheriff -F /Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/ionicons -F /Users/tgm/dev/project-name/ProjectName/ProjectName -F /Users/tgm/dev/project-name/ProjectName -F /Users/tgm/dev/project-name/ProjectName/Ionicons/build/Debug-iphoneos -F /Users/tgm/dev/project-name/ProjectName/build/Debug-iphoneos/Pods -F /Users/tgm/dev/project-name/ProjectName/build/Debug-iphoneos -F /Users/tgm/dev/project-name/ProjectName/build/Debug-iphoneos/Pods-ProjectName -enable-testing -g -import-objc-header /Users/tgm/dev/project-name/ProjectName/ProjectName/ProjectName-Bridging-Header.h -module-cache-path /Users/tgm/dev/project-name/ProjectName/DerivedData/ModuleCache -D DEBUG -D DEBUG -D COCOAPODS -serialize-debugging-options -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/ProjectName-generated-files.hmap -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/ProjectName-own-target-headers.hmap -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/ProjectName-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/ProjectName-project-headers.hmap -Xcc -iquotePods/ionicons -Xcc -iquotePods/ionicons/ionicons -Xcc -iquotePods/ionicons/ionicons/ionicons.bundle -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/include -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/DerivedSources/arm64 -Xcc -I/Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/tgm/dev/project-name/ProjectName -emit-module-doc-path /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFile~SomeSourceFileq.swiftdoc -Onone -module-name ProjectName -emit-module-path /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFile~SomeSourceFilew.swiftmodule -serialize-diagnostics-path /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFile.dia -emit-dependencies-path /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFile.d -emit-reference-dependencies-path /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFilee.swiftdeps -o /Users/tgm/dev/project-name/ProjectName/Build/Intermediates/ProjectName.build/Debug-iphoneos/ProjectName.build/Objects-normal/arm64/SomeSourceFile.o

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Realm.h"
        ^
/Users/tgm/dev/project-name/ProjectName/Build/Products/Debug-iphoneos/Realm/Realm.framework/Headers/Realm.h:21:9: error: 'Realm/RLMArray.h' file not found
#import <Realm/RLMArray.h>
        ^
<unknown>:0: error: could not build Objective-C module 'Realm'
<module-includes>:2:9: note: in file included from <module-includes>:2:
#import "Headers/RealmSwift-Swift.h"

The output of pod install --verbose

tgm@Ensemble:~/dev/project-name/ProjectName (feature/realm-db *)$ pod install --verbose
  Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-ProjectName`: (``)
  Using `ARCHS` setting to build architectures of target `Pods-ProjectNameTests`:
  (``)

Finding Podfile changes
  - BrightFutures
  - MMDrawerController
  - RealmSwift
  - SIOSocket
  - Sheriff
  - ionicons

Resolving dependencies of `Podfile`

Comparing resolved specification to the sandbox manifest
  A BrightFutures
  A MMDrawerController
  A Realm
  A RealmSwift
  A Result
  A SIOSocket
  A Sheriff
  A ionicons

Downloading dependencies

-> Installing BrightFutures (3.0.0)
  > Copying BrightFutures from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/BrightFutures/3.0.0-4a3f4`
  to `Pods/BrightFutures`

-> Installing MMDrawerController (0.5.7)
  > Copying MMDrawerController from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/MMDrawerController/0.5.7-7a4cf`
  to `Pods/MMDrawerController`

-> Installing Realm (1.0.1)
 > Git download
 > Git download
     $ /usr/local/bin/git clone https://github.com/realm/realm-cocoa.git
     /var/folders/w8/xfw7gq950m3000pgxvdwd8n40000gn/T/d20160709-37276-a1dnhe
     --template= --single-branch --depth 1 --branch v1.0.1
     Cloning into '/var/folders/w8/xfw7gq950m3000pgxvdwd8n40000gn/T/d20160709-37276-a1dnhe'...
     Note: checking out '90113193edc9a1d7f47dcacf56db7eaa8e7ce328'.

     You are in 'detached HEAD' state. You can look around, make experimental
     changes and commit them, and you can discard any commits you make in this
     state without impacting any branches by performing another checkout.

     If you want to create a new branch to retain commits you create, you may
     do so (now or later) by using -b with the checkout command again. Example:

       git checkout -b new_branch_name

 > Running prepare command
   $ /bin/bash -c  set -e sh build.sh cocoapods-setup
   core is not a symlink. Deleting...
   Downloading dependency: core 1.1.1
  > Copying Realm from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/Realm/1.0.1-2e15e` to
  `Pods/Realm`

-> Installing RealmSwift (1.0.1)
 > Git download
 > Git download
     $ /usr/local/bin/git clone https://github.com/realm/realm-cocoa.git
     /var/folders/w8/xfw7gq950m3000pgxvdwd8n40000gn/T/d20160709-37276-1yh9ynx
     --template= --single-branch --depth 1 --branch v1.0.1
     Cloning into '/var/folders/w8/xfw7gq950m3000pgxvdwd8n40000gn/T/d20160709-37276-1yh9ynx'...
     Note: checking out '90113193edc9a1d7f47dcacf56db7eaa8e7ce328'.

     You are in 'detached HEAD' state. You can look around, make experimental
     changes and commit them, and you can discard any commits you make in this
     state without impacting any branches by performing another checkout.

     If you want to create a new branch to retain commits you create, you may
     do so (now or later) by using -b with the checkout command again. Example:

       git checkout -b new_branch_name

 > Running prepare command
   $ /bin/bash -c  set -e sh build.sh cocoapods-setup swift
   core is not a symlink. Deleting...
   Downloading dependency: core 1.1.1
  > Copying RealmSwift from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/RealmSwift/1.0.1-d73ea` to
  `Pods/RealmSwift`

-> Installing Result (0.6.0-beta.4)
  > Copying Result from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/Result/0.6.0-beta.4-f7927`
  to `Pods/Result`

-> Installing SIOSocket (0.2.0)
  > Copying SIOSocket from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/SIOSocket/0.2.0-2facc` to
  `Pods/SIOSocket`

-> Installing Sheriff (0.3.1)
  > Copying Sheriff from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/Sheriff/0.3.1-e43d6` to
  `Pods/Sheriff`

-> Installing ionicons (2.0.3)
  > Copying ionicons from
  `/Users/tgm/Library/Caches/CocoaPods/Pods/Release/ionicons/2.0.3-ec1e8` to
  `Pods/ionicons`
  - Running pre install hooks

Generating Pods project
  - Creating Pods project
  - Adding source files to Pods project
  - Adding frameworks to Pods project
  - Adding libraries to Pods project
  - Adding resources to Pods project
  - Linking headers
  - Installing targets
    - Installing target `BrightFutures` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/BrightFutures/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/BrightFutures/BrightFutures.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/BrightFutures/BrightFutures-umbrella.h`
    - Installing target `MMDrawerController` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/MMDrawerController/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/MMDrawerController/MMDrawerController.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/MMDrawerController/MMDrawerController-umbrella.h`
    - Installing target `Realm` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/Realm/Info.plist`
      - Copying module map file to `Pods/Target Support
      Files/Realm/Realm.modulemap`
    - Installing target `RealmSwift` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/RealmSwift/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/RealmSwift/RealmSwift.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/RealmSwift/RealmSwift-umbrella.h`
    - Installing target `Result` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/Result/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/Result/Result.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/Result/Result-umbrella.h`
    - Installing target `SIOSocket` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/SIOSocket/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/SIOSocket/SIOSocket.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/SIOSocket/SIOSocket-umbrella.h`
    - Installing target `Sheriff` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/Sheriff/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/Sheriff/Sheriff.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/Sheriff/Sheriff-umbrella.h`
    - Installing target `ionicons` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/ionicons/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/ionicons/ionicons.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/ionicons/ionicons-umbrella.h`
    - Installing target `Pods-ProjectName` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/Pods-ProjectName/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/Pods-ProjectName/Pods-ProjectName.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/Pods-ProjectName/Pods-ProjectName-umbrella.h`
    - Installing target `Pods-ProjectNameTests` iOS 8.0
      - Generating Info.plist file at `Pods/Target Support
      Files/Pods-ProjectNameTests/Info.plist`
      - Generating module map file at `Pods/Target Support
      Files/Pods-ProjectNameTests/Pods-ProjectNameTests.modulemap`
      - Generating umbrella header at `Pods/Target Support
      Files/Pods-ProjectNameTests/Pods-ProjectNameTests-umbrella.h`
  - Running post install hooks
  - Writing Xcode project file to `Pods/Pods.xcodeproj`
    - Generating deterministic UUIDs
  - Writing Lockfile in `Podfile.lock`
  - Writing Manifest in `Pods/Manifest.lock`

Integrating client project

Integrating target `Pods-ProjectName` (`ProjectName.xcodeproj` project)

Integrating target `Pods-ProjectNameTests` (`ProjectName.xcodeproj` project)
  - Running post install hooks
    - cocoapods-stats from
    `/Users/tgm/.rvm/gems/ruby-2.3.0@global/gems/cocoapods-stats-1.0.0/lib/cocoapods_plugin.rb`

Sending stats
      - BrightFutures, 3.0.0
      - MMDrawerController, 0.5.7
      - Realm, 1.0.1
      - RealmSwift, 1.0.1
      - Result, 0.6.0-beta.4
      - SIOSocket, 0.2.0
      - Sheriff, 0.3.1
      - ionicons, 2.0.3
  Pod installation complete! There are 6 dependencies from the Podfile and 8
  total pods installed.

@thegreatmichael what version of CocoaPods you use? Try to upgrade to the latest 1.0.1 version. Also check "Headers search paths" in your project's build settings, make sure that it doesn't override CocoaPods path.

thanks for checking in @stel, i am on 1.0.1 /-: My User Header Search Paths is $(PODS_ROOT) recursive and $(PODS_ROOT)/ionicons recursive.

update:
so, i just started at the top of this thread again, I (have my project working fine on another machine, and so I) checked out my project again, did as in https://github.com/realm/realm-cocoa/issues/3735#issuecomment-226522681 and made sure my User Header Search Paths is empty, and doggonit, it works!!

@thegreatmichael faced with this issue by myself today :) My solution was to remove all Xcode's Derived Data (or alt+shift+cmd+K in project). Glad to hear that you also resolved this issue :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javierjulio picture javierjulio  路  3Comments

fadylateef picture fadylateef  路  3Comments

matteodanelli picture matteodanelli  路  3Comments

TheHmmka picture TheHmmka  路  3Comments

dennisgec picture dennisgec  路  3Comments