Code Monkey home page Code Monkey logo

cocoapods-static-swift-framework's Introduction

cocoapods-static-swift-framework

A cocoapods plugin that enables static frameworks for all pods.

Cocoapods only supports static framework at pod level, which means an option in podspec and just valid for that pod. By using this plugin, we can make all pod to static framework with only one word!

(There's 'swift' in the plugin name as it's originally built for swift. You can also use it for pure objc project too.)

Usage

Install via gem:

$ gem install cocoapods-static-swift-framework

Add the following to your podfile:

plugin 'cocoapods-static-swift-framework'

NOTE: Static frameworks is still using framework, not static library. So don't forget to add use_frameworks!

NOTE: From cocoapods 1.7, the generated resource bundle specified with s.resource_bundle in podspec, will not be copied to the .framework folder. It's a default behavior of cocoapods.

About Static framework

Why

Too many dynamic frameworks will increase app boot time dramatically, also the Copy framework build phase will expend unendurable time in the code-build-run loop. (There is also a dyld crash) Static framework have no these problems.

What is a static framework

First of all, what is a framework? Framework is just a bundle with specifications to organize files, for whom xcode provides convenient methods to link bianry and copy resources.

Static framework, or precisely static-linking framework, has no official defination. There's only (dynamic) framework. "When linking, it found that the binary in the framework is static-linking, then it will link the binary staticaly. There's no special handling." an Apple engineer answered me at WWDC.

Resources in static framework can't be copied to app's main bundle automatically. If you use cocoapods, it will handle it automatically, but not for the manual integration.

The binary in the framework will be linked statically, as its name, to the main binary. There's no framework file in the Framework folder of the app bundle. Resources will copied to app bundle's root path. So there's a potential bug of conflict of resource file names.

requirement

  • Xcode 9+
  • cocoapods 1.5+ (v1.7 tested)

License

MIT

Appreciate a 🌟 if you like it. Another cocoapods plugin made by me to improve pod compile time: cocoapods-binary

cocoapods-static-swift-framework's People

Contributors

dependabot[bot] avatar leavez avatar noremac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cocoapods-static-swift-framework's Issues

Does it support cocoapods v1.9.3?

no work

this is my podfile

plugin 'cocoapods-static-swift-framework'

use_frameworks!
all_binary!

platform :ios, '10.0'

target 'CocoapodsBinaryKit_Example' do
pod 'CocoapodsBinaryKit', :path => '../'

pod 'IQKeyboardManagerSwift', :binary => true
pod 'Alamofire' , :binary => true

end

Feature Request: Per Pod override of static linking

I have a fairly large project with a number of pods. I have attempted to use this plugin, but ran in to duplicate symbols during linking. This is because multiple pods have included some common open source code directly in to the framework.

duplicate symbol '_OBJC_IVAR_$_GPBInt64Array._count' in:
    /Users/benski/******/Pods/Adswizz/libs/AdswizzSDK.framework/AdswizzSDK(GPBArray.o)
    /Users/benski/Library/Developer/Xcode/DerivedData/iPhone-fwdbrlygvnjovgeelnqgbhzfulll/Build/Products/Debug-iphonesimulator/Protobuf/Protobuf.framework/Protobuf(GPBArray.o)

Is it possible to override static linking for a particular pod?
e.g. , :static => false
This would be similar to how your binary plugin works.

Adding `excludes` option is preferable

This is a great plugin, but I had some issues.

  1. pod install causes "transitive dependencies that include static frameworks"
  2. Framework WorldpayCSE includes openssl that conflicts with my app's binary which makes duplicate symbols error. In dynamic framework, it would not be a problem.

[Catalyst support][feature request] makes it possible to pre-build libraries for multiple platforms

Thanks for developing such tool, it helps us until we try to support Mac OS through Catalyst.

Our app's Xcode project contains severals targets whose one which is supporting Catalyst, iPhone and iPad. Most of our pods are common to these targets. It will be wonderful to be able to pre-build the common set of pods for the different supported platform. When building for severals platform, we can imagine packaging the dependency as an XCFrameworks.

I am wondering if you plan to support such things?

Question: Compilation issues with a lot of Pods

First of all, this is a great plugin and I'm looking forward to using it in all of our projects. Thank you for this!

Unfortunately I'm facing a lot of issues with existing Pods. I'm not exactly sure how did it work before, but there were some frameworks that didn't need import X in the source files of Pods (mainly UIKit and Foundation).

So now there are many Pods that don't compile with this plugin active, because they lack those imports in their source files.

My question is, can we workaround it somehow?

Thanks!

Using the plugin to create a framework

Hi, sorry for opening an issue, but this was the only way I could find to get in touch

I'm trying to develop a framework, written in swift, that will be distributed as binary, and that depends on other frameworks. The goal is to combine all of them into one unit. Tried loads of methods out there. Your plugin was my last stop. The framework is built ok. But when trying to use it in app projects, I get a compile error around modules. Namely that it can't find the dependencies module, even though expectation was for it to be incorporated as a black box.

Have you any experience in building such frameworks?
Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.