Changes
4 changed files (+124/-1)
-
-
@@ -41,6 +41,86 @@mod.addImport("sood", sood); } // XCFramework // https://mitchellh.com/writing/zig-and-swiftui if (target.result.os.tag.isDarwin()) { const arm = b.addLibrary(.{ .name = "plac_core_arm", .linkage = .static, .root_module = b.createModule(.{ .root_source_file = b.path("src/lib.zig"), .target = b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .aarch64, }), .optimize = optimize, }), }); // While I could have dedicated unit just for copying, this is simpler and easier. arm.installHeader(b.path("src/lib.h"), "plac_core.h"); arm.installHeader(b.path("src/lib.modulemap"), "module.modulemap"); const intel = b.addLibrary(.{ .name = "plac_core_intel", .linkage = .static, .root_module = b.createModule(.{ .root_source_file = b.path("src/lib.zig"), .target = b.resolveTargetQuery(.{ .os_tag = .macos, .cpu_arch = .x86_64, }), .optimize = optimize, }), }); inline for (.{ arm, intel }) |compile| { compile.linkLibC(); // Without bundling those, XCode unable to resolve symbols. compile.bundle_compiler_rt = true; compile.bundle_ubsan_rt = true; compile.root_module.addImport("sood", sood); } const universal_lib = universal: { const lipo = b.addSystemCommand(&.{"lipo"}); lipo.addArg("-create"); lipo.addArg("-output"); const output = lipo.addOutputFileArg("libplac_core.a"); lipo.addFileArg(arm.getEmittedBin()); lipo.addFileArg(intel.getEmittedBin()); break :universal output; }; const xcframework = xcframework: { const xcodebuild = b.addSystemCommand(&.{"xcodebuild"}); xcodebuild.addArg("-create-xcframework"); xcodebuild.addArg("-library"); xcodebuild.addFileArg(universal_lib); xcodebuild.addArg("-headers"); xcodebuild.addDirectoryArg(arm.getEmittedIncludeTree()); xcodebuild.addArg("-output"); break :xcframework xcodebuild.addOutputDirectoryArg("PlacCore.xcframework"); }; const step = b.step("xcframework", "Build xcframework file for XCode"); step.dependOn(&b.addInstallDirectory(.{ .source_dir = xcframework, .install_dir = .{ .custom = "xcframeworks" }, .install_subdir = "PlacCore.xcframework", }).step); } // Static library (C API) { const linkage = b.option(
-
-
core/src/lib.modulemap (new)
-
@@ -0,0 +1,19 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 module PlacCore { umbrella header "plac_core.h" export * }
-
-
-
@@ -6,6 +6,10 @@ };objectVersion = 77; objects = { /* Begin PBXBuildFile section */ C3490F972DB36DC40030476A /* PlacCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3490F962DB36DC40030476A /* PlacCore.xcframework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ C3EABC802DB1170700F786D6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy;
-
@@ -24,6 +28,7 @@ };/* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ C3490F962DB36DC40030476A /* PlacCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = PlacCore.xcframework; path = "../core/zig-out/xcframeworks/PlacCore.xcframework"; sourceTree = "<group>"; }; C3EABC712DB1170400F786D6 /* plac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = plac.app; sourceTree = BUILT_PRODUCTS_DIR; }; C3EABC7F2DB1170700F786D6 /* placTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = placTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C3EABC892DB1170700F786D6 /* placUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = placUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
-
@@ -52,6 +57,7 @@ C3EABC6E2DB1170400F786D6 /* Frameworks */ = {isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( C3490F972DB36DC40030476A /* PlacCore.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; };
-
@@ -72,12 +78,21 @@ };/* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ C3490F952DB36DC30030476A /* Frameworks */ = { isa = PBXGroup; children = ( C3490F962DB36DC40030476A /* PlacCore.xcframework */, ); name = Frameworks; sourceTree = "<group>"; }; C3EABC682DB1170400F786D6 = { isa = PBXGroup; children = ( C3EABC732DB1170400F786D6 /* plac */, C3EABC822DB1170700F786D6 /* placTests */, C3EABC8C2DB1170700F786D6 /* placUITests */, C3490F952DB36DC30030476A /* Frameworks */, C3EABC722DB1170400F786D6 /* Products */, ); sourceTree = "<group>";
-
-
-
@@ -14,15 +14,24 @@ // limitations under the License.// // SPDX-License-Identifier: Apache-2.0 import PlacCore import SwiftUI func getDefaultReceiveWindow() -> UInt32 { var opts = PlacCore.plac_server_scan_options() PlacCore.plac_server_scan_options_init(&opts) return opts.receive_window_ms } struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Text( String(format: "Window = %u", getDefaultReceiveWindow())) } .padding() }
-