Skip to content

Conversation

carson-katri
Copy link

This adds support for building dependencies for iOS. It depends on lightpanda-io/zig-v8-fork#96 for v8.

Lightpanda can be built for iOS with these commands:

make get-v8
OS=ios make build-v8

export OS=iphonesimulator
export ARCH=arm64
export SDK=$(xcrun --sdk $OS --show-sdk-path)
export CC=$(xcrun --sdk "$SDK" -f clang)
export CXX=$(xcrun --sdk "$SDK" -f clang++)
export CPP="$CC -E"
export AR="$(xcrun --sdk "$SDK" -f ar)"
export RANLIB="$(xcrun --sdk "$SDK" -f ranlib)"
export CFLAGS="-isysroot \"$SDK\" -arch $ARCH -mios-simulator-version-min=16.0"
export LDFLAGS="-isysroot \"$SDK\" -arch $ARCH -mios-simulator-version-min=16.0"
export MAKE="make CC=$CC AR=$AR RANLIB=$RANLIB"
export CMAKE="cmake -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=$ARCH -DCMAKE_OSX_SYSROOT=\"$SDK\" -DCMAKE_OSX_DEPLOYMENT_TARGET=16.0"
export AUTOCONF_FLAGS="--disable-shared --host=arm-apple-darwin CC=\"$CC\" CXX=\"$CXX\" CPP=\"$CPP\" AR=\"$AR\" RANLIB=\"$RANLIB\" CFLAGS=\"$CFLAGS\" CPPFLAGS=\"$CFLAGS\" LDFLAGS=\"$LDFLAGS\""
export SKIP_EXAMPLES=1
make install

SDK=$(xcrun --sdk iphonesimulator --show-sdk-path) zig build -Dtarget=aarch64-ios-simulator -Dcpu=apple_m1 --release=safe

Note

The lightpanda executable cannot be built for iOS. build.zig should be modified to produce a liblightpanda.a file that can be included in an xcframework.

Copy link

github-actions bot commented Sep 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@carson-katri
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Member

@krichprollsch krichprollsch left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

The lightpanda executable cannot be built for iOS. build.zig should be modified to produce a liblightpanda.a file that can be included in an xcframework.

What about adding a new step for ios only generating this lib?
And erroring the steps not compatibles w/ ios?

src/app.zig Outdated
}

if (@import("builtin").os.tag == .ios) {
return null; // getAppDataDir is not available on iOS
Copy link
Member

Choose a reason for hiding this comment

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

Do we have an alternative dir to use on ios?

Copy link
Author

Choose a reason for hiding this comment

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

I inlined the macOS version.

build.zig Outdated
mbedtls.addIncludePath(b.path(root ++ "library"));

mbedtls.addCSourceFiles(.{ .flags = &.{}, .files = &.{
mbedtls.addCSourceFiles(.{ .flags = &.{"-Wno-nullability-completeness"}, .files = &.{
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about changing this flag for all build.
Maybe it could be conditional for ios only for now? Or is there another reason to use it?

Copy link
Author

Choose a reason for hiding this comment

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

I adjusted it to only add that flag for iOS builds.

@carson-katri
Copy link
Author

carson-katri commented Sep 18, 2025

I added a zig build static-lib step based on lib.zig. Right now this is empty, but it can include extern definitions. We're building out the API we need for liveview-native this way.

We're going to want this static lib on other platforms too, so I didn't restrict it to iOS.

Copy link
Member

@krichprollsch krichprollsch left a comment

Choose a reason for hiding this comment

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

Please can you rebase the PR to remove the .DS_Store file 🙏

May I suggest you to configure a global .gitgnore file to avoid the risk of committing these kind of files. We don't want to add this into the project's gitignore because it relates to the dev workspace.

// static lib
// -------
const static_lib_module = b.addModule("lightpanda", .{
.root_source_file = b.path("src/lib.zig"),
Copy link
Member

Choose a reason for hiding this comment

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

I have an error b/c this file is missing when I'm trying to run zig build static-lib

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