Darwin::InitObjC(3pm) User Contributed Perl Documentation Darwin::InitObjC(3pm)

# [NAME](#NAME)

Darwin::InitObjC - initializes Objective-C runtime

# [SYNOPSIS](#SYNOPSIS)

```
  use Darwin::InitObjC;
  Darwin::InitObjC::maybe_init();
  my $pid = fork // die;
  if ($pid == 0) {
    do_something();
    exit;
  }
  wait;
```

# [DESCRIPTION](#DESCRIPTION)

Darwin::InitObjC initializes Objective-C runtime.

In macOS 13+, initialising Objective-C APIs in forked processes are treated as errors. So you may see the following errors when executing your scripts:

```
  objc[80048]: +[NSString initialize] may have been in progress in another thread when fork() was called.
  objc[80048]: +[NSString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
```

A workaround is to initilize Objective-C runtime before calling [**fork**(2)](/man/os/perl-darwin-initobjc/fork.2).

# [SEE ALSO](#SEE_ALSO)

https://bugs.ruby-lang.org/issues/14009

# [COPYRIGHT AND LICENSE](#COPYRIGHT_AND_LICENSE)

Copyright 2024 Shoichi Kaji &lt;skaji@cpan.org&gt;

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2026-09-10 perl v5.44.0

---

Document: Darwin::InitObjC(3pm) from perl-darwin-initobjc 0.001-r5 (Chainguard OS)
Source: https://cpan.metacpan.org/authors/id/S/SK/SKAJI/Darwin-InitObjC-0.001.tar.gz
