React-native-app-auth: Argument list too long: recursive header expansion failed

Created on 31 May 2018  Â·  21Comments  Â·  Source: FormidableLabs/react-native-app-auth

After integrating react-native-app-auth with our project, our iOS build is now failing with the following error:

```=== BUILD TARGET RNAppAuth OF PROJECT RNAppAuth WITH CONFIGURATION Debug ===

Check dependencies

Argument list too long: recursive header expansion failed at /Users/username/app_name/node_modules/react-native-app-auth/ios/../../../ios/build/Index/DataStore/v5/records/UW.
```

The problem seems to be the result of an overly aggressive HEADER_SEARCH_PATHS build setting causing Xcode to give up after it recurses through too many sub-directories for RNAppAuth's required header files. Other react native libraries have similar issues reported, and have resolved the issue by modifying HEADER_SEARCH_PATHS to be more specific than the current $(PROJECT_DIR)/../../../ios/**

I tried setting the HEADER_SEARCH_PATHS to $(PROJECT_DIR)/../../../ios/Pods/** but that produced other build errors.

Other libraries with similar problems:
https://github.com/react-native-community/react-native-camera/issues/1407
https://github.com/Microsoft/AppCenter-SDK-React-Native/issues/209

Most helpful comment

This should finally be fixed in v3.0.2. Please let me know is the problem persists.

All 21 comments

Hi..good morning @sjmorrow...have you faced @https://github.com/FormidableLabs/react-native-app-auth/issues/113 this kind of issue ?..i am stuck with this..can you help me to resolve it ? please

Yes, looks like it's an error in the newest versions of RN, I've just tried it on the latest version and getting a similar error.

Thanks for the tip, I'll have a look updating the HEADER_SEARCH_PATHS 🤔

Thanks mam for replying me..please let me know if something tackle on it..i am using android emulator and your help would be greatly appreciate.
On Friday, June 1, 2018, 2:19:32 PM GMT+5:30, Kadi Kraman notifications@github.com wrote:

Yes, looks like it's an error in the newest versions of RN, I've just tried it on the latest version and getting a similar error.
/Users/kadikraman/TestNewReact/node_modules/react-native-app-auth/ios/RNAppAuth.m:3:9: fatal error: 'AppAuth/AppAuth.h' file not found

import

Thanks for the tip, I'll have a look updating the HEADER_SEARCH_PATHS 🤔

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

For us, there was a conflict with some of the other installed pods. Had to edit header search paths, but also had to make sure not to include whole pods folder or it would use the headers from other pods which would cause the build to fail. Right now we have to reference the project folder directly by name, not sure if there is a generic solution that would work for everyone which could be merged.

Working search paths for us in RNAppAuth.xcodeproj set like below, replace "yourProjectName" with your project name.

$(inherited)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
$(SRCROOT)/../../../React
$(SRCROOT)/../../react-native/React
$(SRCROOT)/../../../ios/Pods/AppAuth
$(SRCROOT)/../../../ios/Pods/Headers
$(SRCROOT)/../../../ios/yourProjectName

Thanks for the tip, @nol13. I've been playing around with the HEADER_SEARCH_PATH values but couldn't find something that worked. I'll try what you're suggesting.

I'm willing to work on a patch if provided with what specifically needs to be changed.

P.S. The workaround did work for me, @nol13. Thanks again.

Thanks a lot for the investigating work @nol13 and @BradfordTaylor!

I've excitedly made a PR to fix this and realised I don't think it will be possible.

The reason we were searching from /ios level originally was because we need to have access to the the project's AppDelegate for deep linking back into the app after the auth step, but there's no way for us to know what the project will be called form the library level.

I tried to add "$(SRCROOT)/../../../ios/$(PROJECT_NAME)/**" to the header search paths, but of course that will never work, as the header search paths for the _library_, not the project using it, so $(PROJECT_NAME) will be RNAppAuth, not YourProjectName.

Unless anyone knows of a solution, we'll just have to recommend this workaround for now.

Ya that was the same place I got to. Maybe a postinstall script that parses the directory structure and regex replaces the project name? Feels like the 'wrong' way but don't see why it couldn't work

Not sure how robust this is, but something along the lines of..

const {readdirSync, readFile, writeFile} = require('fs');
const {join} = require('path');

let projectName;
for (let d of readdirSync('../../ios')) {
  // find the folder that ends in .xcodeproj and strip end to get project name
  if (/\.xcodeproj/.test(d)) {
    projectName = d.substring(0, d.length - 10);
  }
}

if (projectName) {
  // find and replace our place holder string in project file with projectName
  readFile('./ios/RNAppAuth.xcodeproj/project.pbxproj', 'utf8', function (err,data) {
    if (err) {
      // throw err
    }
    var result = data.replace(/##someUniqueString##/g, projectName);
    writeFile('./ios/RNAppAuth.xcodeproj/project.pbxproj', result, 'utf8', function (err) {
      // throw err
    });
  });
}

Hi all,
I have fixed this issue for changeng HEADER_SEARCH_PATHS from "$(SRCROOT)/../../../ios/**" to
"$(SRCROOT)/../../../ios/Pods/Headers/Public",
"$(SRCROOT)/../../../ios/{rootProjectName}",

We have main issue with rootProjectName becouse it depends on appDelegate. I have found next line
appDelegate.currentAuthorizationFlow = ...

I have created the branch with a possible fix. Please check https://github.com/laktarugar/react-native-app-auth/tree/fix/recursive_header

Nice! Yes that looks like it would work! It would have to be released as a major version though as it won't be backwards compatible.

This fix does not seem to work for me. Upon making the HEADER_SEARCH_PATH changes,
I get "fatal error: 'AppAuth/AppAuth.h' file not found #import ".
in RNAppAuth.m Line 3

@EvanWestermann Did you install cocoa pods? What did you use fix?

Downgrading to v2.4.0 fixed this error for me. This commit specifically breaks the import in our build and causes the "fatal error: 'AppAuth/AppAuth.h' file not found #import ".
in RNAppAuth.m Line 3 error.

https://github.com/FormidableLabs/react-native-app-auth/commit/2f714cb5cf5fcf5da2d0d26b6ced0689a2ccda04#diff-9d58d422456571f1c785f3ec104e859d

Hmm I changed it when someone suggested that was a more "correct" syntax. As far as I understand it, there are 3 kinds of imports:

<AppAuth/AppAuth.h> is when the header is part of a static lib or framework.
#import "AppAuth.h" when the header is in your source or part of a sub project
@import UIKit; is for clang modules

Since AppAuth is a third party library we're using, the first import should be correct.

The angle brace syntax is most correct when using a third-party library. However, currently creating a new project will fail to build when following the instructions from the README—using both manual installation and with CocoaPods. The same setup works with v2.4.0. At the surface, it seems the search paths still aren't right, but I don't know why it wouldn't work from a cursory glance.

I believe I was getting the "'AppAuth/AppAuth.h' file not found" error after updating the headers, but before running a "react-native start --reset-cache". That was many error messages ago so I forget exactly, and probably not what you're running into, but worth a try if you haven't tried clearing it recently.

I'm having this same issue trying to use the library for the first time, and rolling back to 2.4.0 doesn't seem to fix it.

Is there any straightforward way to get it running for the time being?

Will 3.0.0 fix this?

Yes, it should! 3.0.0 essentially implements @laktarugar 's suggestion and removes the dependency on AppDelegate. Just hoping someone can confirm the fix. (Worth nothing the iOS instructions have changed in v3.

@kadikraman Unfortunately 3.0.0 does not resolve the issue, it is still reporting header expansion failed at

react-native-app-auth/ios/../../../ios/DerivedData/<app>/Index/DataStore/v5/record/6W
Running react native 0.56.0

Do we have any update on this issue 3.0.1 does not resolve this issue and in fact degrading to 2.4.0 also giving the same error

This should finally be fixed in v3.0.2. Please let me know is the problem persists.

Was this page helpful?
0 / 5 - 0 ratings