Open algoz098 opened 3 years ago
Found the solution removing and reinstalling the xcode commandtools.
is this still an issue then?
i also got same issue as above, re-install command line tools worked.. I think this is no more an issue but should be documented to frequently encounter errors/FAQ.
Commands to re-install Xcode command line tools.
# delete existing command line tools
sudo rm -rf /Library/Developer/CommandLineTools
# install command line tools
xcode-select —install
Upgrading ncurses from v6.2 to v6.3 in macports fixed this for me:
sudo port upgrade ncurses
although I was getting a slightly different error:
cargo:warning=/opt/local/include/unctrl.h:61:63: error: unknown type name 'SCREEN'
cargo:warning=NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
...
cargo:warning=In file included from objc/notify.m:1:
cargo:warning=objc/notify.h:1:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=16 errors generated.
exit status: 1
Related: https://stackoverflow.com/a/46613039
I'm facing the same problem when using cargo
installed via Nix (which seems (to try) to link against nix-packaged macOS frameworks).
My context is a simple Tauri app. Here is a repro: https://github.com/schickling-test/tauri-nix-mac-repro
I get the same issue trying to install cargo-watch
.
I'm using ncurses
v6.3 from homebrew, although I tried to use it via
LDFLAGS="-L/opt/homebrew/opt/ncurses/lib" CPPFLAGS="-I/opt/homebrew/opt/ncurses/include" cargo install cargo-watch
@felipesere are you on an M1? Which macOS version?
Yeah, I am on M1 with macOS 11.6.2 "Big Sur"
Same thing for me in a nix environment with cargo-watch
with an M1 on macOS Monterey
warning: In file included from objc/notify.m:1:
warning: objc/notify.h:1:9: fatal error: 'Foundation/Foundation.h' file not found
warning: #import <Foundation/Foundation.h>
warning: ^~~~~~~~~~~~~~~~~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `mac-notification-sys v0.3.0`
So then I manually go and include Foundation
(pkgs.darwin.apple_sdk.frameworks.Foundation
), and I get
warning: While building module 'Foundation' imported from objc/notify.h:1:
warning: In file included from <module-includes>:1:
warning: /nix/store/641gv090lkmcfz52wlf9314rnl4fb1jm-apple-framework-Foundation-11.0.0/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CoreFoundation.h>
warning: ~~~~~~~~^
warning: In file included from objc/notify.m:1:
warning: objc/notify.h:1:9: fatal error: could not build module 'Foundation'
warning: #import <Foundation/Foundation.h>
warning: ~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: In file included from <module-includes>:1:
warning: /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CoreFoundation.h>
warning: ~~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: While building module 'DiskArbitration' imported from /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/File
warning: In file included from <module-includes>:1:
warning: /nix/store/9ksh90av3smccmwlnqh2svq48xhj2pkf-apple-framework-DiskArbitration-11.0.0/Library/Frameworks/DiskArbitration.framework/Headers/DiskArbitration.h:27:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CoreFoundation.h>
warning: ~~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: While building module 'DiskArbitration' imported from /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/File
warning: While building module 'IOKit' imported from /nix/store/9ksh90av3smccmwlnqh2svq48xhj2pkf-apple-framework-DiskArbitration-11.0.0/Library/Frameworks/DiskArbitration.framework/Headers/DADisk.h:28:
warning: In file included from <module-includes>:4:
warning: /nix/store/kvcr4lv0a477a35khkdnim11sy0nics9-apple-framework-IOKit-11.0.0/Library/Frameworks/IOKit.framework/Headers/IOCFBundle.h:26:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CoreFoundation.h>
warning: ~~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: While building module 'CFNetwork' imported from /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:31:
warning: In file included from <module-includes>:1:
warning: /nix/store/yg3zg4w95cn4bp4c70kcbh7ildxbadnf-apple-framework-CFNetwork-11.0.0/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CoreFoundation.h>
warning: ~~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: While building module 'Security' imported from /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentityB
warning: In file included from <module-includes>:1:
warning: In file included from /nix/store/c7ilkh6b3lva99kixsv4n1la0vw68rav-apple-framework-Security-11.0.0/Library/Frameworks/Security.framework/Headers/Security.h:27:
warning: /nix/store/c7ilkh6b3lva99kixsv4n1la0vw68rav-apple-framework-Security-11.0.0/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10: fatal error: could not build module 'CoreFoundation'
warning: #include <CoreFoundation/CFBase.h>
warning: ~~~~~~~~^
warning: While building module 'CoreServices' imported from objc/notify.h:3:
warning: While building module 'Security' imported from /nix/store/srl8r7rk11sgvgbz07vipmfi6cdq8vlw-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentityB
warning: While building module 'XPC' imported from /nix/store/c7ilkh6b3lva99kixsv4n1la0vw68rav-apple-framework-Security-11.0.0/Library/Frameworks/Security.framework/Headers/SecCode.h:35:
warning: In file included from <module-includes>:1:
warning: /nix/store/8mgx8iwvhxqpqq87blr6ligj8y2ka80w-apple-lib-xpc/include/xpc/xpc.h:7:2: fatal error: module 'ObjectiveC' is defined in both '/var/folders/k7/sspdr20908j9vyw063hj9f4h00009d/C/clang/ModuleCache/1DUII0VXZWGY4/Objec
warning: #include <dispatch/dispatch.h>
warning: ^
warning: 8 errors generated.
error: failed to run custom build command for `mac-notification-sys v0.3.0`
Not sure how much of this is helpful.
Confirm the same issue persist for mac-notification-sys v0.5.0
--- stdout
TARGET = Some("aarch64-apple-darwin")
OPT_LEVEL = Some("3")
HOST = Some("aarch64-apple-darwin")
CC_aarch64-apple-darwin = None
CC_aarch64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_aarch64-apple-darwin = None
CFLAGS_aarch64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,llvm14-builtins-abi,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,v8.1a,v8.2a,v8.3a,v8.4a,vh")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-fmodules" "-o" "/Users/hugosum/Desktop/jyut-speech-to-text/src-tauri/target/release/build/mac-notification-sys-c5cfa49e7a6ec1ad/out/objc/notify.o" "-c" "objc/notify.m"
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'Foundation' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
cargo:warning=- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
cargo:warning= ~~~~~~~~~~~~~~ ^ ~
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
cargo:warning= #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
cargo:warning= ^ ~
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreData' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSKeyValueBinding.h:12:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/CoreData.h:8:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreData' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSKeyValueBinding.h:12:
cargo:warning=While building module 'CloudKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentCloudKitContainerOptions.h:12:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CloudKit.h:8:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreData' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSKeyValueBinding.h:12:
cargo:warning=While building module 'CloudKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentCloudKitContainerOptions.h:12:
cargo:warning=While building module 'CoreLocation' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CloudKit.framework/Headers/CKRecord.h:8:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.h:18:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CLErrorDomain.h:10:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreImage' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSColor.h:51:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.h:9:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreImage' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSColor.h:51:
cargo:warning=While building module 'CoreVideo' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CIImage.h:10:
cargo:warning=While building module 'IOSurface' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVPixelBufferIOSurface.h:31:
cargo:warning=In file included from <module-includes>:4:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceObjC.h:15:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreImage' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSColor.h:51:
cargo:warning=While building module 'CoreVideo' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CIImage.h:10:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CoreVideo.h:29:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVPixelBuffer.h:628:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVPixelBufferIOSurface.h:31:10: fatal error: could not build module 'IOSurface'
cargo:warning=#include <IOSurface/IOSurface.h>
cargo:warning= ~~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'CoreImage' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSColor.h:51:
cargo:warning=While building module 'CoreVideo' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CIImage.h:10:
cargo:warning=While building module 'Metal' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/CoreVideo.framework/Headers/CVMetalTextureCache.h:41:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:9:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h:8:9: fatal error: could not build module 'Foundation'
cargo:warning=#import <Foundation/Foundation.h>
cargo:warning= ~~~~~~~^
cargo:warning=While building module 'Cocoa' imported from objc/notify.h:1:
cargo:warning=While building module 'AppKit' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:
cargo:warning=While building module 'QuartzCore' imported from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGLLayer.h:11:
cargo:warning=In file included from <module-includes>:1:
cargo:warning=In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:9:
cargo:warning=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreImage.h:1:10: fatal error: could not build module 'CoreImage'
cargo:warning=#include <CoreImage/CoreImage.h>
cargo:warning= ~~~~~~~~^
cargo:warning=In file included from objc/notify.m:1:
cargo:warning=objc/notify.h:1:9: fatal error: could not build module 'Cocoa'
cargo:warning=#import <Cocoa/Cocoa.h>
cargo:warning= ~~~~~~~^
cargo:warning=12 errors generated.
exit status: 1
--- stderr
error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-fmodules" "-o" "/Users/hugosum/Desktop/jyut-speech-to-text/src-tauri/target/release/build/mac-notification-sys-c5cfa49e7a6ec1ad/out/objc/notify.o" "-c" "objc/notify.m" with args "cc" did not execute successfully (status code exit status: 1).
I had the same error and fixed it by simply upgrading/installing llvm
brew install llvm
I still have this issue on 11.6 Freshly installed commandline tools and llvm
even with xcode installed? you need to have Foundation on your system
need to try that. was a bit hesitant to install complete xcode because it was something like 10gig.
installing the newest available xcode available for my 2014 macbook pro 15 (not supported on latest macos) works :)
Unfortunately I'm still facing the same problem as described above. Would be great if this issue could be kept open until the underlying issue is resolved.
Here is a repro: https://github.com/schickling-test/tauri-nix-mac-repro
same here. started after the (latest) xcode-select update to version 2384. llvm 15.0.1, rust 1.64.0 (a55dd71d5 2022-09-19), cargo-tauri 1.1.1
For the record, I managed to solve it with
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
Using the demo code in the readme.md it's throwing a error in build