importing costum swift framework into my project codenameone?

50 views
Skip to first unread message

Amine ABIABA

unread,
Jun 18, 2020, 7:33:11 AM6/18/20
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Jun 18, 2020, 11:02:14 PM6/18/20
to CodenameOne Discussions
Wrap the swift calls with an objective-c or C API and package that into a static library. Export the Objective-C or C code and a header API file. Then the static library and header file can be placed in the native/ios directory. Once there you can invoke that code from the native interface just like any other native API

Amine ABIABA

unread,
Jun 19, 2020, 8:03:06 AM6/19/20
to codenameone...@googlegroups.com

Hi Shai 
I was trying to use  swift library  (randomGenerator.framework) . but not working for me.

warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'RandomGenerator' from project 'Pods')
** ARCHIVE FAILED **


The following build commands failed:
CompileC /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build7750962809406776673xxx/dist/build/Build/Intermediates.noindex/ArchiveIntermediates/cameraApp/IntermediateBuildFilesPath/cameraApp.build/Release-iphoneos/cameraApp.build/Objects-normal/arm64/com_superAlpha_cameraApp_myNativeImpl.o /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build7750962809406776673xxx/dist/cameraApp-src/com_superAlpha_cameraApp_myNativeImpl.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler

Le ven. 19 juin 2020 à 04:02, Shai Almog <shai....@gmail.com> a écrit :
Wrap the swift calls with an objective-c or C API and package that into a static library. Export the Objective-C or C code and a header API file. Then the static library and header file can be placed in the native/ios directory. Once there you can invoke that code from the native interface just like any other native API

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/a3e84125-f92e-4e6d-9652-253734f07b8do%40googlegroups.com.

Amine ABIABA

unread,
Jun 19, 2020, 8:17:59 AM6/19/20
to codenameone...@googlegroups.com
/var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build1428186720654561546xxx/dist/cameraApp-src/com_superAlpha_cameraApp_myNativeImpl.m:2:9: fatal error: ' RandomGenerator-Swift.h' file not found
#import "RandomGenerator-Swift.h"
        ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.

warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'MySexyRandom' from project 'Pods')

** ARCHIVE FAILED **


The following build commands failed:
CompileC /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build1428186720654561546xxx/dist/build/Build/Intermediates.noindex/ArchiveIntermediates/cameraApp/IntermediateBuildFilesPath/cameraApp.build/Release-iphoneos/cameraApp.build/Objects-normal/arm64/com_superAlpha_cameraApp_myNativeImpl.o /var/folders/zh/kb_4hqhn4kg1h0r5dp_6htcm0000gn/T/build1428186720654561546xxx/dist/cameraApp-src/com_superAlpha_cameraApp_myNativeImpl.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Process return code is 65
Failed xcodebuild step

Shai Almog

unread,
Jun 20, 2020, 1:31:27 AM6/20/20
to CodenameOne Discussions
You can't import a swift file directly. You need to use xcode to generate a static library with an Objective-C exported header from that library.

Amine ABIABA

unread,
Jun 25, 2020, 6:30:31 AM6/25/20
to codenameone...@googlegroups.com
Hi Shai ,
When i exported the code source and integrated it in the Xcode and i integrated the framework in the project codenameone , it works well. But when I transform the generale changit in target, i  changed the embed by "embed without singing", how I can change it on hinds build ? 
Annotation 2020-06-25 111838.png

Le sam. 20 juin 2020 à 06:31, Shai Almog <shai....@gmail.com> a écrit :
You can't import a swift file directly. You need to use xcode to generate a static library with an Objective-C exported header from that library.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.

Shai Almog

unread,
Jun 25, 2020, 10:49:52 PM6/25/20
to CodenameOne Discussions
Hi,
you need a static library not a framework. You can open the framework directory and find the actual binary file within rename it to libMyFramework.a and move that into the native/ios directory together with your headers.
Reply all
Reply to author
Forward
0 new messages