React Native XcodeBuild fails on header import

I am attempting to build a React Native application on an Os X CircleCI box.

My circle.yml is as follows:

machine:
  xcode:
    version: 8.3.3
  environment:
    PATH: '$PATH:$HOME/node/node-v4.4.3-darwin-x64/bin'

dependencies:
  pre:
    - brew install node
    - npm install -g react-native-cli
    - npm install
    - react-native link

test:
  override:
    - set -o pipefail && xcodebuild -project 'ios/myApp.xcodeproj' -scheme 'myApp' clean build test -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=9.0,name=iPhone 6' CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= | tee $CIRCLE_ARTIFACTS/xcode_raw.log | xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml

Which fails with:

  /Users/distiller/my-app/ios/myApp/AppDelegate.m:12:9: 'React/RCTBundleURLProvider.h' file not found

 #import <React/RCTBundleURLProvider.h>

My package.json is follows:

{
  "name": "myApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "test-watch": "jest --watch",
    "test-coverage": "jest --coverage"
  },
  "dependencies": {
    "@turf/circle": "^4.5.2",
    "@turf/envelope": "^4.5.2",
    "@turf/helpers": "^4.5.2",
    "gl-react-native": "^2.42.3",
    "react": "~15.4.0-rc.4",
    "react-addons-test-utils": "^15.4.2",
    "react-dom": "^15.6.1",
    "react-native": "0.39.2",
    "react-native-config": "0.5.0",
    "react-navigation": "^1.0.0-beta.11",
    "react-test-renderer": "^15.6.1"
  },
  "devDependencies": {
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "2.0.0",
    "enzyme": "^2.9.1",
    "enzyme-to-json": "^1.5.1",
    "jest": "20.0.4"
  },
  "rnpm": {
    "assets": [
      "assets/fonts"
    ]
  },
  "jest": {
    "preset": "react-native",
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "coverageDirectory": "__coverage__",
    "snapshotSerializers": [
      "./node_modules/enzyme-to-json/serializer"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|native-base|react-navigation|react-native-fabric)"
    ],
    "setupFiles": [
      "./test-setup.js"
    ]
  }
}

By running a build with ssh enabled and inspecting the version, I can say that react-native-cli is installed at 2.0.1

Interestingly, this behaviour does not exhibit when the project is built (with the exact same command) on my machine (localhost)

By googling, I have found things like: https://stackoverflow.com/questions/41704534/react-native-0-40-0-rctbundleurlprovider-h-file-not-found-appdelegate-m

Describing my problem exactly, however they are all limited to RN 4.0, while my package.json is explicitly pegged at 3.9.2

Any help would be greatly appreciated!

The solution seemed to be to delete my ios/build directory. Once I did so, I started having the same behavior locally as in CircleCi (which I could then fix by simply taking React out of the import path like so:

#import <RCTBundleURLProvider.h>