Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use the Pod without use_frameworks!? #237

Open
ph4r05 opened this issue Jan 6, 2021 · 2 comments
Open

Is it possible to use the Pod without use_frameworks!? #237

ph4r05 opened this issue Jan 6, 2021 · 2 comments

Comments

@ph4r05
Copy link

ph4r05 commented Jan 6, 2021

I have a Cocoapod project that for some reason does not use use_frameworks! directive (legacy, react-native had issues with the frameworks).

Compilation fails with linking errors for Sodium 0.9.1.

Undefined symbols for architecture arm64:
"_sodium_unpad", referenced from:
    Sodium.Utils.unpad(bytes: inout [Swift.UInt8], blockSize: Swift.Int) -> ()? in libSodium.a(Utils.o)
    Sodium.Utils.unpad(bytes: inout [Swift.UInt8], blockSize: Swift.Int) -> ()? in libsodium.a(Utils.o)
"_sodium_base64_encoded_len", referenced from:
    Sodium.Utils.bin2base64(_: [Swift.UInt8], variant: Sodium.Utils.Base64Variant) -> Swift.String? in libSodium.a(Utils.o)
    Sodium.Utils.bin2base64(_: [Swift.UInt8], variant: Sodium.Utils.Base64Variant) -> Swift.String? in 

I was wondering whether it is possible to use this Sodium pod without using use_frameworks! or using the framework is a fundamental requirement for the Sodium pod.

It is easy to reproduce with pod spec lint on this repository:

The following Lint passes:

pod spec lint --no-clean --verbose --use-modular-headers --private  

The following does not. The error is the same as when I am using Sodium in my project.

pod spec lint --no-clean --verbose --use-modular-headers --private --use-libraries 

I've created a simple demo project depending on Sodium 0.9.1: https://github.com/ph4r05/SodiumPoc

When use_frameworks! is present in https://github.com/ph4r05/SodiumPoc/blob/main/Example/Podfile it builds, otherwise not.

  • It works also with use_frameworks! :linkage => :static
  • use_modular_headers! alone does not work
@ph4r05 ph4r05 changed the title Is it possible to build as a static lib, without use_frameworks!? Is it possible to use the Pod without use_frameworks!? Jan 6, 2021
@flash76
Copy link

flash76 commented Mar 28, 2021

I'm also working on a React Native app and was having problems with use_frameworks!. I was able to solve my issue (at least for now) with cocoapods-user-defined-build-types.

I did this by:

  1. Running sudo gem install cocoapods-user-defined-build-types
  2. Adding
plugin 'cocoapods-user-defined-build-types'`
enable_user_defined_build_types!

right after the second require_relative in the Podfile
3. Adding pod 'Sodium', :build_type => :dynamic_framework under the app target.
4. Running npx pod-install ios in the root project directory

At this point, once I tried building the project, I was getting errors about swiftWebKit not being found, so I added a File.swift to the iOS Xcode Project and created a bridging header when Xcode asked. Cleaning and running after that worked for me.

@ph4r05
Copy link
Author

ph4r05 commented Jun 21, 2022

@flash76 I got back to this problem and your solution works, thanks a lot!

I am working on a react-native application with Flipper, which does not work with use_frameworks! from some reason.

There are also several workarounds, e.g.. having selected libraries marked as static, but it runs into a problems if any of selected Flipper deps are also transitive dependencies of other dependencies and are expected to be built as frameworks.

So thanks for this! Reversed approach having only selected pods built as Frameworks works much better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants