If an iOS app gets terminated by watchdog due to, for example, hanging the main thread, is that considered to be a crash or something different.
I'm asking because, according to google and AI, Crashlytics can detect and report these,but in my experience it does not.
If I deliberately cause a watchdog termination by for example sleeping on the main thread for a long time then these never appear in Crashlytics.
I know Apple folks here don't comment on non Apple software, so I'm not asking about Crashlytics, just wondering and interested about watchdog timeout terminations and how they differ from a "regular" crash.
General
RSS for tagDive into the vast array of tools and services available to developers.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have two macOS applications: Application A, named My App.app with the bundle ID com.comp.myapp, and Application B, named My App.app with the bundle ID com.comp.myapp2. Both applications have the same name. Application A is installed at /Applications/My App.app. When I run the installer for Application B, it gets installed in a folder at /Applications/My App.localized/My App.app. Even if I remove Application A using the preinstall script of Application B's installer, the result remains the same.
Does the installer determine the installation path with the new folder before the preinstall script executes?
How can it be addressed so the new folder will not be created?
Notes:
We have a composite package that contains multiple components. Instead of just running pkgbuild, we use our own components.plist rather than a synthesized one. The components.plist is attached.
The PackageInfo for Application B is also attached.
components.plist
PackageInfo
packageInfo.xml
components.plist
Topic:
Developer Tools & Services
SubTopic:
General
Tags:
Developer Tools
InstallerJS
macOS
Command Line Tools
The app I'm working on has iOS 16.0 as target. Recently Live Activities support was added, but then it started crashing when running on iOS 16.0 devices.
After some investigation, I've found that the culprit was the presence of NSUserActivityTypeLiveActivity and WidgetCenter.UserInfoKey.activityID, even though they were inside an @available(iOS 17.2, *) block. If I comment these two variables, the app work as expected. I've also tried adding #if canImport(ActivityKit) around the code, but without success.
But if the @available isn't working, how can I prevent this? It looks like a bug, since the documentation says that NSUserActivityTypeLiveActivity is supported but iOS 14.0+, but I'm pretty sure it was introduced on 16.1.
This is the only output I get with the crash:
dyld[66888]: Symbol not found: _$s9WidgetKit0A6CenterC11UserInfoKeyV10activityIDSSvgZ
Referenced from: <D6EFF120-2681-34C1-B261-8F3F7B388238> /Users/<redacted>/Library/Developer/CoreSimulator/Devices/8B5B4DC9-3D54-4C91-8C88-E705E851CA0F/data/Containers/Bundle/Application/DB6671FF-CB07-4570-BD63-C851D94FAF29/<redacted>.app/<redacted>.debug.dylib
Expected in: <C5E72BB5-533F-3658-A987-E849888F4DFC> /Library/Developer/CoreSimulator/Volumes/iOS_20A360/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 16.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/WidgetKit.framework/WidgetKit
在idea中Java spring 框架如何运行啊,求求大佬们,我跑https://gitee.com/lab1024/smart-admin 这个包老是报错,不让我写入
I am running Appium tests on an iOS 18 simulator, and I am encountering an intermittent issue where the device screen gets locked unexpectedly during the tests. The Appium logs show no errors or unusual activity, and all commands appear to be executed successfully.
However, upon reviewing the device logs, I see entries related to the lock event, but the exact cause remains unclear.
SpringBoard: (SpringBoard) [com.apple.SpringBoard:Common] lockUIFromSource:Boot options:{
SBUILockOptionsLockAutomaticallyKey: 1,
SBUILockOptionsForceLockKey: 1,
SBUILockOptionsUseScreenOffModeKey: 0
}
SpringBoard: (SpringBoard) [com.apple.SpringBoard:Common] -[SBTelephonyManager inCall] 0
SpringBoard: (SpringBoard) [com.apple.SpringBoard:Common] LockUI from source: Now locking
Has anyone experienced similar behavior with Appium on iOS 18, or could there be a setting or configuration in the simulator that is causing this issue?
Running
xcrun xcresulttool get build-results --path ResultFile
does not always show the warnings that the build emitted, If I run the legacy command,
xcrun xcresulttool get --legacy --path ResultFile
against the same file, there are (numerous) warnings, where the non-legacy call above shows no warnings.
Topic:
Developer Tools & Services
SubTopic:
General
Install CommandLineTools below macOS Sequoia installs the VULNERABLE version of Git, 2.39.3 while macOS Sequoia installs a non-vulnerable version 2.39.5. How to get the non vulnerable version installed on macOS Sonoma?
CVE-2024-32002 - Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, repositories with submodules can be crafted in a way that exploits a bug in Git whereby it can be fooled into writing files not into the submodule's worktree but into a .git/ directory.
Hi,
We have few MacStudio servers that when we ssh as users to it and trying to run some commands fro /usr/bin, they staying in hang state for infinite.
When root user do the same commands are working properly
Example for hanging commands : clang, gcc, make, ld etc
Add as attachment the dtruss out for ld -v command to help debug it
Thanks,
Amir
dtruss out from ld -v command
Hi! I wanted to use Lottie in my swiftpm app, but I've been running into errors and I'm not sure if it's possible. When I try to run the app, it crashes and I get errors saying that the library isn't loaded and the files aren't found (basically these: https://github.com/lottie-react-native/lottie-react-native/issues/373 , https://github.com/airbnb/lottie-ios/issues/2233 ). But moving the framework file into the PackageFrameworks folder doesn't work, and also I'm getting the error that swiftpm cannot distribute packages containing binary frameworks and from what I understand that just isn't something that swiftpm can do. So I was wondering if anyone knows any workarounds to this, or if I should just ditch Lottie?
Any help or advice would be greatly appreciated!
Topic:
Developer Tools & Services
SubTopic:
General
Tags:
Swift Packages
Swift Student Challenge
Swift Playground
Visual Design
Hey, Since I set up push notifications for my Flutter app following this tutorial https://documentation.onesignal.com/docs/flutter-sdk-setup, my Flutter app no longer builds for iOS in the CD pipeline. I get the following error:
[17:24:47]: ▸ ProcessException: Process exited abnormally with exit code -6:
[17:24:47]: ▸ Command line invocation:
[17:24:47]: ▸ /Applications/Xcode_15.4.app/Contents/Developer/usr/bin/xcodebuild -list
[17:24:47]: ▸ User defaults from command line:
[17:24:47]: ▸ IDEPackageSupportUseBuiltinSCM = YES
[17:24:47]: ▸ 2025-03-10 17:24:46.855 xcodebuild[13337:34491] [MT] DVTAssertions: ASSERTION FAILURE in DevToolsCore/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/ProjectModel/DataModel/References/SynchronizedGroups/PBXFileSystemSynchronizedAbstractGroup.m:28
[17:24:47]: ▸ Details: Assertion failed: IDEFileSystemSynchronizedGroupsAreEnabled()
[17:24:47]: ▸ Object: <PBXFileSystemSynchronizedRootGroup>
[17:24:47]: ▸ Method: +allocWithZone:
[17:24:47]: ▸ Thread: <_NSMainThread: 0x60000026c200>{number = 1, name = main}
[17:24:47]: ▸ Hints:
[17:24:47]: ▸ Backtrace:
[17:24:47]: ▸ 0 -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
[17:24:47]: ▸ 1 _DVTAssertionHandler (in DVTFoundation)
[17:24:47]: ▸ 2 _DVTAssertionFailureHandler (in DVTFoundation)
[17:24:47]: ▸ 3 _DVTAssertionWarningHandler (in DVTFoundation)
My pipeline looks like this:
name: iOS Build and Deploy to App Store with Custom Version
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
default: '1.0.0'
env:
FLUTTER_CHANNEL: "stable"
RUBY_VERSION: "3.2.2"
jobs:
build_ios:
name: Build iOS
runs-on: macos-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
working-directory: 'daytistics/ios'
- name: Clean up vendor
working-directory: 'daytistics/ios'
run: rm -rf vendor
- name: Install Bundler Gems
working-directory: 'daytistics/ios'
run: bundle install
- name: Run Flutter tasks and get pub packages
uses: subosito/flutter-action@v2.16.0
with:
flutter-version-file: 'daytistics/pubspec.yaml'
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Get Flutter Packages
working-directory: ./daytistics
run: flutter pub get
- name: Install Bundler Gems
working-directory: 'daytistics/ios'
run: |
bundle install
bundle exec pod repo update # Add this line
# Remove the "Reinstall CocoaPods" step entirely
- name: Pod Install
working-directory: 'daytistics/ios'
run: bundle exec pod install
- name: Clean Flutter build
working-directory: ./daytistics
run: flutter clean
- name: Create .env file
working-directory: ./daytistics
run: touch .env
- uses: maierj/fastlane-action@v3.1.0
with:
lane: 'release_app_store'
subdirectory: daytistics/ios
options: '{
"version_number": "${{ github.event.inputs.version }}",
"env_vars": ["SUPABASE_URL", "SUPABASE_ANON_KEY", "POSTHOG_API_KEY", "SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID", "SENTRY_DSN"]
}'
env:
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_KEY_P8_BASE64: ${{ secrets.ASC_KEY_P8_BASE64 }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
APP_BUNDLE_ID: ${{ secrets.APP_BUNDLE_ID }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID: ${{ secrets.SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
Everything works as expected in the simulator. However, I think that the problem isn't related to the pipeline. Instead I think it is related to the "Signing Capabilities" in X-Code:
https://i.sstatic.net/E0tSetZP.png
https://i.sstatic.net/oC1xG0A4.png
Thanks for your help!
Hi All,
I have an App on AppStore, recently the minimum supported version of the app was changed from iOS 12 to iOS 14.
Post that the TestFlight builds are crashing on launch.
If we revert the minimum supported iOS version to 12, the crash no longer happens.
This project is using cocoapods, and from the crash logs it seems the issue with with PLCrashReporter framework.
"EXC_CRASH" Termination reason: DYLD 9 weak-def symbol not found '__ZN7plcrash3PL_5async15dwarf_cfa_stateljiE10push_stateEv'.
This issue is happening only on TestFlight builds where the minimum supported version is 14.0
Any pointer to a solution is welcome.
Hello,
I am trying to read debug symbols from a binary obtained from simple "hello world" C code. I use default gcc (Clang) on macos15, then try to install gcc-14 with hombrew
$ gcc -g program.c -o program
then run
$ dsymutil program
I got :
warning: no debug symbols in executable (-arch arm64)
I am doing something wrong here. My final objective is to be able to use my binaries in total view for debugging. Without debugging symbols, I can debug properly .
Thank you
Hi, I’m having trouble installing GPT 1.1 on macOS Sequoia 15.3.1 using Xcode Command Line Tools 16.0.
I downloaded Evaluation Environment for Windows Games 2.1, mounted the image, and opened the README file. Then, I followed Option 2 to build the environment from scratch:
Set up your development and Homebrew environment
Ensure you are using Command Line Tools for Xcode 15.1. You can download this older version from:
https://developer.apple.com/downloads
Note: There is a header file layout change that prevents using newer versions of the macOS SDK.
softwareupdate --install-rosetta
arch -x86_64 zsh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
which brew
brew tap apple/apple http://github.com/apple/homebrew-apple
brew -v install apple/apple/game-porting-toolkit
At first, I noticed that I needed to use CLT 15.1, which is not supported on later macOS versions (including mine). Even when I tried using 15.3 (which is somehow supported), I received a message stating that I needed CLT v16.0 or higher to install GPT.
After following all the steps and waiting for the installation to complete, I got the following error:
==> Installing apple/apple/game-porting-toolkit
==> Staging /Users/tycjanfalana/Library/Caches/Homebrew/downloads/7baed2a6fd34b4a641db7d1ea1e380ccb2f457bb24cd8043c428b6c10ea22932--crossover-sources-22.1.1.tar.gz in /private/tmp/game-porting-toolkit-20250316-15122-yxo3un
==> Patching
==> /private/tmp/game-porting-toolkit-20250316-15122-yxo3un/wine/configure --prefix=/usr/local/Cellar/game-porting-toolkit/1.1 --disable-win16 --disable-tests --without-x --without-pulse --without-dbus --without-inotify --without-alsa --without-capi --without-oss --without-udev --without-krb5 --enable-win64 --with-gnutls --with-freetype --with-gstreamer CC=/usr/local/opt/game-porting-toolkit-compiler/bin/clang CXX=/usr/local/opt/game-porting-toolkit-compiler/bin/clang++
checking build system type... x86_64-apple-darwin24.3.0
checking host system type... x86_64-apple-darwin24.3.0
checking whether make sets $(MAKE)... yes
checking for gcc... /usr/local/opt/game-porting-toolkit-compiler/bin/clang
checking whether the C compiler works... no
configure: error: in `/private/tmp/game-porting-toolkit-20250316-15122-yxo3un/wine64-build':
configure: error: C compiler cannot create executables
See `config.log' for more details
==> Formula
Tap: apple/apple
Path: /usr/local/Homebrew/Library/Taps/apple/homebrew-apple/Formula/game-porting-toolkit.rb
==> Configuration
HOMEBREW_VERSION: 4.4.24
ORIGIN: https://github.com/Homebrew/brew
HOMEBREW_PREFIX: /usr/local
Homebrew Ruby: 3.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: 14-core 64-bit westmere
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3.1-x86_64
CLT: 16.0.0.0.1.1724870825
Xcode: N/A
Rosetta 2: true
==> ENV
HOMEBREW_CC: clang
HOMEBREW_CXX: clang++
CFLAGS: [..]
Error: apple/apple/game-porting-toolkit 1.1 did not build
Logs:
/Users/xyz/Library/Logs/Homebrew/game-porting-toolkit/00.options.out
/Users/xyz/Library/Logs/Homebrew/game-porting-toolkit/01.configure
/Users/xyz/Library/Logs/Homebrew/game-porting-toolkit/01.configure.cc
/Users/xyz/Library/Logs/Homebrew/game-porting-toolkit/wine64-build
If reporting this issue, please do so to (not Homebrew/brew or Homebrew/homebrew-core):
apple/apple
In config.log, I found this:
configure:4672: checking for gcc
configure:4704: result: /usr/local/opt/game-porting-toolkit-compiler/bin/clang
configure:5057: checking for C compiler version
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang --version >&5
clang version 8.0.0
Target: x86_64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /usr/local/opt/game-porting-toolkit-compiler/bin
configure:5077: $? = 0
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -v >&5
clang version 8.0.0
Target: x86_64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /usr/local/opt/game-porting-toolkit-compiler/bin
configure:5077: $? = 0
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -V >&5
clang-8: error: argument to '-V' is missing (expected 1 value)
clang-8: error: no input files
configure:5077: $? = 1
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -qversion >&5
clang-8: error: unknown argument '-qversion', did you mean '--version'?
clang-8: error: no input files
configure:5077: $? = 1
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -version >&5
clang-8: error: unknown argument '-version', did you mean '--version'?
clang-8: error: no input files
configure:5077: $? = 1
configure:5097: checking whether the C compiler works
configure:5119: /usr/local/opt/game-porting-toolkit-compiler/bin/clang [...]
dyld[15547]: Symbol not found: _lto_codegen_debug_options_array
Referenced from: <E33DCAC4-3116-3019-8003-432FB3E66FB4> /Library/Developer/CommandLineTools/usr/bin/ld
Expected in: <43F5C676-DE37-3F0E-93E1-BF793091141E> /usr/local/Cellar/game-porting-toolkit-compiler/0.1/lib/libLTO.dylib
clang-8: error: unable to execute command: Abort trap: 6
clang-8: error: linker command failed due to signal (use -v to see invocation)
configure:5123: $? = 254
configure:5163: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Wine"
| #define PACKAGE_TARNAME "wine"
| #define PACKAGE_VERSION "7.7"
| #define PACKAGE_STRING "Wine 7.7"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
|
| int
| main (void)
| {
|
| ;
| return 0;
| }
configure:5168: error: in `/private/tmp/game-porting-toolkit-20250316-15122-yxo3un/wine64-build':
configure:5170: error: C compiler cannot create executables
See `config.log` for more details
Does anyone have any ideas on how to fix this?
I'm creating a clean project in Expo without Typescript. I run the command “npx expo prebuild” normally, but when I run the command “npx expo run:ios” I get the error “PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/bogdanlyamzin/Library/Developer/Xcode/DerivedData/testapp-gbckopevfunjmtanprbgmojuogrr/Build/Intermediates. noindex/Pods.build/Debug-iphonesimulator/ReactCodegen.build/Script-46EB2E0001C6B0.sh (in target 'ReactCodegen' from project 'Pods')”. Can you please tell me how to fix it?
Translated with DeepL.com (free version)
Topic:
Developer Tools & Services
SubTopic:
General
This posts collects together a bunch of information about the symbols found in a Mach-O file.
It assumes the terminology defined in An Apple Library Primer. If you’re unfamiliar with a term used here, look there for the definition.
If you have any questions or comments about this, start a new thread in the Developer Tools & Services > General topic area and tag it with Linker.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Understanding Mach-O Symbols
Every Mach-O file has a symbol table. This symbol table has many different uses:
During development, it’s written by the compiler.
And both read and written by the linker.
And various other tools.
During execution, it’s read by the dynamic linker.
And also by various APIs, most notably dlsym.
The symbol table is an array of entries. The format of each entry is very simple, but they have been used and combined in various creative ways to achieve a wide range of goals. For example:
In a Mach-O object file, there’s an entry for each symbol exported to the linker.
In a Mach-O image, there’s an entry for each symbol exported to the dynamic linker.
And an entry for each symbol imported from dynamic libraries.
Some entries hold information used by the debugger. See Debug Symbols, below.
Examining the Symbol Table
There are numerous tools to view and manipulate the symbol table, including nm, dyld_info, symbols, strip, and nmedit. Each of these has its own man page.
A good place to start is nm:
% nm Products/Debug/TestSymTab
U ___stdoutp
0000000100000000 T __mh_execute_header
U _fprintf
U _getpid
0000000100003f44 T _main
0000000100008000 d _tDefault
0000000100003ecc T _test
0000000100003f04 t _testHelper
Note In the examples in this post, TestSymTab is a Mach-O executable that’s formed by linking two Mach-O object files, main.o and TestCore.o.
There are three columns here, and the second is the most important. It’s a single letter indicating the type of the entry. For example, T is a code symbol (in Unix parlance, code is in the text segment), D is a data symbol, and so on. An uppercase letter indicates that the symbol is visible to the linker; a lowercase letter indicates that it’s internal.
An undefined (U) symbol has two potential meanings:
In a Mach-O image, the symbol is typically imported from a specific dynamic library. The dynamic linker connects this import to the corresponding exported symbol of the dynamic library at load time.
In a Mach-O object file, the symbol is undefined. In most cases the linker will try to resolve this symbol at link time.
Note The above is a bit vague because there are numerous edge cases in how the system handles undefined symbols. For more on this, see Undefined Symbols, below.
The first column in the nm output is the address associated with the entry, or blank if an address is not relevant for this type of entry. For a Mach-O image, this address is based on the load address, so the actual address at runtime is offset by the slide. See An Apple Library Primer for more about those concepts.
The third column is the name for this entry. These names have a leading underscore because that’s the standard name mangling for C. See An Apple Library Primer for more about name mangling.
The nm tool has a lot of formatting options. The ones I use the most are:
-m — This prints more information about each symbol table entry. For example, if a symbol is imported from a dynamic library, this prints the library name. For a concrete example, see A Deeper Examination below.
-a — This prints all the entries, including debug symbols. We’ll come back to that in the Debug Symbols section, below.
-p — By default nm sorts entries by their address. This disables that sort, causing nm to print the entries in the order in which they occur in the symbol table.
-x — This outputs entries in a raw format, which is great when you’re trying to understand what’s really going on. See Raw Symbol Information, below, for an example of this.
A Deeper Examination
To get more information about each symbol table, run nm with the -m option:
% nm -m Products/Debug/TestSymTab
(undefined) external ___stdoutp (from libSystem)
0000000100000000 (__TEXT,__text) [referenced dynamically] external __mh_execute_header
(undefined) external _fprintf (from libSystem)
(undefined) external _getpid (from libSystem)
0000000100003f44 (__TEXT,__text) external _main
0000000100008000 (__DATA,__data) non-external _tDefault
0000000100003ecc (__TEXT,__text) external _test
0000000100003f04 (__TEXT,__text) non-external _testHelper
This contains a world of extra information about each entry. For example:
You no longer have to remember cryptic single letter codes. Instead of U, you get undefined.
If the symbol is imported from a dynamic library, it gives the name of that dynamic library. Here we see that _fprintf is imported from the libSystem library.
It surfaces additional, more obscure information. For example, the referenced dynamically flag is a flag used by the linker to indicate that a symbol is… well… referenced dynamically, and thus shouldn’t be dead stripped.
Undefined Symbols
Mach-O’s handling of undefined symbols is quite complex. To start, you need to draw a distinction between the linker (aka the static linker) and the dynamic linker.
Undefined Symbols at Link Time
The linker takes a set of files as its input and produces a single file as its output. The input files can be Mach-O images or dynamic libraries [1]. The output file is typically a Mach-O image [2]. The goal of the linker is to merge the object files, resolving any undefined symbols used by those object files, and create the Mach-O image.
There are two standard ways to resolve an undefined symbol:
To a symbol exported by another Mach-O object file
To a symbol exported by a dynamic library
In the first case, the undefined symbol disappears in a puff of linker magic. In the second case, it records that the generated Mach-O image depends on that dynamic library [3] and adds a symbol table entry for that specific symbol. That entry is also shown as undefined, but it now indicates the library that the symbol is being imported from.
This is the core of the two-level namespace. A Mach-O image that imports a symbol records both the symbol name and the library that exports the symbol.
The above describes the standard ways used by the linker to resolve symbols. However, there are many subtleties here. The most radical is the flat namespace. That’s out of scope for this post, because it’s a really bad option for the vast majority of products. However, if you’re curious, the ld man page has some info about how symbol resolution works in that case.
A more interesting case is the -undefined dynamic_lookup option. This represents a halfway house between the two-level namespace and the flat namespace. When you link a Mach-O image with this option, the linker resolves any undefined symbols by adding a dynamic lookup undefined entry to the symbol table. At load time, the dynamic linker attempts to resolve that symbol by searching all loaded images. This is useful if your software works on other Unix-y platforms, where a flat namespace is the norm. It can simplify your build system without going all the way to the flat namespace.
Of course, if you use this facility and there are multiple libraries that export that symbol, you might be in for a surprise!
[1] These days it’s more common for the build system to pass a stub library (.tbd) to the linker. The effect is much the same as passing in a dynamic library. In this discussion I’m sticking with the old mechanism, so just assume that I mean dynamic library or stub library.
If you’re unfamiliar with the concept of a stub library, see An Apple Library Primer.
[2] The linker can also merge the object files together into a single object file, but that’s relatively uncommon operation. For more on that, see the discussion of the -r option in the ld man page.
[3] It adds an LC_LOAD_DYLIB load command with the install name from the dynamic library. See Dynamic Library Identification for more on that.
Undefined Symbols at Load Time
When you load a Mach-O image the dynamic linker is responsible for finding all the libraries it depends on, loading them, and connecting your imports to their exports. In the typical case the undefined entry in your symbol table records the symbol name and the library that exports the symbol. This allows the dynamic linker to quickly and unambiguously find the correct symbol. However, if the entry is marked as dynamic lookup [1], the dynamic linker will search all loaded images for the symbol and connect your library to the first one it finds.
If the dynamic linker is unable to find a symbol, its default behaviour is to fail the load of the Mach-O image. This changes if the symbol is a weak reference. In that case, the dynamic linking continues to load the image but sets the address of the symbol to NULL. See Weak vs Weak vs Weak, below, for more about this.
[1] In this case nm shows the library name as dynamically looked up.
Weak vs Weak vs Weak
Mach-O supports two different types of weak symbols:
Weak references (aka weak imports)
Weak definitions
IMPORTANT If you use the term weak without qualification, the meaning depends on your audience. App developers tend to assume that you mean a weak reference whereas folks with a C++ background tend to assume that you mean a weak definition. It’s best to be specific.
Weak References
Weak references support the availability mechanism on Apple platforms. Most developers build their apps with the latest SDK and specify a deployment target, that is, the oldest OS version on which their app runs. Within the SDK, each declaration is annotated with the OS version that introduced that symbol [1]. If the app uses a symbol introduced later than its deployment target, the compiler flags that import as a weak reference. The app is then responsible for not using the symbol if it’s run on an OS release where it’s not available.
For example, consider this snippet:
#include <xpc/xpc.h>
void testWeakReference(void) {
printf("%p\n", xpc_listener_set_peer_code_signing_requirement);
}
The xpc_listener_set_peer_code_signing_requirement function is declared like so:
API_AVAILABLE(macos(14.4))
…
int
xpc_listener_set_peer_code_signing_requirement(…);
The API_AVAILABLE macro indicates that the symbol was introduced in macOS 14.4. If you build this code with the deployment target set to macOS 13, the symbol is marked as a weak reference:
% nm -m Products/Debug/TestWeakRefC
…
(undefined) weak external _xpc_listener_set_peer_code_signing_requirement (from libSystem)
If you run the above program on macOS 13, it’ll print NULL (actually 0x0).
Without support for weak references, the dynamic linker on macOS 13 would fail to load the program because the _xpc_listener_set_peer_code_signing_requirement symbol is unavailable.
[1] In practice most of the SDK’s declarations don’t have availability annotations because they were introduced before the minimum deployment target supported by that SDK.
Weak definitions
Weak references are about imports. Weak definitions are about exports. A weak definition allows you to export a symbol from multiple images. The dynamic linker coalesces these symbol definitions. Specifically:
The first time it loads a library with a given weak definition, the dynamic linker makes it the primary.
It registers that definition such that all references to the symbol resolve to it. This registration occurs in a namespace dedicated to weak definitions. That namespace is flat.
Any subsequent definitions of that symbol are ignored.
Weak definitions are weird, but they’re necessary to support C++’s One Definition Rule in a dynamically linked environment.
IMPORTANT Weak definitions are not just weird, but also inefficient. Avoid them where you can. To flush out any unexpected weak definitions, pass the -warn_weak_exports option to the static linker.
The easiest way to create a weak definition is with the weak attribute:
__attribute__((weak))
void testWeakDefinition(void) {
}
IMPORTANT The C++ compiler can generate weak definitions without weak ever appearing in your code.
This shows up in nm like so:
% nm -m Products/Debug/TestWeakDefC
…
0000000100003f40 (__TEXT,__text) weak external _testWeakDefinition
…
The output is quite subtle. A symbol flagged as weak external is either a weak reference or a weak definition depending on whether it’s undefined or not. For clarity, use dyld_info instead:
% dyld_info -imports -exports Products/Debug/TestWeakRefC
Products/Debug/TestWeakDefC [arm64]:
…
-imports:
…
0x0001 _xpc_listener_set_peer_code_signing_requirement [weak-import] (from libSystem)
% dyld_info -imports -exports Products/Debug/TestWeakDefC
Products/Debug/TestWeakDefC [arm64]:
-exports:
offset symbol
…
0x00003F40 _testWeakDefinition [weak-def]
…
…
Here, weak-import indicates a weak reference and weak-def a weak definition.
Weak Library
There’s one final confusing use of the term weak, that is, weak libraries. A Mach-O image includes a list of imported libraries and a list of symbols along with the libraries they’re imported from. If an image references a library that’s not present, the dynamic linker will fail to load the library even if all the symbols it references in that library are weak references.
To get around this you need to mark the library itself as weak. If you’re using Xcode it will often do this for your automatically. If it doesn’t, mark the library as optional in the Link Binary with Libraries build phase.
Use otool to see whether a library is required or optional. For example, this shows an optional library:
% otool -L Products/Debug/TestWeakRefC
Products/Debug/TestWeakRefC:
/usr/lib/libEndpointSecurity.dylib (… 511.60.5, weak)
…
In the non-optional case, there’s no weak indicator:
% otool -L Products/Debug/TestWeakRefC
Products/Debug/TestWeakRefC:
/usr/lib/libEndpointSecurity.dylib (… 511.60.5)
…
Debug Symbols
or Why the DWARF still stabs. (-:
Historically, all debug information was stored in symbol table entries, using a format knows as stabs. This format is now obsolete, having been largely replaced by DWARF. However, stabs symbols are still used for some specific roles.
Note See <mach-o/stab.h> and the stab man page for more about stabs on Apple platforms. See stabs and DWARF for general information about these formats.
In DWARF, debug symbols aren’t stored in the symbol table. Rather, debug information is stored in various __DWARF sections. For example:
% otool -l Intermediates.noindex/TestSymTab.build/Debug/TestSymTab.build/Objects-normal/arm64/TestCore.o | grep __DWARF -B 1
sectname __debug_abbrev
segname __DWARF
…
The compiler inserts this debug information into the Mach-O object file that it creates. Eventually this Mach-O object file is linked into a Mach-O image. At that point one of two things happens, depending on the Debug Information Format build setting.
During day-to-day development, set Debug Information Format to DWARF. When the linker creates a Mach-O image from a bunch of Mach-O object files, it doesn’t do anything with the DWARF information in those objects. Rather, it records references to the source objects files into the final image. This is super quick.
When you debug that Mach-O image, the debugger finds those references and uses them to locate the DWARF information in the original Mach-O object files.
Each reference is stored in a stabs OSO symbol table entry. To see them, run nm with the -a option:
% nm -a Products/Debug/TestSymTab
…
0000000000000000 - 00 0001 OSO …/Intermediates.noindex/TestSymTab.build/Debug/TestSymTab.build/Objects-normal/arm64/TestCore.o
0000000000000000 - 00 0001 OSO …/Intermediates.noindex/TestSymTab.build/Debug/TestSymTab.build/Objects-normal/arm64/main.o
…
Given the above, the debugger knows to look for DWARF information in TestCore.o and main.o. And notably, the executable does not contain any DWARF sections:
% otool -l Products/Debug/TestSymTab | grep __DWARF -B 1
%
When you build your app for distribution, set Debug Information Format to DWARF with dSYM File. The executable now contains no DWARF information:
% otool -l Products/Release/TestSymTab | grep __DWARF -B 1
%
Xcode runs dsymutil tool to collect the DWARF information, organise it, and export a .dSYM file. This is actually a document package, within which is a Mach-O dSYM companion file:
% find Products/Release/TestSymTab.dSYM
Products/Release/TestSymTab.dSYM
Products/Release/TestSymTab.dSYM/Contents
…
Products/Release/TestSymTab.dSYM/Contents/Resources/DWARF
Products/Release/TestSymTab.dSYM/Contents/Resources/DWARF/TestSymTab
…
% file Products/Release/TestSymTab.dSYM/Contents/Resources/DWARF/TestSymTab
Products/Release/TestSymTab.dSYM/Contents/Resources/DWARF/TestSymTab: Mach-O 64-bit dSYM companion file arm64
That file contains a copy of the the DWARF information from all the original Mach-O object files, optimised for use by the debugger:
% otool -l Products/Release/TestSymTab.dSYM/Contents/Resources/DWARF/TestSymTab | grep __DWARF -B 1
…
sectname __debug_line
segname __DWARF
…
Raw Symbol Information
As described above, each Mach-O file has a symbol table that’s an array of symbol table entries. The structure of each entry is defined by the declarations in <mach-o/nlist.h> [1]. While there is an nlist man page, the best documentation for this format is the the comments in the header itself.
Note The terms nlist stands for name list and dates back to truly ancient versions of Unix.
Each entry is represented by an nlist_64 structure (nlist for 32-bit Mach-O files) with five fields:
n_strx ‘points’ to the string for this entry.
n_type encodes the entry type. This is actually split up into four subfields, as discussed below.
n_sect is the section number for this entry.
n_desc is additional information.
n_value is the address of the symbol.
The four fields within n_type are N_STAB (3 bits), N_PEXT (1 bit), N_TYPE (3 bits), and N_EXT (1 bit).
To see these raw values, run nm with the -x option:
% nm -a -x Products/Debug/TestSymTab
…
0000000000000000 01 00 0300 00000036 _getpid
0000000100003f44 24 01 0000 00000016 _main
0000000100003f44 0f 01 0000 00000016 _main
…
This prints a column for n_value, n_type, n_sect, n_desc, and n_strx. The last column is the string you get when you follow the ‘pointer’ in n_strx.
The mechanism used to encode all the necessary info into these fields is both complex and arcane. For the details, see the comments in <mach-o/nlist.h> and <mach-o/stab.h>. However, just to give you a taste:
The entry for getpid has an n_type field with just the N_EXT flag set, indicating that this is an external symbol. The n_sect field is 0, indicating a text symbol. And n_desc is 0x0300, with the top byte indicating that the symbol is imported from the third dynamic library.
The first entry for _main has an n_type field set to N_FUN, indicating a stabs function symbol. The n_desc field is the line number, that is, line 22.
The second entry for _main has an n_type field with N_TYPE set to N_SECT and the N_EXT flag set, indicating a symbol exported from a section. In this case the section number is 1, that is, the text section.
[1] There is also an <nlist.h> header that defines an API that returns the symbol table. The difference between <nlist.h> and <mach-o/nlist.h> is that the former defines an API whereas the latter defines the Mach-O on-disk format. Don’t include both; that won’t end well!
I'm trying to make an xcframework from my static library (SPM btw) with macros. My script doesn't work properly
My SPM declaration of macros:
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import CompilerPluginSupport
import PackageDescription
let package = Package(
name: "SomeMacr",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .macCatalyst(.v13)],
products: [
.library(
name: "SomeMacr",
targets: ["SomeMacr"]
),
.executable(
name: "SomeMacrClient",
targets: ["SomeMacrClient"]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0")
],
targets: [
.macro(
name: "SomeMacrMacros",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
]
),
.target(name: "SomeMacr", dependencies: ["SomeMacrMacros"]),
.executableTarget(name: "SomeMacrClient", dependencies: ["SomeMacr"]),
.testTarget(
name: "SomeMacrTests",
dependencies: [
"SomeMacrMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax")
]
)
]
)
My .sh script:
xcodebuild archive \
-scheme $1 \
-sdk iphoneos \
-archivePath "Products/archives/ios_devices.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $1 \
-sdk iphonesimulator \
-archivePath "Products/archives/ios_simulators.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $1 \
-sdk macosx \
-archivePath "Products/archives/macos.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild -create-xcframework \
-library Products/archives/ios_devices.xcarchive/Products/Library/Frameworks/lib$1.a \
-library Products/archives/ios_simulators.xcarchive/Products/Library/Frameworks/lib$1.a \
-library Products/archives/macos.xcarchive/Products/Library/Frameworks/lib$1.a \
-output Products/xc/$1.xcframework
It requires destination (But in other tutorials, authors clearly shows, that after this script I will get an xcframework)
xcodebuild: error: Building a Swift package requires that a destination is provided using the "-destination" option. The "-showdestinations" option can be used to list the available destinations
But when I setup the destination it was compiled to exec file, which I don't mind how to include to another SPM package / or xcframework
What am I doing wrong?
Topic:
Developer Tools & Services
SubTopic:
General
Tags:
Extensions
Frameworks
Swift Packages
Swift
% mkdir /tmp/test
% cd /tmp/test
% touch {a,b,c}{1,2,3,4,5,6}.txt
% lf
a1.txt a3.txt a5.txt b1.txt b3.txt b5.txt c1.txt c3.txt c5.txt
a2.txt a4.txt a6.txt b2.txt b4.txt b6.txt c2.txt c4.txt c6.txt
% echo [b-z]*.txt
a1.txt a2.txt a3.txt a4.txt a5.txt a6.txt b1.txt b2.txt b3.txt b4.txt b5.txt b6.txt c1.txt c2.txt c3.txt c4.txt c5.txt c6.txt
I filed FB16715590 about this. I have a vague memory this might be related to some code to pretend to be case insensitive, but I can't find it now.
Do you know any software that indicates the frequency of the cores in real time?
the macbook pro adapts the frequency of the cores according to the load/temperature it seems to me
thank
Hello,
There seems to be a regression with macOS SDK 15 and dynamically loading libraries if Address Sanitizer is turned on. Seems to only affect Debug builds, and .frameworks. I've also reported this via the Feedback Assistant: FB16513866
Here's a minimal repro, if anyone is interested: https://gist.github.com/peter-esik/6b00432e411be85333e14ae7d953966e
I thought I'd post this here, as according to my web searches, this isn't a very well-known bug at this point.
I wanted to take an old iPhone 11 Pro and downgrade from iOS 18 beta to iOS 17 for testing. I can download today (Sept 26) the restore image for the iPhone 11 Pro (and many others) but when I try to restore it (Finder Option click, select restore image), Apple rejects it (I guess they won't sign it).
If find this to be a problem. There is no reason why an iPhone in developer mode can't be used for testing a release less than a few weeks after the next release comes out.
Why do they have the restore images if you can't use them? Why is there no restore images for iOS 17.7?