awslabs / aws-crt-swift

Apache License 2.0
15 stars 17 forks source link

Unable to use swift-api-digester when aws-crt-swift is a dependency #267

Open rozaychen opened 4 months ago

rozaychen commented 4 months ago

Describe the bug

Hi!

I have aws-crt-swift as a dependency of my library (integrated with SPM). I'd like to use swift-api-digester to diagnose breaking API changes. I do this by running swift build and then swift api-digester. These are the commands I run:

swift build --target $module

swift api-digester -swift-only -sdk "$(xcrun --show-sdk-path)" -dump-sdk -module "$module" \
        -o "./api-dump/$module.json" -I .build/debug

The build command succeeds; however, the swift-api-digester fails with this error:

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/rozayc/Downloads/amplify-swift/.build/checkouts/aws-crt-swift/aws-common-runtime/aws-c-cal/include/aws/cal/cal.h"
        ^
/Users/rozayc/Downloads/amplify-swift/.build/checkouts/aws-crt-swift/aws-common-runtime/aws-c-cal/include/aws/cal/cal.h:8:10: error: 'aws/common/common.h' file not found
#include <aws/common/common.h>
         ^
<unknown>:0: error: could not build Objective-C module 'AwsCCal'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/rozayc/Downloads/amplify-swift/.build/checkouts/aws-crt-swift/aws-common-runtime/aws-c-auth/include/aws/auth/auth.h"
        ^
Failed to load module: AWSCloudWatchLoggingPlugin

I tried to debug by running swift build then swift api-digester in aws-crt-swift, and I get this error:

rozayc@6c7e67cb160a Downloads % ./generate_api_files.sh 
warning: 'aws-crt-swift': Invalid Exclude '/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-io/THIRD-PARTY-LICENSES.txt': File not found.
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.26s)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-auth/include/aws/auth/auth.h"
        ^
/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-auth/include/aws/auth/auth.h:9:10: error: 'aws/auth/exports.h' file not found
#include <aws/auth/exports.h>
         ^
<unknown>:0: error: could not build Objective-C module 'AwsCAuth'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-cal/include/aws/cal/cal.h"
        ^
Failed to load module: AwsCommonRuntimeKit

Do you have any recommendations for how I might be able to solve this issue? Thanks!

Expected Behavior

Expected to generate json file in the api-dump folder when running swift api-digester

Current Behavior

Has the failed to load module error

Reproduction Steps

In the aws-crt-swift directory, run swift build Then run swift api-digester -sdk "$(xcrun --show-sdk-path)" -dump-sdk -module "AwsCommonRuntimeKit" -o ./api-dump/AwsCommonRuntimeKit.json -I .build/debug

Possible Solution

No response

Additional Information/Context

No response

aws-crt-swift version used

0.26.0

Compiler and Version used

swift 5.9.0

Operating System and version

macos v14.4.1

DmitriyMusatkin commented 4 months ago

make sure to do a recursive git clone when getting the code. looks like its not picking up submodules.

rozaychen commented 4 months ago

I get the same error message after running swift package clean and git clone --recursive https://github.com/awslabs/aws-crt-swift.git. Seems like it's not problem with recursive git clone.

DmitriyMusatkin commented 4 months ago

Can you try git clone --recurse-submodules https://github.com/awslabs/aws-crt-swift.git?

rozaychen commented 4 months ago

I tried Running this command then api-digester, I also tried running git submodule update --init --recursive instead, but both commands doesn't change anything. I'm still getting


#import "/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-auth/include/aws/auth/auth.h"
        ^
/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-auth/include/aws/auth/auth.h:9:10: error: 'aws/auth/exports.h' file not found
#include <aws/auth/exports.h>
         ^
<unknown>:0: error: could not build Objective-C module 'AwsCAuth'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/Users/rozayc/Downloads/aws-crt-swift/aws-common-runtime/aws-c-cal/include/aws/cal/cal.h"
        ^
Failed to load module: AwsCommonRuntimeKit