Open achew22 opened 2 years ago
Sorry for the delay in my response.
I think that you are running into the issue where the repository name does not match the package name. The Stripe Package.swift
specifies the name of the package as Stripe
. The spm_repositories
rule needs to know the name of the package to set up the Bazel packages. By default, it uses the basename of the git repository. When the basename of the git repository does not match the name specified in the Package.swift
, rules_spm
can't find what it expects to find.
If you add the name
attribute to the spm_pkg
and update your BUILD
file to point to @swift_pkgs//Stripe:Stripe
, rules_spm
should be able to fetch and start compiling the project.
spm_repositories(
name = "swift_pkgs",
dependencies = [
spm_pkg(
"https://github.com/stripe/stripe-ios.git",
name = "Stripe",
exact_version = "22.6.0",
products = ["Stripe"], # https://github.com/stripe/stripe-ios/blob/f5b0b5973aaa7ce6a2865e56f5942637cfef53f7/Package.swift#L11-L14
),
],
)
That seems to address the fetch issue. Unfortunately, I am seeing a compilation issue with the Stripe package. I'll poke at it for a minute to glean some information.
I cloned stripe/strip-ios and ran swift build
. I am getting the following output:
❯ swift build
Building for debugging...
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/UIColor+ThirteenSupport.m:9:
/Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/UIColor+ThirteenSupport.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/STDSTextFieldCustomization.m:9:
'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/UIViewController+Stripe3DS2.m:9:
: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/STDSTransaction.m:9:
/Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/include/STDSTransaction.h:10:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/UIColor+DefaultColors.m:9:
/Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/UIColor+DefaultColors.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/STDSThreeDS2Service.m:18:
In file included from /Users/chuck/code/stripe/stripe-ios/Stripe3DS2/Stripe3DS2/STDSDirectoryServerCertificate.h:13:
9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
1 error generated.
1 error generated.
[461/539] Compiling Stripe3DS2 UIColor+ThirteenSupport.m
Does building the Stripe package work for you?
Huh, I get very similar errors.
swift build
Building for debugging...
In file included from /Users/achew/Projects/stripe-ios/Stripe3DS2/Stripe3DS2/UIViewController+Stripe3DS2.m:9:
/Users/achew/Projects/stripe-ios/Stripe3DS2/Stripe3DS2/UIViewController+Stripe3DS2.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
In file included from /Users/achew/Projects/stripe-ios/Stripe3DS2/Stripe3DS2/UIFont+DefaultFonts.m:9:
/Users/achew/Projects/stripe-ios/Stripe3DS2/Stripe3DS2/UIFont+DefaultFonts.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
1 error generated.
[460/539] Compiling Stripe3DS2 UIViewController+Stripe3DS2.m
I wonder in what way I'm hodling it wrong... Let's ask https://github.com/stripe/stripe-ios/issues/1983
Looking at the response from the stripe team, I think the issue is in rules_spm. I modified my import following your instructions but now I get the following output:
spm_repositories(
name = "swift_pkgs",
dependencies = [
spm_pkg(
url = "https://github.com/pointfreeco/swift-composable-architecture.git",
exact_version = "0.38.3",
products = ["ComposableArchitecture"],
),
spm_pkg(
"https://github.com/stripe/stripe-ios-spm.git",
name = "Stripe",
exact_version = "22.6.0",
products = ["Stripe"],
),
spm_pkg(
"https://github.com/pointfreeco/combine-schedulers.git",
exact_version = "0.6.0",
products = ["CombineSchedulers"],
),
spm_pkg(
"https://github.com/square/Valet",
exact_version = "4.1.2",
products = ["Valet"],
),
spm_pkg(
"https://github.com/grpc/grpc-swift",
exact_version = "1.7.3",
products = ["GRPC"],
),
spm_pkg(
"https://github.com/apple/swift-nio-ssl.git",
exact_version = "2.19.0",
products = ["NIOSSL"],
),
],
platforms = [
".iOS(.v14)",
".macOS(.v10_15)",
],
)
Note that I include the platform .iOS(.v14)
which I would expect to bring in UIKit
.
In file included from /private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/stripe-ios-spm/Stripe3DS2/Stripe3DS2/UIViewController+Stripe3DS2.m:9:
/private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/stripe-ios-spm/Stripe3DS2/Stripe3DS2/UIViewController+Stripe3DS2.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
#import <UIKit/UIKit.h>
^~~~~~~~~~~~~~~
[323/851] Compiling Stripe3DS2 resource_bundle_accessor.m
clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
1 error generated.
[323/851] Compiling Stripe3DS2 UIViewController+Stripe3DS2.m
[323/851] Compiling Stripe3DS2 UIView+LayoutSupport.m
[324/851] Compiling cipher.c
[325/851] Compiling aes_nohw.c
[326/851] Compiling aes128gcmsiv-x86_64.mac.x86_64.S
[327/851] Compiling printf.c
[328/851] Compiling socket.c
[329/851] Compiling pair.c
[330/851] Compiling hexdump.c
/private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/Valet/Sources/Valet/SecureEnclave.swift:69:26: warning: 'kSecUseOperationPrompt' was deprecated in iOS 14.0: Use kSecUseAuthenticationContext and set LAContext.localizedReason property
secItemQuery[kSecUseOperationPrompt as String] = userPrompt
^
/private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/Valet/Sources/Valet/SecureEnclave.swift:82:59: warning: 'kSecUseAuthenticationUIFail' was deprecated in iOS 14.0: Instead of kSecUseAuthenticationUI, use kSecUseAuthenticationContext and set LAContext.interactionNotAllowed property
secItemQuery[kSecUseAuthenticationUI as String] = kSecUseAuthenticationUIFail
^
/private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/Valet/Sources/Valet/SecureEnclave.swift:118:26: warning: 'kSecUseOperationPrompt' was deprecated in iOS 14.0: Use kSecUseAuthenticationContext and set LAContext.localizedReason property
secItemQuery[kSecUseOperationPrompt as String] = userPrompt
^
/private/var/tmp/_bazel_achew/86cdfd37d379cf1772409fa48c6ef35e/sandbox/darwin-sandbox/4139/execroot/__main__/bazel-out/ios-sim_arm64-min15.0-applebin_ios-ios_sim_arm64-fastbuild-ST-4e6c2a19403f/bin/external/swift_pkgs/spm_build/checkouts/Valet/Sources/Valet/SinglePromptSecureEnclaveValet.swift:197:30: warning: 'kSecUseOperationPrompt' was deprecated in iOS 14.0: Use kSecUseAuthenticationContext and set LAContext.localizedReason property
secItemQuery[kSecUseOperationPrompt as String] = userPrompt
^
Do you have any theories @cgrindel ?
Were you able to clone their repo and run swift build
? If so, did you have to specify some additional flags (e.g. --arch
)? This is a limitation of the current rules_spm
implementation. It does not handle compilation for other platforms very well. Alas, this is one of the issues that spurred me to gather feedback (#157).
not sure it helps @achew22 - but uikit is specifically used on ios. appkit is for macos. if you have scripts that are importing - need to determine os
https://stackoverflow.com/questions/68676690/macos-uikit-uikit-h-not-found
UPDATE - I see someone is using bazel + stripe here
I'm unable to add a dependency on Stripe. I believe this is a reasonable way of loading it in (happy to be told I'm wrong on that front).
WORKSPACE
:BUILD
:main.swift
:Even when I try to do something relatively simple like query
#swift_pkgs
, not even running the binary, I get the following output:And
bazel run //:simple
has a similar error:I think there is a good chance that I'm holding it wrong, but I can't understand what I'm doing wrong here. Happy to provide any additional debug information you might want.