ios - 使用dylib创建ios框架

标签 ios dylib

我有 60k 行 pascal 代码(不要问:-))。使用free pascal为armv7和aarch64编译了dylib。它可以在设备上运行,但在以下情况下无法将其上传到应用商店

Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

这意味着

Dynamic libraries outside of a framework bundle, which typically have the file extension .dylib, are not supported on iOS, watchOS, or tvOS, except for the system Swift libraries provided by Xcode (tn2435).

所以,根据这个,应该有一种方法可以用dylib创建一个框架。此外,还有很多带有库的框架:Fabric、Crashlytics、Firebase、GoogleAnalytics 等。

我研究了这个框架并创建了自己的框架。但现在我有错误

The binary file 'test.dylib' is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles.

所以,我的问题是如何使用 dylib 创建一个框架(使用 Function test(foo:integer):integer;cdecl;),加载它并在 ObjectiveC 项目中使用?

谢谢。

<小时/>

使用 free pascal 编译了适用于 armv7 和 aarch64 的 dylib。 dlopen() 运行良好,但无法上传到应用商店。

Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

尝试制作简单的框架,但是

The binary file 'test.dylib' is not permitted. Your app can’t contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles.

<小时/>
library fpctest;

{$ifdef fpc}
 {$mode delphi}
{$endif}

uses sysutils;

Function test (foo: integer) : integer; cdecl;
begin
  Result := foo * 2;
end;

Exports
  test;
end.
<小时/>

需要 dylib 的工作框架。

最佳答案

注释掉了项目特定部分。您可以通过创建一个虚拟框架并从那里复制来获取 Info.plist 和 DSYM Info.plist。

# set OUT_DIR and LIB_NAME
FW_PATH="$OUT_DIR/$LIB_NAME.framework"
INFO_PLIST="$FW_PATH/Info.plist"
OUT_DYLIB="$FW_PATH/$LIB_NAME"

# set the DYLIBS, SOURCE_INFO_PLIST and HEADER_PATH for the library
mkdir -p "$FW_PATH"
cp "$SOURCE_INFO_PLIST" "$INFO_PLIST"
lipo $DYLIBS -output "$OUT_DYLIB" -create
mkdir -p "$FW_PATH/Headers"
cp "$HEADER_PATH" "$FW_PATH/Headers"
install_name_tool -id @rpath/$LIB_NAME.framework/$LIB_NAME "$OUT_DYLIB"

# set the DYLIBS and SOURCE_INFO_PLIST for DSYM
OUT_DSYM_PATH="$FW_PATH.dSYM/Contents/Resources/DWARF"
INFO_PLIST="$FW_PATH.dSYM/Contents/Info.plist"
mkdir -p "$OUT_DSYM_PATH"
cp "$SOURCE_INFO_PLIST" "$INFO_PLIST"
lipo $DYLIBS -output "$OUT_DSYM_PATH/$LIB_NAME" -create

关于ios - 使用dylib创建ios框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57755276/

相关文章:

ios - 带有自定义 selectedBackgroundView 的 UITableViewCell,它比 UISplitViewController 上的主视图 Controller 更宽

ios - 奇怪的错误/SIGABRT 线程 1

ios - 确保两个计时器的执行逻辑不会同时运行

c++ - gazebo ros插件报错: Undefined symbols for architecture x86_64

dylib - 使用 dlopen 查找 dylib 版本

java - Mac OSX 10.9.3 上 JCUDA 0.6.0 的打包

HTML 视频无法在苹果设备(Chrome/Safari/等)上运行

ios - 如何解决错误 'No visible @interface for ' UIViewController' declares the selector ''

xcode - "Undefined symbols for architecture x86_64:"

macos - OSX stat() 和 libffi