Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create ios framework with dylib

Tags:

ios

dylib

I have 60k lines of pascal code (don't ask :-) ). Compiled a dylib for armv7 and aarch64 with free pascal. It works on device but can not upload it to appstore in case of

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

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).

So, according to this there should be a way to create a framework with dylib. Besides there are lot of frameworks with libraries: Fabric, Crashlytics, Firebase, GoogleAnalytics, etc.

I looked into this frameworks and created my own. But now I have error

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

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?

Thanks.


Compiled a dylib for armv7 and aarch64 with free pascal. dlopen() works well but can not upload it to appstore.

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

Tried to make simple framework, but

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.

Need working framework with dylib.

like image 204
Lapushkazaika Avatar asked Sep 02 '19 10:09

Lapushkazaika


1 Answers

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.

# 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
like image 95
Cyberbeni Avatar answered Oct 19 '22 20:10

Cyberbeni