Skip to content

[iOS] Linker error: libpng symbols not found — missing -lpng16 in OTHER_LDFLAGS #47

@codemountain

Description

@codemountain

What were you trying to do?

Build an iOS app using php artisan native:run ios on both physical and simulator

What happened?

Build fails with linker errors. libphp.a (GD extension) references png_* symbols but libpng
is not linked in the generated Xcode project.

Affects both simulator (Debug-iphonesimulator) and device (Debug-iphoneos) targets.

How to reproduce the bug

  1. php artisan native:install ios --force
  2. php artisan native:run ios
  3. Build fails at linker stage

Debug Output

"_png_create_read_struct", referenced from:
_php_gd_gdImageCreateFromPngCtx in libphp.a(gd_png.o)
"_png_write_info", referenced from:
_php_gd_gdImagePngCtxEx in libphp.a(gd_png.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1

Missing symbols include: png_create_read_struct, png_create_write_struct,
png_destroy_read_struct, png_destroy_write_struct, png_get_IHDR, png_get_PLTE,
png_read_image, png_write_image, png_write_info, png_write_end, and ~15 more.

The static libraries exist but aren't linked:

$ ls nativephp/ios/Libraries/iphonesimulator/libpng*
libpng.a
libpng16.a

$ ls nativephp/ios/Libraries/iphoneos/libpng*
libpng.a
libpng16.a

$ ls nativephp/ios/Include/libpng16/
png.h pngconf.h pnglibconf.h

But project.pbxproj only links -lresolv:

OTHER_LDFLAGS = (
"$(inherited)",
"-lresolv",
);

Which operating systems have you seen this occur on?

macOS

Which platforms were you trying to build for?

iOS (Simulator)

Notes

  • nativephp/mobile: v3.1.x-dev (mobile-air repo)
  • macOS: Darwin 24.6.0
  • Xcode: Latest (ran xcodebuild -runFirstLaunch before build)
  • CocoaPods: Installed successfully, issue is in the Xcode project template
  • Suggested fix: Add -lpng16 to OTHER_LDFLAGS in the generated project.pbxproj

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions