Skip to content

Commit

Permalink
Make Themis a static framework (cossacklabs#731)
Browse files Browse the repository at this point in the history
* Clean up whitespace

First of all, to get this thing out of sight, remove all trailing
whitespace that got recently added to the file.

* Make Themis a static framework

Tell CocoaPods to build ObjCThemis as a 'static framework'. That is,
your usual framework bundle but with a static library inside, not a
dynamic one as you would have normally use.

Using static linkage greatly simplifies our life on iOS platforms which
tend to be very picky about dynamic linkage and loading of frameworks.
These issues are not really visible until you archive the app for
distribution, actually install it on the device, and try launching it.
Debugging these issues takes enormous amount amount of time which we
don't have. Let Apple engineers fiddle with dynamic linkage for system
frameworks. That at least makes sense.

Using static linkage for Themis has advantages, such as improved startup
time (no extra symbol resolution) and improved app size (unused parts of
Themis and its dependencies could be cut out by the linker). As Themis
is distributed under a permissive license, there are no legal downsides
of including it as an integral part of an application, it does not have
to be a completely separate binary.

On the other hand, there are not many advantages of dynamic linkage.
We don't get to share the memory and storage as Themis is not a system
framework. The only real advantage is that it's easier to verify that
Themis binaries have not been tampered with and to check Themis version,
but iOS deployment process is know to heavily process the binaries,
making this point mostly moot.

(cherry picked from commit 3f858f4)

Signed-off-by: Alexei Lozovsky <[email protected]>
  • Loading branch information
ilammy committed Oct 28, 2020
1 parent 7472f22 commit 367c979
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

Changes that are currently in development and have not been released yet.

_Code:_

- **Objective-C**

- CocoaPods will now link ObjCThemis statically into application ([#731](https://github.com/cossacklabs/themis/pull/731)).

- **Swift**

- CocoaPods will now link SwiftThemis statically into application ([#731](https://github.com/cossacklabs/themis/pull/731)).


## [0.13.3](https://github.com/cossacklabs/themis/releases/tag/0.13.3), October 12th 2020

Expand Down
18 changes: 11 additions & 7 deletions themis.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pod::Spec.new do |s|
s.license = { :type => 'Apache 2.0'}

s.source = { :git => "https://github.com/cossacklabs/themis.git", :tag => "#{s.version}" }

s.author = {'cossacklabs' => '[email protected]'}

s.module_name = 'themis'
Expand All @@ -17,6 +17,10 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.11'
s.ios.frameworks = 'UIKit', 'Foundation'

# Tell CocoaPods that the frameworks we publish are "static frameworks".
# This ensures correct resolution of transitive dependencies.
s.static_framework = true

# TODO(ilammy, 2020-03-02): resolve "pod spec lint" warnings due to dependencies
# If you update dependencies, please check whether we can remove "--allow-warnings"
# from podspec validation in .github/workflows/test-objc.yaml
Expand Down Expand Up @@ -80,22 +84,22 @@ Pod::Spec.new do |s|

# use `themis/themis-openssl` as separate target to use Themis with OpenSSL
s.subspec 'themis-openssl' do |so|
# Enable bitcode for OpenSSL in a very specific way, but it works, thanks to @deszip
# Enable bitcode for OpenSSL in a very specific way, but it works, thanks to @deszip
#so.ios.pod_target_xcconfig = {'ENABLE_BITCODE' => 'YES' }
so.ios.pod_target_xcconfig = {
'OTHER_CFLAGS[config=Debug]' => '$(inherited) -fembed-bitcode-marker',
'OTHER_CFLAGS[config=Release]' => '$(inherited) -fembed-bitcode',
'BITCODE_GENERATION_MODE[config=Release]' => 'bitcode',
'BITCODE_GENERATION_MODE[config=Debug]' => 'bitcode-marker'
}

# Xcode12, arm64 simulator issues https://stackoverflow.com/a/63955114
# disable building for arm64 simulator for now

so.ios.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
so.ios.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }


# TODO: due to error in symbols in GRKOpenSSLFramework 219 release, we've manually switched to 218
# which doesn't sound like a good decision, so when GRKOpenSSLFramework will be updated –
# please bring back correct dependency version
Expand Down Expand Up @@ -165,4 +169,4 @@ Pod::Spec.new do |s|
ss.dependency 'themis/themis-boringssl/core'
end
end
end
end

0 comments on commit 367c979

Please sign in to comment.