1

I need to use an iOS .framework dynamic library with Codename One, but I didn't find proper instructions.

In the developers guide (section: https://www.codenameone.com/manual/advanced-topics.html#_bundling_native_ios_sdk) there are the following tips, but there are not seem to work:

Find the "binary" file within the framework, and copy it into your native/ios directory - but rename it libXXX.a (where XXX is the name of the binary).

Copy all .h files from the framework into your native/ios directory.

Update all #import statements in the headers from #import format to simply #import "FileName.h"

This doesn't work when the *.framework doesn't contain a static library but a dynamic one (as suggested in the answers to How to create static library from an existing framework in iOS?).

Before iOS 8, all .framework files contained only static libraries, but starting from iOS 8 Apple is permitting developers to create dynamic frameworks (as reported in https://stackoverflow.com/a/15331319/1277576).

Francesco Galgani
  • 6,137
  • 3
  • 20
  • 23

2 Answers2

1

I'm afraid we never worked with iOS dynamic library frameworks as cocoapods became universal and took over the need for working with frameworks evaporated. Frameworks are problematic as they can't be shared with PC developers since they have symbolic links within them etc. So sending them as part of the build process would be problematic.

Most cases that needed creative solutions created a custom pod.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Just to be sure that I understood your hint: have I to place the `.framework` inside a cocoapod? If it's so, today I spent all the day trying to do that, without success. If you already done that, could you please suggest me a guide with the correct steps? Thank you – Francesco Galgani Oct 12 '19 at 22:31
  • I've never done it but Steve has some experience in that, I'll point him to this question – Shai Almog Oct 13 '19 at 02:04
1

Updated Answer:

Starting with the next update (Next friday), you'll be able to include iOS frameworks by simply zipping up the framework, and adding it to your project's native/ios directory. Eg. native/ios/MyFramework.framework.

You can still, alternatively, create a custom podspec as a part of your project. The steps are:

  1. Add native/ios/podspecs/MyFramework.podspec with contents:
Pod::Spec.new do |s|
  s.name                    = "MyFramework"
  s.version                 = "1.0.0"
  s.summary                 = "MyFramework framework"
  s.description             = "This spec specifies a vendored framework."
  s.platform                = :ios
  s.homepage                = "https://www.codenameone.com"
  s.source                  = {:path => "."}
  s.author                  = "Codename One"
  s.vendored_frameworks     = "MyFramework.framework"
end
  1. Copy the MyFramework.framework into native/ios/podspecs

  2. Build hints:

ios.pods=MyFramework

This workaround isn't perfect because the project probably isn't portable to Windows ( but it should work on Linux and Mac). The new method (zipping the framework and adding to native/ios) is 100% portable.

Original Answer:

For frameworks, you can place them inside a custom podspec. Here is a sample Codename One project that defines a custom podspec. https://github.com/shannah/TestCustomPodspec

Notice, all you need to do is create a native/ios/podspecs directory in your project, and then you can place your custom podspecs in there. You can reference your podspec using the ios.pods build hint.

For information on packaging your .framework in a Podspec, this article looks pretty informative, starting at "Consume Framework Using Local CocoaPods"

steve hannah
  • 4,586
  • 11
  • 18