How can you disable bitcode for your project and cocoapod dependencies? Here is the error I get when trying to run my project with Xcode 7.
does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
Edit: Originally only disabled it for one of the targets. Once I disabled all of them and I was able to build successfully.
To set this setting in a way that doesn't get overridden each time you do a pod install
you can add this to your Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
There is a way to build CocoaPods' targets with full bitcode. Just add -fembed-bitcode
option to OTHER_CFLAGS
of each:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)']
cflags << '-fembed-bitcode'
config.build_settings['OTHER_CFLAGS'] = cflags
end
end
end
I think this way is better than disabling bitcode.
project 'frameworkTest.xcodeproj'
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
target 'frameworkTest' do
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for frameworkTest
source 'https://github.com/CocoaPods/Specs.git'
#zip files libs
pod 'SSZipArchive'
#reachability
pod 'Reachability'
end
#bitcode enable
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# set valid architecture
config.build_settings['VALID_ARCHS'] = 'arm64 armv7 armv7s i386 x86_64'
# build active architecture only (Debug build all)
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['ENABLE_BITCODE'] = 'YES'
if config.name == 'Release' || config.name == 'Pro'
config.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
else # Debug
config.build_settings['BITCODE_GENERATION_MODE'] = 'marker'
end
cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)']
if config.name == 'Release' || config.name == 'Pro'
cflags << '-fembed-bitcode'
else # Debug
cflags << '-fembed-bitcode-marker'
end
config.build_settings['OTHER_CFLAGS'] = cflags
end
end
end
Go to the build settings for the target you wish to disable it on. Search for something that says "Enable Bitcode", set it to No.
Disabling Bitcode in Main Project and Pods
The other answers fail to clear out the bitcode flag for the main project. The Post-Install hooks of the Cocoapod do not give you access to the main project, I believe this is design choice, so you need to find the project file and modify it using xcodeproj. If a binary library includes bitcode you will need to use xcrun bitcode_strip
to remove the bitcode to make the project consistent.
Two helper functions
def disable_bitcode_for_target(target)
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
remove_cflags_matching(config.build_settings, ['-fembed-bitcode', '-fembed-bitcode-marker'])
end
end
def remove_cflags_matching(build_settings, cflags)
existing_cflags = build_settings['OTHER_CFLAGS']
removed_cflags = []
if !existing_cflags.nil?
cflags.each do |cflag|
existing_cflags.delete_if { |existing_cflag| existing_cflag == cflag && removed_cflags << cflag }
end
end
if removed_cflags.length > 0
build_settings['OTHER_CFLAGS'] = existing_cflags
end
end
Post_install phase
post_install do |installer|
project_name = Dir.glob("*.xcodeproj").first
project = Xcodeproj::Project.open(project_name)
project.targets.each do |target|
disable_bitcode_for_target(target)
end
project.save
installer.pods_project.targets.each do |target|
disable_bitcode_for_target(target)
end
installer.pods_project.save
end
For disable bitcode for your own development pod only add this below code in pod file of the projects.
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "YOUR SDK TARGET NAME"
puts "Processing for disable bit code in YOUR SDK TARGET NAME SDK"
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end
Update for cocoapods 1.7+ if you have enabled multiple xcodeproj generation:
install! 'cocoapods', :generate_multiple_pod_projects => true
<Pod list section>
post_install do |installer|
installer.pod_target_subprojects.each do |subproject|
subproject.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end
来源:https://stackoverflow.com/questions/32640149/disable-bitcode-for-project-and-cocoapods-dependencies-with-xcode-7