Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# swift-staticlibs

This repo contains scripts for building iOS static frameworks that
contain Swift sources from **within Xcode**
This repo contains a replacement linker script for building iOS static
frameworks that contain Swift sources from **within Xcode**

## Usage

For each dynamic framework target in Xcode that you would like to be
build statically:

1. Set the undocumented `LD` and `LIPO` Xcode build settings to point to
these scripts
1. Set the undocumented `LD` Xcode build setting to point to `ld.py`
2. Add the target to your main target's `Link Binary With Libraries`
build phase.

You can set these settings through a user defined build setting in
Xcode, or with a [`xcconfig`][xcconfigs] file like this:
You can set this setting through a user defined build setting in Xcode,
or with a [`xcconfig`][xcconfigs] file like this:

```
LD = $(PROJECT_DIR)/path/to/ld.py
LIPO = $(PROJECT_DIR)/path/to/lipo.py
```

## CocoaPods

There are a few issues with using these scripts alongside CocoaPods:
There are a few issues with using this script alongside CocoaPods:

- With the below configuration, there is no differentiation between
targets, if for some reason you didn't want to use these scripts for
Expand Down Expand Up @@ -52,7 +50,6 @@ post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LD'] = '$(PROJECT_DIR)/path/to/ld.py'
config.build_settings['LIPO'] = '$(PROJECT_DIR)/path/to/lipo.py'
end
end
end
Expand Down Expand Up @@ -80,12 +77,12 @@ make decisions based on project configuration.

## How?

By replacing the `libtool` and `lipo` invocations from Xcode, these
scripts hijack the passed arguments, and transform them into the
arguments necessary for building static _frameworks_, instead of dynamic
frameworks. Then since the product ends up existing in the same place as
the dynamic framework that would have otherwise been included, Xcode
happily links the static framework instead.
By replacing the `libtool` invocation from Xcode, this script hijacks
the passed arguments, and transforms them into the arguments necessary
for building static _frameworks_, instead of dynamic frameworks. Then
since the product ends up existing in the same place as the dynamic
framework that would have otherwise been included, Xcode happily links
the static framework instead.

Static _frameworks_ are very similar to dynamic frameworks, except the
binary contained within the framework ends up being linked statically,
Expand Down
1 change: 0 additions & 1 deletion integration_tests/PodsDependencies/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ post_install do |installer|
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
config.build_settings['LD'] = '$(PROJECT_DIR)/../../../ld.py'
config.build_settings['LIPO'] = '$(PROJECT_DIR)/../../../lipo.py'
end
end
end
2 changes: 1 addition & 1 deletion integration_tests/PodsDependencies/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Dependency: 22ba715658049a8b0146f25be1144266af8781f6

PODFILE CHECKSUM: 49b0d43e511d4f2a6ee157de8093072f1219c8b3
PODFILE CHECKSUM: a6be16fbd1cb394247d5d74af8ee38bc4fc9fb5f

COCOAPODS: 1.2.0
2 changes: 1 addition & 1 deletion integration_tests/PodsDependencies/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 49 additions & 53 deletions integration_tests/PodsDependencies/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion integration_tests/settings.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CODE_SIGNING_ALLOWED = NO
LD = $(PROJECT_DIR)/../../ld.py
LIPO = $(PROJECT_DIR)/../../lipo.py

ALWAYS_SEARCH_USER_PATHS = NO
DEBUG_INFORMATION_FORMAT = dwarf
Expand Down
26 changes: 0 additions & 26 deletions lipo.py

This file was deleted.

40 changes: 0 additions & 40 deletions tests/test_lipo.py

This file was deleted.