use_frameworks! for only some pods or swift pods

You can overwrite use_frameworks! and install all pods as static except for the ones you choose to be a framework

In the Podfile use use_frameworks! And at the end of the file add

dynamic_frameworks = ['aaa','bbb'] # <- swift libraries names

# Make all the other frameworks into static frameworks by overriding the static_framework? function to return true
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

Based on a member of CocoaPods:

This won't be possible for the general case, because of transitive dependencies. If Pod A is build dynamically and depends on Pod B that is build statically and the app also depends on Pod B, it is for example impossible to build, because either Pod A will be missing the symbols of Pod B at link time, or you end up with multiple copies of Pod B. There are probably more scenarios which won't work.

However, you should be able to create a plugin to support specific cases like yours.


When JSBridge init, it will add some "UserScripts" to webview, which source is loaded from [NSBundle mainBundle] in previous version. But if it's in a framework, the resource files is in the framework bundle instead of mainBundle.

So the fix is in WBWebViewConsoleDefines

replace this

inline static NSBundle * WBWebBrowserConsoleBundle()
{
return [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] bundlePath], @"WBWebBrowserConsole.bundle"]];
}

with

inline static NSBundle * WBWebBrowserConsoleBundle()
{
return [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@", [NSBundle bundleForClass:[WBWebViewConsole class]], @"WBWebBrowserConsole.bundle"]]; 
}

Actually the author has released new version it also has the fix

pod 'WBWebViewConsole', '~> 1.0.2’

  1. pod install
  2. restart Xcode and clean your project
  3. build and run again

Note: Its not possible. if you use_frameworks! everything become dynamic framework.


                    source 'https://github.com/CocoaPods/Specs.git'
                    platform :ios, '8.0'
                    use_frameworks!
                    pod 'WBWebViewConsole', '~> 1.0.1' 
                    pod 'XWebView', '~>0.9.5’ 
                    pod 'Starscream', '~> 1.1.3'

there is no need for specifying objective c pod above use_framework!.