natjs / nat

A powerful kit for adding native functionalities to your weex app.
http://natjs.com
284 stars 25 forks source link

Does not work when importing as framework (use_frameworks!) #46

Open tralves opened 6 years ago

tralves commented 6 years ago

Hi!

I want to use natjs libs but importing them as a framework (i.e. adding use_framewoks! in my Podfile). I need this because I am also using a swift library and it is not possible to import a swift static lib and use it in ObjC(*).

I am testing with the device info plugin. To reproduce the issue, just add natjs and nat-device-info to a new project, and add use_framewoks! in platforms/ios/Podfile. The project compiles, but then I get the runtime js error TypeError: undefined is not a function (near '...device.info...'. Without use_framewoks!, it works.

Is there a way to make natjs work with use_framewoks!?

Thanks!

(*)- Actually, I found this workaround but seems too much work or most likely it will not work.

acathur commented 6 years ago

It seems that you didn't install nat plugin correctly, Can you provide your Podfile content? @tralves

tralves commented 6 years ago

Hi!

I did install the plugin correctly and it does work when I don't add use_frameworks!, like so:

source 'git@github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
#inhibit_all_warnings!

def common
    pod 'WeexNatDeviceInfo', '1.0.0'
    pod 'WeexSDK', '0.17.0'
...

the problem is that I need to add need use_frameworks!, like this:

source 'git@github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
#inhibit_all_warnings!

def common
    pod 'WeexNatDeviceInfo', '1.0.0'
    pod 'WeexSDK', '0.17.0'
    pod 'WeexPluginLoader'
    pod 'SDWebImage', '3.7.5'
    pod 'SocketRocket', '0.4.2'
end

target 'WeexDemo' do
    common
end

target 'WeexUITestDemo' do
    common
end

pre_install do |installer|
    def installer.verify_no_static_framework_transitive_dependencies; end
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

because my project also depends on a swift lib.

acathur commented 6 years ago

Ok, I got it. But I think this is a issue cause by weex plugin loader, to solve this problem, maybe you can try to set the library targets manually in Xcode.

tralves commented 6 years ago

@Acathur you mean like add them without cocoapods? which library?

Zss1990 commented 4 years ago

Ok, I got it. But I think this is a issue cause by weex plugin loader, to solve this problem, maybe you can try to set the library targets manually in Xcode.

I got same problem, You can consider not using WeexPluginLoader,or support !use_framework