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

Do not use exit() on mobile platforms #24

Merged
merged 2 commits into from
Feb 7, 2022
Merged

Do not use exit() on mobile platforms #24

merged 2 commits into from
Feb 7, 2022

Conversation

Tobisaninfo
Copy link
Contributor

Hi,

I try to use your library on iOS but get some compiler errors. The exit() method cannot be used on mobile platforms. Therefore Xcode reports some compiler errors. To use it anyway, I added a preprocessor statement to switch between mobile platforms and macOS/Linux.

@dastrobu
Copy link
Owner

dastrobu commented Jan 31, 2022

@Tobisaninfo thanks for taking the time to create this PR. I guess I wasn't expecting anyone to use this on a mobile target, since CLI apps are not very common there 😉. (Of course, if you have multiple targets, it makes sense).

May I suggest a slightly alternative approach. You could change the imports from

#if os(macOS)
import Darwin
#elseif os(Linux)
import Glibc
#endif

to

#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import Glibc
#endif

The reason for the compile error is that Darwin was not imported on iOS (although it is available). That you should not use exit(0) on iOS is a different story, but this is probably something that should not be handled by this library.

@dastrobu dastrobu self-requested a review January 31, 2022 07:54
@Tobisaninfo
Copy link
Contributor Author

Sure your are right, the market of CLI apps isn't that big 😀 Recently I was looking for a arg parse framework for my iOS project, because I have some launch args for dev and UI test purpose. So none of them are for production, but it makes my development life much easier.

Thanks your fast feedback. I will have a look on your annotations and fix this things.

…ty; make exit method on all platforms with Darwin module available
Copy link
Owner

@dastrobu dastrobu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@dastrobu dastrobu merged commit cfc277a into dastrobu:master Feb 7, 2022
@dastrobu
Copy link
Owner

dastrobu commented Feb 7, 2022

@Tobisaninfo enjoy version 1.5.4.

@Tobisaninfo
Copy link
Contributor Author

Thanks for the fast reply and new version of the library 😊

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

Successfully merging this pull request may close these issues.

2 participants