Flutter lexactivator library build error due to invalid podspec

I’m using the lexactivator Dart library in a Flutter app, and I’m getting an error due to the format of the lexactivator.podspec file.

As written, the podspec is:

Pod::Spec.new do |s|
  s.name             = 'lexactivator'
  s.version          = '3.0.0'
  s.summary          = 'LexActivator API wrapper for Dart (licensing library)'
  s.description      = <<-DESC
  LexActivator API wrapper for Dart (licensing library)
  s.homepage         = 'https://cryptlex.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Cryptlex' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files     = 'Classes/**/*'
  s.dependency 'FlutterMacOS'
  s.library '../'

  s.platform = :osx, '10.11'
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
  s.swift_version = '5.0'

The error is:
Failed to load ‘lexactivator’ podspec:
[!] Invalid lexactivator.podspec file: undefined method `library’ for #<Pod::Specification name=“lexactivator”>

I’ve tried changing:
s.library ‘…/’
to this:
s.library = ‘…/’

…and get a different error:
ld: library not found for -l…/
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m not sure what the appropriate value is for library, but as it comes from pub.dev, it appears to be invalid. I also tried removing that line altogether as well but get errors that way too.

This is a Flutter 3.3.1 app with Dart 2.18.0 on MacOS. Any help is appreciated.

Hello @newmicro

The lexactivator package on pub.dev is an initial version that we shipped for Windows and Linux, which is why it does not contain the library that the project requires for macOS. Currently, you can add the required library for macOS by following these steps:

  1. Download the latest LexActivator library (non-static) for macOS from Dashboard->Downloads. Alternatively, you can use this link.
  2. Extract the zip file and within the extracted folder, the library you require is a file named libLexActivator.dylib which will be found in EXTRACTED_FOLDER/libs/clang/universal.
  3. In your Flutter project, Open the yourapp/macos/Runner.xcworkspace in Xcode.
  4. Drag (libLexActivator.dylib) into Runner/Frameworks.
  5. Click Runner and go to the Build Phases tab.
    1. Drag libLexActivator.dylib into the Copy Bundle Resources list.
    2. Under Embed Libraries (if available), check Code Sign on Copy.
    3. Under Link Binary With Libraries, set status to Optional.
  6. Click Runner and go to the General tab.
    1. Drag libLexActivator.dylib into the Frameworks, Libraries and Embedded Content list.
    2. Select Embed & Sign.

This should be enough for you to get started with using the lexactivator package on macOS.

I assure you that future versions of the lexactivator package will not require this cumbersome process and we shall add support for macOS in the near future.

Let me know if this answers your questions


1 Like

Ok, thank you. I’ve done this in XCode. Do I just need to point that library in the podspec to this dylib to use the LexActivator Dart library?

After adding the library to your project by following the steps above, you can use the lexactivator package as per the tutorial in the readme.

You do not need to install the package locally using the path: method of importing in the pubspec. Furthermore, you will not need to make any changes to the podspec in the lexactivator package.

Let me know if this answers your questions

Maybe I’m missing something. I followed the steps in XCode; however, the lexactivator.podspec file in the Dart library is still invalid. I get the same error when running the Flutter app:

-> Fetching podspec for `lexactivator` from `Flutter/ephemeral/.symlinks/plugins/lexactivator/macos`
[!] Failed to load 'lexactivator' podspec:
[!] Invalid `lexactivator.podspec` file: undefined method `library' for #<Pod::Specification name="lexactivator">
Did you mean?  library=.
#  from /Users/blakemiller/myapp/macos/Flutter/ephemeral/.symlinks/plugins/lexactivator/macos/lexactivator.podspec:18
#  -------------------------------------------
#    s.dependency 'FlutterMacOS'
#    s.library '../'
#  -------------------------------------------

Should I expect that adding the library in XCode will address the invalid podspec?

My apologies. I checked the package published on pub.dev again and found the podspec to be invalid.

For now, after following the XCode steps, you can:

  1. Download the package manually
  2. Extract it into a folder in your project
  3. Import it into your project using the path method in your pubspec.yaml
  4. Within the lexactivator project directory, within the macos directory, open the lexactivator.podspec in your text editor
  5. Comment out the line that starts with s.library
  6. Continue to build your application

I apologize again for this and assure you that we will improve the lexactivator library by a large margin. I appreciate your patience.

Let me know if this answers your questions


1 Like

Sorry for the delay in getting back to you. I’ve got this working, I think, using your instructions. Thank you for the help.