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

Cocoa is not available when building for tvOS Simulator #133

Open
Kentzo opened this issue Nov 30, 2020 · 7 comments
Open

Cocoa is not available when building for tvOS Simulator #133

Kentzo opened this issue Nov 30, 2020 · 7 comments

Comments

@Kentzo
Copy link
Owner

Kentzo commented Nov 30, 2020

I see that the spm branch has been merged in, and the readme file says that SPM is supported. That's great news! Unfortunately, I am having a problem, related to the @IBDesignable code in the package.

I added the package and everything builds fine, but as soon as I add a SRRecorderControl to a storyboard I get an error as it tries to build for Interface Builder. The app itself runs and works, but every time IB tries to refresh the views the error shows up.

SRCommon.h:6:9: Cocoa is not available when building for tvOS Simulator. Consider using `#if !TARGET_OS_TV` to conditionally import this framework, first importing TargetConditionals.h if necessary.

The most confusing thing about this error message is that this is a macOS app, with no tvOS (or any iOS based) targets at all.

Naturally, adding a RecorderControl in code works great, and that's the approach I'm using for now.

I thought I'd mention it though, and see if anyone else has a better workaround than creating it in code. Let me know if you'd rather I open this as a separate issue, I'd be happy to.


Apologies, I should have included that! I'm running the latest stable, Version 12.2 (12B45b) on Big Sur.

I just made a new project, imported the package and placed a view on the view controller in the storyboard and reproduced it. Here's the project.


Originally posted by @daveverwer in #95 (comment)

@Kentzo
Copy link
Owner Author

Kentzo commented Nov 30, 2020

@daveverwer Cannot try it yet (don't have that Xcode installed). Does the error affect rendering in IB only or you cannot compile the app as well? If that's the latter, can you navigate to the Reports panel and locate the associated log records? They should show what command Xcode tried to execute and raw output.

@daveverwer
Copy link

daveverwer commented Nov 30, 2020

The error only affects IB, and the app runs correctly even with the control showing an error in IB.

It shows the error here:

Screenshot 2020-11-30 at 19 29 23@2x

Then, here's the build from the Reports panel:

Screenshot 2020-11-30 at 19 31 09@2x

@Kentzo
Copy link
Owner Author

Kentzo commented Nov 30, 2020

Can you click the burger (rightmost) button of a failure record to unfold the command line that Xcode used?

@daveverwer
Copy link

Apologies, I should have included that with the last comment! Here you go:

CompileC /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/Objects-normal/x86_64/SRCommon.o /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder/Sources/ShortcutRecorder/SRCommon.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'ShortcutRecorder' from project 'ShortcutRecorder')
    cd /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder
    export LANG\=en_US.US-ASCII
    /Applications/Xcode_12.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -target x86_64-apple-tvos9.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fobjc-arc -fmodules -gmodules -fmodules-cache-path\=/Users/dave/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/dave/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -fmodule-name\=ShortcutRecorder -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-implicit-atomic-properties -Wno-objc-interface-ivars -Wno-arc-repeated-use-of-weak -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -DTARGET_INTERFACE_BUILDER\=1 -DSWIFT_PACKAGE -DDEBUG\=1 -DOBJC_OLD_DISPATCH_PROTOTYPES\=1 -isysroot /Applications/Xcode_12.2.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator14.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -fobjc-abi-version\=2 -fobjc-legacy-dispatch -index-store-path /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Index/DataStore -I/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Products/Debug-appletvsimulator/include -I/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder/Sources/ShortcutRecorder/include -I/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/DerivedSources-normal/x86_64 -I/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/DerivedSources/x86_64 -I/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/DerivedSources -F/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Products/Debug-appletvsimulator -F/Applications/Xcode_12.2.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/Library/Frameworks -iframework /Applications/Xcode_12.2.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator14.2.sdk/Developer/Library/Frameworks -DXcode -include /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/DerivedSources/resource_bundle_accessor.h -MMD -MT dependencies -MF /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/Objects-normal/x86_64/SRCommon.d --serialize-diagnostics /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/Objects-normal/x86_64/SRCommon.dia -c /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder/Sources/ShortcutRecorder/SRCommon.m -o /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/ShortcutRecorder.build/Debug-appletvsimulator/ShortcutRecorder.build/Objects-normal/x86_64/SRCommon.o

In file included from /Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder/Sources/ShortcutRecorder/SRCommon.m:8:
/Users/dave/Library/Developer/Xcode/DerivedData/Test-aqjgxhhbreofgwfbihsmehgqztws/SourcePackages/checkouts/ShortcutRecorder/Sources/ShortcutRecorder/include/ShortcutRecorder/SRCommon.h:6:9: fatal error: 'Cocoa/Cocoa.h' file not found
#import <Cocoa/Cocoa.h>
        ^~~~~~~~~~~~~~~
1 error generated.

@Kentzo
Copy link
Owner Author

Kentzo commented Dec 1, 2020

Perhaps the project or XIB is annotated to be multiplatform? The package itself is annotated to require macOS.

@daveverwer
Copy link

I must admit I'm not sure how to annotate a Storyboard for multiple platforms, but my first thought was also that it was something in my project that was causing this. The screenshots and logs above are from a brand new Test project that was certainly created as macOS only.

In terms of what platform the storyboard is for, here's what's in the File Inspector for it:

Screenshot 2020-12-02 at 07 39 17@2x

@Kentzo
Copy link
Owner Author

Kentzo commented Dec 2, 2020

Related issue on Apple's devforums: https://developer.apple.com/forums/thread/652552 (you may find other issues there with IB too). Could you report the but to Apple and share a link to this project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants