Skip to content

Instantly share code, notes, and snippets.

@evands
Created January 14, 2015 20:40
Show Gist options
  • Star 43 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save evands/8ba4f227b00ae14a9303 to your computer and use it in GitHub Desktop.
Save evands/8ba4f227b00ae14a9303 to your computer and use it in GitHub Desktop.
Combine multiple .a static libraries, which may each have multiple architectures, into a single static library
#!/bin/sh
# Combined all static libaries in the current directory into a single static library
# It is hardcoded to use the i386, armv7, and armv7s architectures; this can easily be changed via the 'archs' variable at the top
# The script takes a single argument, which is the name of the final, combined library to be created.
#
# For example:
# => combine_static_libraries.sh combined-library
#
# Script by Evan Schoenberg, Regular Rate and Rhythm Software
# Thanks to Claudiu Ursache for his blog post at http://www.cvursache.com/2013/10/06/Combining-Multi-Arch-Binaries/ which detailed the technique automated by this script
#####
# $1 = Name of output archive
#####
archs=(i386 armv7 armv7s)
libraries=(*.a)
libtool="/usr/bin/libtool"
echo "Combining ${libraries[*]}..."
for library in ${libraries[*]}
do
lipo -info $library
# Extract individual architectures for this library
for arch in ${archs[*]}
do
lipo -extract $arch $library -o ${library}_${arch}.a
done
done
# Combine results of the same architecture into a library for that architecture
source_combined=""
for arch in ${archs[*]}
do
source_libraries=""
for library in ${libraries[*]}
do
source_libraries="${source_libraries} ${library}_${arch}.a"
done
$libtool -static ${source_libraries} -o "${1}_${arch}.a"
source_combined="${source_combined} ${1}_${arch}.a"
# Delete intermediate files
rm ${source_libraries}
done
# Merge the combined library for each architecture into a single fat binary
lipo -create $source_combined -o $1.a
# Delete intermediate files
rm ${source_combined}
# Show info on the output library as confirmation
echo "Combination complete."
lipo -info $1.a
Copy link

ghost commented Apr 20, 2019

So i found this, J strongly believe there’s something that could help everyone

Copy link

ghost commented Apr 20, 2019

Version Compatibility

This book describes Swift 5, the default version of Swift that’s included in Xcode 10.2. You can use Xcode 10.2 to build targets that are written in either Swift 5, Swift 4.2, or Swift 4.

When you use Xcode 10.2 to build Swift 4 and Swift 4.2 code, most Swift 5 functionality is available. That said, the following changes are available only to Swift 5 code:

The try? expression doesn’t introduce an extra level of optionality to expressions that already return optionals.
Large integer literal initialization expressions are inferred to be of the correct integer type. For example, UInt64(0xffff_ffff_ffff_ffff) evaluates to the correct value rather than overflowing.
A target written in Swift 5 can depend on a target that’s written in Swift 4.2 or Swift 4, and vice versa. This means, if you have a large project that’s divided into multiple frameworks, you can migrate your code from Swift 4 to Swift 5 one framework at a time.

@DmitryPR
Copy link

DmitryPR commented May 7, 2019

Can this be used to combine static frameworks in a single framework?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment