add Widespread C++ Code inside a Flutter Plugin in order that it is accessible to each iOS and Android Environments?

0
23
add Widespread C++ Code inside a Flutter Plugin in order that it is accessible to each iOS and Android Environments?


I’ve a flutter plugin (lets name is FPlugin) which majorly works with C++ code.
The circulate is like this –

Flutter App -> Flutter Plugin -> Calls C++ code by way of DartFFI

This undertaking was initially meant for Android surroundings and so they used CMake, and so on to make all of the C++ recordsdata accessible in scope by placing it immediately inside /android folder INSIDE the plugin. Now I am migrating it to iOS as effectively and I do not wish to copy all this code in iOS folder. It must be a typical place like /cpp alongside /android and /ios.

How can I acheive this? What adjustments ought to I make in Xcode or iOS Podspec contained in the plugin in order that the iOS surroundings additionally has entry to those recordsdata together with Android?

Comply with up – This C++ code is utilizing third occasion libraries as effectively like enhance, how can I add that as a dependency contained in the plugin as effectively?

Word- There isn’t any involvement of Obj-C right here. The Flutter entry level of the plugin immediately calls C++ capabilities which in flip might use Increase header recordsdata.

Placing all of the cpp code inside iOS/Lessons did not assist.
I modified ios/FPlugin.podspec seems to be like this –

Pod::Spec.new do |s|
  s.identify="uac"
  s.model          = '0.0.1'
  s.abstract          = 'A brand new flutter plugin undertaking.'
  s.description      = <<-DESC
A brand new flutter plugin undertaking.
                       DESC
  s.homepage="http://instance.com"
  s.license          = { :file => '../LICENSE' }
  s.creator           = { 'Your Firm' => '[email protected]' }
  s.supply           = { :path => '.' }
  s.source_files="Lessons/**/*.{h,m,mm,cpp,hpp}", 'Lessons/cots/**/*.{h,cpp,hpp}'
  s.dependency 'Flutter'
  s.platform = :ios, '8.0'

  # Flutter.framework doesn't include a i386 slice.
  s.pod_target_xcconfig = { 
    'CLANG_CXX_LIBRARY' => 'libc++',
    'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
    'DEFINES_MODULE' => 'YES', 
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' 
  }
  s.swift_version = '5.0'
finish```

The cots folder the place my enhance library is. I used to be making an attempt to incorporate that as effectively however failed. It saved giving me pod set up fails or 'A number of Instructions Produce' Errors

LEAVE A REPLY

Please enter your comment!
Please enter your name here