Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unistd.h" should be <unistd.h> #5419

Closed
eddieSullivan opened this issue Aug 6, 2024 · 9 comments
Closed

"unistd.h" should be <unistd.h> #5419

eddieSullivan opened this issue Aug 6, 2024 · 9 comments
Assignees
Labels
bug Something isn't working build Issues related to build problems and CI/CD core Issues related to AWSCore

Comments

@eddieSullivan
Copy link
Contributor

Describe the bug
There are two Objective-C source files that #include "unistd.h", however, since this is a system header, it should be #include <unistd.h>

Using the double-quotes instead of angle brackets causes the file to be searched for in a different set of directories. This means that if there is a non-system header file of the same name, that one will be included rather than the system file.

In my case, this causes a build failure in my React Native app when I upgrade to React Native version 0.74.5, because the "RCT-Folly" library has its own version of "unistd.h", which AWSCore tries to use.

The Objective-C files in question are:
AWSCore/FMDB/AWSFMResultSet.m

and:

AWSCore/FMDB/AWSFMDatabase.m

To Reproduce
Steps to reproduce the behavior:

  1. Create a new React Native project with npx @react-native-community/cli@latest init AwesomeProject --version 0.74.5
  2. cd AwesomeProject
  3. npm install
  4. cd ios
  5. Add pod 'AWSCore' to the "AwesomeProject" target in AwesomeProject/ios/Podfile
  6. pod install
  7. xed . and try to build the workspace in Xcode (I'm on 15.4.0)

Observed Behavior
The build fails.

Expected Behavior
A successful build.

Stack Trace

In file included from /home/src/AwesomeProject/ios/Pods/AWSCore/AWSCore/FMDB/AWSFMResultSet.m:3:
/home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:24:1: error: unknown type name 'using'
using off64_t = off_t;
^
/home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:24:17: error: unexpected type name 'off_t': expected expression
using off64_t = off_t;
                ^
/home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:26:1: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t lseek64(int fh, off64_t off, int orig);
^~~~~~~
off_t
In module 'Darwin' imported from /home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:21:
/Applications/Xcode-15.4.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 'off_t' declared here
typedef __darwin_off_t          off_t;
                                ^
In file included from /home/src/AwesomeProject/ios/Pods/AWSCore/AWSCore/FMDB/AWSFMResultSet.m:3:
/home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:26:25: error: unknown type name 'off64_t'; did you mean 'off_t'?
off64_t lseek64(int fh, off64_t off, int orig);
                        ^~~~~~~
                        off_t
In module 'Darwin' imported from /home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:21:
/Applications/Xcode-15.4.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 'off_t' declared here
typedef __darwin_off_t          off_t;
                                ^
In file included from /home/src/AwesomeProject/ios/Pods/AWSCore/AWSCore/FMDB/AWSFMResultSet.m:3:
/home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:28:50: error: unknown type name 'off64_t'; did you mean 'off_t'?
ssize_t pread64(int fd, void* buf, size_t count, off64_t offset);
                                                 ^~~~~~~
                                                 off_t
In module 'Darwin' imported from /home/src/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/Unistd.h:21:
/Applications/Xcode-15.4.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/include/sys/_types/_off_t.h:31:33: note: 'off_t' declared here
typedef __darwin_off_t          off_t;
                                ^
5 errors generated.

Code Snippet

#include "unistd.h"

Unique Configuration
A React Native app

Environment(please complete the following information):

  • SDK Version: 2.35.0
  • Dependency Manager: Cocoapods
  • Xcode Version: 15.4.0
@thisisabhash thisisabhash added core Issues related to AWSCore build Issues related to build problems and CI/CD bug Something isn't working labels Aug 7, 2024
@pgom
Copy link

pgom commented Aug 7, 2024

@eddieSullivan that tip was really great since I was spending hours debugging an issue related to this. @thisisabhash I'm patching the Pod file with is changing is a solution but having this directly added would be great

@thisisabhash
Copy link
Member

Thank you for your message - our team will take a look and post updates.

@decim92
Copy link

decim92 commented Aug 13, 2024

Hi, is there a workaround for this? like downgrading react native or AWS?

@NirN-Venn
Copy link

Getting the same error after updating from rn 0.71.11 to 0.74.5.

@tylerjroach tylerjroach added the pending-maintainer-response Issue is pending response from an Amplify team member label Aug 13, 2024
@markgaucher
Copy link

I'm receiving a similar error after upgrading React Native from 0.73.6 to 0.74.5.

@lawmicha
Copy link
Contributor

Thanks for the updates, we are investigating this (#5425) and will provide an update when we can.

@lawmicha lawmicha added work in progress Issues was triaged and investigation done and removed pending-maintainer-response Issue is pending response from an Amplify team member labels Aug 19, 2024
@eddieSullivan
Copy link
Contributor Author

In my Podfile I added this to the end of my post_install block. It's a hack for sure but it's a temporary workaround:

  unistd_file = File.join(__dir__, 'Pods/AWSCore/AWSCore/FMDB/unistd.h')
  unless File.exist?(unistd_file)
    File.open(unistd_file, 'w') do |f|
      f.write("#include <unistd.h>\n")
    end
  end

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Aug 20, 2024
@thisisabhash
Copy link
Member

The changes are released in https://github.com/aws-amplify/aws-sdk-ios/releases/tag/2.37.0

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Aug 23, 2024
@thisisabhash thisisabhash added pending-maintainer-response Issue is pending response from an Amplify team member and removed work in progress Issues was triaged and investigation done pending-maintainer-response Issue is pending response from an Amplify team member labels Aug 23, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Issues related to build problems and CI/CD core Issues related to AWSCore
Projects
None yet
Development

No branches or pull requests

9 participants