71

In iOS, I update 7.2. I'm able to build my existing project to my device with no problem. When it came time to archive the project to prepare for submission to the app store, however, I'm getting a build error - Cordova/CDVViewController.h file not found. I've gone through just about every fix/workaround that I've not found Stack Overflow, and Google, and none of them have worked for me. If I go back to Xcode 6.4 I can build and archive no problem, but I can't build to my device now that it's running iOS 9.1.

I'm guessing it's a configuration issue somewhere with the new Xcode version setup. Has anyone else run into this? Again, the usual suspects (Preferences > Location > Derived Data > Advanced > Unique), Header Search Paths, etc. all seem to be fine.

Thanks, Adisheshu

Adisheshu RY
  • 873
  • 1
  • 7
  • 10

19 Answers19

238

This issues seems to appear in Xcode 7.2 due to search path/include.

Solve this in following way:

  1. Select your [projectName] in Xcode TARGETS.

  2. Go to Build Settings tab.

  3. Make sure that the filter is set to "All" and not "Basic".

  4. Search "Header Search Paths"

  5. Double click and add this path to both "Debug" and "Release": $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

  6. Now clean the Project and restart Xcode.

  7. Able to make the Build and Archive.

  8. That's All.

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
ArunDhwaj IIITH
  • 3,833
  • 1
  • 24
  • 14
  • 5
    This is the correct answer. Also worth noting: The build settings tab defaults to the 'Basic' filter. Make sure that 'All' is selected or you won't see the Header Search Paths field. – jmknoll Jan 11 '16 at 11:06
  • 18
    I see this answer thrown about a lot, but my project already has this exact same string as part of the search header paths but the file is still not found. :-( – simbolo Feb 29 '16 at 12:01
  • 3
    Don't forget to add this to all pahts, Release, not only Debug. I first only added to Debug and missed Release and it didn't help. Adding to Release fixed the issue. Thanks! – wojjas Jun 13 '16 at 13:47
  • 2
    I had to also delete the old one: $(OBJROOT)/UninstalledProducts/include Then the Archive would run. Not before. – pdschuller Jul 07 '16 at 02:42
  • 4
    For those that don't remember the shortcut to clean your project, press `Shift-Cmd-K` – pbojinov Aug 22 '16 at 21:47
  • 1
    FYI I didn't need to do a clean build or restart XCode. – Jonathon Horsman Oct 13 '16 at 11:01
69

After trying every solution with no success I ran:

cordova platform update ios

This fixed it for me. (XCODE 7.3.1, Cordova 6.3.0)

Reference: Cordova app failing to Archive with Xcode 7.1 (Cordova/CDVViewController.h file not found)

Community
  • 1
  • 1
Dom Hede
  • 1,066
  • 9
  • 19
  • Thanks. I have Xcode Version 7.2 and this fixed my issue. – Ishara Amarasekera Oct 17 '16 at 15:22
  • Oddly enough, this seems to make this worse for me. I have to remove ios and then add it again before I can get rid of the addition xcode errors. – Jacksonkr Jan 02 '17 at 10:37
  • This fixed my issue with cordova 7.1 and the inappbrowser plugin which uses CDVViewController.h; https://github.com/purplecabbage/GDCordova/blob/master/docs/How%20to%20Use%20Cordova%20as%20a%20Component.md – Lothre1 Jul 11 '17 at 21:13
  • This fixed my issue with Xcode 10.2 and Cordova 6.0.0. – Vadim Apr 05 '19 at 16:53
7

If adding this line:

$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

to the headers-search-path (as described in 'im3r3k' answer) didn't fixed this issue, also set this:

Build Settings -> Architectures -> Build Active Architecture Only -> YES
Gil Epshtain
  • 8,670
  • 7
  • 63
  • 89
6

You should update your project's Cordova iOS version to 3.9.2 (latest version of 3 as of 3/11/16). I got this same error when using 3.8.0 and it was fixed in 3.9.

Alternatively, you could upgrade to Cordova iOS v4.1.0 (bleeding edge as of 3/11/16) but be aware you lose support for iOS 6 and 7, and cordova-plugin-screen-orientation isn't updated to use 4 yet so you have to lock your app in portrait or landscape.

EDIT:

Without upgrading you can fix this manually in XCode. go to

Build Settings -> Header Search Paths : Change:

$(OBJROOT)/UninstalledProducts/include

to:

$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

(related issue on apache.org)

im3r3k
  • 503
  • 1
  • 7
  • 14
4

This fixed it for me:

  • Open your project in Xcode
  • Go to Preference -> Locations -> Advanced
  • Choose "Unique" as the option for Build Location
  • Product -> Clean
  • Product -> Build

Taken from https://forum.ionicframework.com/t/cordova-cdvviewcontroller-h-file-not-found-in-xcode-7-1-beta/32232/40

mles
  • 4,534
  • 10
  • 54
  • 94
  • 1
    I've tried all other changes in build config, but finally with this my project could be installed on a real device – iflorit Apr 19 '17 at 13:31
  • 1
    I tried all the above changes too, and NONE of them worked; I had upgraded from an ancient version of Xcode (back when it worked with my iPod),to the now version 8.3, and all the paths that needed to be added above, were already in the debug and the release, but it still could not find them; adding Unique worked, woohoo, thank you! – Captain Fantastic Jul 24 '17 at 12:52
3

I also had this problem but for me adding path to Header Search was not enough. I have added CDVViewController.h to "public" section into subproject CordovaLib.xcodeproj -> CordovaLib(target) -> Build Phases -> Headers -> Public

Andrew Bogaevskyi
  • 2,251
  • 21
  • 25
3

For me the $(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include was already in the Header Search Paths (using XCode 8 in El Capitan). I then added to User Header Search Paths the specific path to CordovaLib folder, with recursive option enabled (for unexperienced XCode users like myself, select the project in the tree view (1st node) to see "Build Settings"!!)

But watch out for spaces! After a lot of missings it was safer to just drag the folder from a finder window, and it filled as $(SRCROOT)/.. (cont.), which was not expected but did work..

Also in XCode/Preferences/Locations/Custom Paths I've added a CORDOVALIB name with the same folder as before, in the same manner (this time, the full path was used, without the $(SRCROOT) thing).

Took me quite some hours to figure all out...

Bernardo Dal Corno
  • 1,858
  • 1
  • 22
  • 27
  • 1
    If you have spaces in a path you can add quotations around it `"$(SOME_VAR)some path/with spaces"` – Jacksonkr Dec 30 '16 at 15:19
  • Thanks @Jacksonkr. Not sure if I didn't try that (which is obvious, but quite useful) or if the path was so long I got lost in it. Still a great remark, though, thanks. – Bernardo Dal Corno Jan 05 '17 at 12:46
2

The above solutions did not work for me.

In my case, when I build my iOS platform, CordovaLib folder was not included.
1. Delete existing CordovaLib.xcodeproj
2. Add existing files. Add CordovaLib.xcodeproj from CordovaLib folder
3. Add dependencies and select CordovaLib
4. Add link Binaries with library and select libCordova.a

Thats it!

h3n
  • 5,142
  • 9
  • 46
  • 76
1

I was using xcode 7.3 and I was having the same problem. In my case the error was due to an error that was happening when executing "cordova platform add ios", an error was ocurring because an image couldn't be found in res folder and this was avoiding cordova platform add ios to finish correctly.

1
  1. In your Xcode project settings select TARGETS
  2. Within TARGETS select the Build Settings tab
  3. In the sub-options under the Build Settings tab be sure to select All
  4. Scroll down to the Search Paths section
  5. Locate Header Search Paths
  6. Add the following configuration to the Release option (as a new value on its own line):$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include
  7. Clean the project: Command + Shift + K
  8. Restart Xcode

The following screenshot demonstrates what you should see in Xcode 7.2 after following steps 1 to 6 (the line highlighted in blue displays the added configuration): enter image description here

Dinesh Vaitage
  • 2,983
  • 19
  • 16
1

One of the issue in my case was the one plugin cordova-plugin-inappbrowser. Make sure your plugins are updated.

Inshal Irshad
  • 227
  • 3
  • 17
0

Also set ENABLE BITCODE = NO in the Build Settings

dijipiji
  • 3,063
  • 1
  • 26
  • 21
0

I had the same issue so i just removed <icon src="icon.png" /> from config file. then I removed&addded IOS platform using cordova platform remove ios then cordova platform add ios

Alamri
  • 2,112
  • 2
  • 16
  • 21
0

For me following worked

Xcode 8.1 ios 10.x

(target -> Build Settings -> Header search paths )

"${PODS_ROOT}/Cordova/CordovaLib/Classes/Public"

as

"${PODS_ROOT}/Headers/Public" folder was empty

Chirag Purohit
  • 731
  • 11
  • 20
0

I faced this issue when I removed and re-added the project, some resources files such as icons or splashes screen not found made the project doesn't create at all.

infinito84
  • 1,971
  • 17
  • 8
0

The CDV.h file is present in CordovaLib/CordovaLib.xcodeproj/public. You can give this path and worked for me.

I don't know how to give relative path. So I dragged/dropped the file and put it in "" with #import like:

#import "dragged file full path"
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Laksh
  • 41
  • 2
0

Uninstall And reinstall Cordova Platform

cordova platform rm ios

cordova platform add ios
0

I encountered this kind of problem.

 'Cordova/CDVJSON_private.h' file not found

solution: click: Pods -> Cordova -> build phase -> Headers, and then move all of the items into public tab.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 20 '22 at 17:04
-1

supplementing the response. Add

"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"

Don't replace the existing line that looks similar, that is still needed to be backwards compatible with Xcode 7 and Xcode 6.4.

click here