简体   繁体   English

使用 dylib 创建 ios 框架

[英]Create ios framework with dylib

I have 60k lines of pascal code (don't ask :-) ).我有 60k 行 pascal 代码(不要问 :-) )。 Compiled a dylib for armv7 and aarch64 with free pascal.使用免费的 pascal 为 armv7 和 aarch64 编译了一个 dylib。 It works on device but can not upload it to appstore in case of它适用于设备,但无法将其上传到应用商店以防万一

Invalid Swift Support - The SwiftSupport folder is missing.无效的 Swift 支持 - 缺少 SwiftSupport 文件夹。 Rebuild your app using the current public (GM) version of Xcode and resubmit it.使用当前公共 (GM) 版本的 Xcode 重建您的应用程序并重新提交。

It means that这意味着

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)在 iOS、watchOS 或 tvOS 上不受支持,除了 Xcode (tn2435) 提供的系统 Swift 库。

So, according to this there should be a way to create a framework with dylib.因此,根据this应该有一种方法可以使用dylib创建框架。 Besides there are lot of frameworks with libraries: Fabric, Crashlytics, Firebase, GoogleAnalytics, etc.此外还有很多带有库的框架:Fabric、Crashlytics、Firebase、GoogleAnalytics 等。

I looked into this frameworks and created my own.我研究了这个框架并创建了我自己的框架。 But now I have error但现在我有错误

The binary file 'test.dylib' is not permitted.不允许使用二进制文件“test.dylib”。 Your app can't contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles.除了受支持包的 CFBundleExecutable 之外,您的应用程序不能包含独立的可执行文件或库。

So, my questions is how to create a framework with dylib (with Function test(foo: integer): integer; cdecl;), load it and use in ObjectiveC project?所以,我的问题是如何创建一个带有 dylib 的框架(带有 Function test(foo: integer): integer; cdecl;),加载它并在 ObjectiveC 项目中使用?

Thanks.谢谢。


Compiled a dylib for armv7 and aarch64 with free pascal.使用免费的 pascal 为 armv7 和 aarch64 编译了一个 dylib。 dlopen() works well but can not upload it to appstore. dlopen() 运行良好,但无法将其上传到应用商店。

Invalid Swift Support - The SwiftSupport folder is missing.无效的 Swift 支持 - 缺少 SwiftSupport 文件夹。 Rebuild your app using the current public (GM) version of Xcode and resubmit it.使用当前公共 (GM) 版本的 Xcode 重建您的应用程序并重新提交。

Tried to make simple framework, but试图制作简单的框架,但是

The binary file 'test.dylib' is not permitted.不允许使用二进制文件“test.dylib”。 Your app can't contain standalone executables or libraries, other than the CFBundleExecutable of supported bundles.除了受支持包的 CFBundleExecutable 之外,您的应用程序不能包含独立的可执行文件或库。


library fpctest;

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

uses sysutils;

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

Exports
  test;
end.

Need working framework with dylib.需要使用 dylib 的工作框架。

Commented out the project specific parts.注释掉项目特定部分。 You can get your Info.plist and DSYM Info.plist by creating a dummy framework and copying it from there.您可以通过创建一个虚拟框架并从那里复制它来获取您的 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 and SOURCE_INFO_PLIST for the library
mkdir -p "$FW_PATH"
cp "$SOURCE_INFO_PLIST" "$INFO_PLIST"
lipo $DYLIBS -output "$OUT_DYLIB" -create
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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM