Skip to content

Commit 747edbf

Browse files
committed
feat(build): add support for creating xcframeworks for iOS and macOS
1 parent b049bad commit 747edbf

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

Makefile

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,54 @@ endif
310310
mv $(CURL_SRC)/lib/.libs/libcurl.a $(CURL_DIR)/$(PLATFORM)
311311
rm -rf $(CURL_DIR)/src
312312

313+
.NOTPARALLEL: %.dylib
314+
%.dylib:
315+
rm -rf $(BUILD_DIRS) && $(MAKE) PLATFORM=$*
316+
mv $(DIST_DIR)/cloudsync.dylib $(DIST_DIR)/$@
317+
318+
define PLIST
319+
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
320+
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\
321+
<plist version=\"1.0\">\
322+
<dict>\
323+
<key>CFBundleDevelopmentRegion</key>\
324+
<string>en</string>\
325+
<key>CFBundleExecutable</key>\
326+
<string>cloudsync</string>\
327+
<key>CFBundleIdentifier</key>\
328+
<string>ai.sqlite.cloudsync</string>\
329+
<key>CFBundleInfoDictionaryVersion</key>\
330+
<string>6.0</string>\
331+
<key>CFBundlePackageType</key>\
332+
<string>FMWK</string>\
333+
<key>CFBundleSignature</key>\
334+
<string>????</string>\
335+
<key>CFBundleVersion</key>\
336+
<string>$(shell make version)</string>\
337+
<key>CFBundleShortVersionString</key>\
338+
<string>$(shell make version)</string>\
339+
<key>MinimumOSVersion</key>\
340+
<string>11.0</string>\
341+
</dict>\
342+
</plist>
343+
endef
344+
345+
LIB_NAMES = ios.dylib isim.dylib macos.dylib
346+
FMWK_NAMES = ios-arm64 ios-arm64_x86_64-simulator macos-arm64_x86_64
347+
$(DIST_DIR)/%.xcframework: $(LIB_NAMES)
348+
@$(foreach i,1 2 3,\
349+
lib=$(word $(i),$(LIB_NAMES)); \
350+
fmwk=$(word $(i),$(FMWK_NAMES)); \
351+
mkdir -p $(DIST_DIR)/$$fmwk/cloudsync.framework; \
352+
printf "$(PLIST)" > $(DIST_DIR)/$$fmwk/cloudsync.framework/Info.plist; \
353+
mv $(DIST_DIR)/$$lib $(DIST_DIR)/$$fmwk/cloudsync.framework/cloudsync; \
354+
install_name_tool -id "@rpath/cloudsync.framework/cloudsync" $(DIST_DIR)/$$fmwk/cloudsync.framework/cloudsync; \
355+
)
356+
xcodebuild -create-xcframework $(foreach fmwk,$(FMWK_NAMES),-framework $(DIST_DIR)/$(fmwk)/cloudsync.framework) -output $@
357+
rm -rf $(foreach fmwk,$(FMWK_NAMES),$(DIST_DIR)/$(fmwk))
358+
359+
xcframework: $(DIST_DIR)/cloudsync.xcframework
360+
313361
# Tools
314362
sqlite_version:
315363
@echo $(SQLITE_VERSION)
@@ -341,4 +389,4 @@ help:
341389
@echo " test [COVERAGE=true] - Test the extension with optional coverage output"
342390
@echo " help - Display this help message"
343391

344-
.PHONY: all clean test extension help
392+
.PHONY: all clean test extension help xcframework

0 commit comments

Comments
 (0)