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

No such module 'Carbon.HIToolbox' #130

Closed
bobmosh opened this issue Jun 5, 2023 · 6 comments
Closed

No such module 'Carbon.HIToolbox' #130

bobmosh opened this issue Jun 5, 2023 · 6 comments

Comments

@bobmosh
Copy link

bobmosh commented Jun 5, 2023

Hey folks,

I just added the package to my personal Xcode project via SPM and the first thing that happens when I build is No such module 'Carbon.HIToolbox' in the CarbonKeyboardShortcuts.swift.

I tried the latest version tags as well as pulling from main, butt the issue doesn't seem to be resolvable. Anyone else have the same issue?

Cheers,
Ferdi

@bobmosh
Copy link
Author

bobmosh commented Jun 5, 2023

For context I am using this in an App that will also have an iOS App, so it might be connected to that, could that be?

@bobmosh
Copy link
Author

bobmosh commented Jun 5, 2023

Solved it myself!

For anyone wondering, the library only builds for macOS targets.
In order to use it in a cross platform environment, you will need to use conditional exclusion like #if os(macOS) on any imports / usage of code from that library (use safer methods if possible though, this is just what I used in my tests).

You will also need multiple targets (I separated my App targets into iOS/iPadOS and macOS) and remove the linked library from the Frameworks, Libraries, and Embedded Content section of the mobile targets.

@bobmosh bobmosh closed this as completed Jun 5, 2023
@WalterZou
Copy link

WalterZou commented Jul 18, 2023

@bobmosh
I also encountered this problem. I added #if os(macOS) to all the places where this library is used, but it still gives an error:
image

Is there any way to resolve this case without involving multiple targets?

@WalterZou
Copy link

By adding the conditional statement #if os(macOS) ... #endif to all the code of KeyboardShortcuts, I have resolved this issue by ensuring that the source code only compiles on macOS, without the need to build multiple targets.

@sindresorhus
Copy link
Owner

You will also need multiple targets (I separated my App targets into iOS/iPadOS and macOS) and remove the linked library from the Frameworks, Libraries, and Embedded Content section of the mobile targets.

You don't need to do that. You can make it only used for a specific platform:

Screenshot 2023-07-26 at 19 35 26

@WalterZou
Copy link

You will also need multiple targets (I separated my App targets into iOS/iPadOS and macOS) and remove the linked library from the Frameworks, Libraries, and Embedded Content section of the mobile targets.

You don't need to do that. You can make it only used for a specific platform:

Screenshot 2023-07-26 at 19 35 26

I have already set it to only used for macOS, but it still throws the error, so I used conditional statements to wrap all the files to fix the issue

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

No branches or pull requests

3 participants