ethereum/go-ethereum

[iOS] Static Framework: Unable to include Geth in podspec

ronaldmannak opened this issue · 4 comments

System information

Geth version: 1.7.1
OS & Version: iOS

Expected behaviour

I expect the Geth framework to work both when added to a podfile and to a podspec file. Third party frameworks that depend on Geth should be able to add Geth in the podspec file as a dependency.

Actual behaviour

Geth cannot be added to podspec file, complicating creating frameworks that use Geth. The error pod lib lint <name of third party framework>.podspec encounters is:

- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include static binaries: (/private/var/folders/bc/q3fvxvx12bz89_y5wl2kysv80000gn/T/CocoaPods-Lint-20171010-28205-tjowza-Swifthereum/Pods/Geth/Frameworks/Geth.framework)) during validation.

The root cause is that Geth.framework is a static framework, not a dynamic framework, limiting the use of Geth on iOS considerably.

Steps to reproduce the behaviour

  • Create a new framework pod lib create MyLibrary and choose Swift, Yes, none, no
  • Edit the MyLibrary.podspec file and add the line s.dependency 'Geth', '~> 1.7.1'
  • run pod lib lint Swifthereum.podspec

Note that lint will fail with the error listed above.

I've spent a some time today digging into the build scripts and the gomobile docs.

Setting the -dynamic argument of libtool linker should produce a dynamic framework. This is equivalent to setting Mach-O Type to Dynamic Library in the Linker section of the Xcode build settings.

I haven't been able to compile the geth framework using gomobile manually yet, but I do see a build flags argument which suggests those will passed on to the xcode build environment. Can someone confirm that is the case and we can pass custom arguments to the xcode linker?

One sub-optimal option is to include the built Geth.framework in your Pod/Assets and include it in your podspec using:
s.vendored_frameworks = 'Pod/Assets/Geth.framework'

I have gotten this to work for my own development pod. However, I am unable to import Geth in the application code, but I can call public classes and methods in my Pod.

Furthermore, I am unable to get XCTest code to compile with dependencies on Geth.

@hughlang how to include the built Geth.framework in Pod/Assets?

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.