Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supported platforms, base SDK, build active architecture only settings reverted after pod update

My team recently started to employ CocoaPods to manage dependency in our iOS app project.

Here's the podfile:

platform :ios, '6.0'

pod "UI7Kit"
pod "AFNetworking", "~> 2.0"
pod "TMCache"
pod "SVProgressHUD"
pod "SVPullToRefresh"

However, after using CocoaPods, building targets for iPhone 5 always fails, but succeeds for simulator.

Here's the error log:

ld: warning: ignoring file [DerivedData directory]/libPods.a, file was built for archive which is not the architecture being linked (armv7): [DerivedData directory]/libPods.a
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_SVProgressHUD", referenced from:
      objc-class-ref in ....o
  "_OBJC_CLASS_$_TMCache", referenced from:
      objc-class-ref in ....o
  "_OBJC_CLASS_$_UI7Kit", referenced from:
      objc-class-ref in ....o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried solutions mentioned in CocoaPods Troubleshooting, including adding the Pods static library on top of the list, but it still fails.

Later we found that in "Pods Project Settings" > "Build Settings" > "Architectures", "Base SDK" is set as "No SDK (Latest OS X)", "Build Active Architecture Only" > "Debug" set as "Yes" and "Supported Platforms" set as "OS X". After changing them to "Latest iOS (iOS 7.0)", "No", "iOS" respectively, building for iPhone 5 and simulator both work fine.

However, each time we do Pod update, all of the three settings are reverted to their previous states, which is annoying.

My questions are:

  1. Is this case by design or something is wrong with my project/workspace setting?
  2. How to prevent these settings from being reverted to the wrong states?

Any help will be appreciated.

like image 727
LazarusX Avatar asked Dec 09 '13 06:12

LazarusX


2 Answers

As mentioned in CocoaPods issues, you can append this to your Podfile:

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        end
    end
end

This will make all pods build for all arch.

like image 193
samwize Avatar answered Oct 19 '22 23:10

samwize


I used to follow that procedure... now with cocoapods and more hours into the matter I opted for :

# fixes required for xcode project
post_install do |installer_representation|

puts ""
puts "Updating VALID_ARCHS, SUPPORTED_PLATFORMS, SDKROOT for the project..."

installer_representation.pods_project.build_configurations.each do |config|

#    config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'

    config.build_settings['VALID_ARCHS'] = 'arm64 armv7 armv7s'

    config.build_settings['SUPPORTED_PLATFORMS'] = 'iphonesimulator iphoneos'

#   setting the base SDK of the project to match that of the project,
#   otherwise it defaults to No SDK (Latest OS X)"
    config.build_settings['SDKROOT'] = 'iphoneos'

# it sets 'Valid Architectures' to '$(ARCHS_STANDARD)' to all pods
#        config.build_settings['SDKROOT'] = projectSDK
end



puts ""
puts "Updating all of the watch POD targets with specific..."

installer_representation.pods_project.targets.each do |target|
    target.build_configurations.each do |config|

        if (config.build_settings['SDKROOT'] == 'watchos')
            puts "fixing SUPPORTED_PLATFORMS & VALID_ARCHS for #{target.name} #{config.name}"
            config.build_settings['SUPPORTED_PLATFORMS'] = 'watchsimulator watchos'
            config.build_settings['VALID_ARCHS'] = 'arm64 armv7 armv7s armv7k i386'
        end

#    to not default to ONLY_ACTIVE_ARCH for debug"
#            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
#            config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
    end
end

puts ""

end
like image 42
altagir Avatar answered Oct 19 '22 23:10

altagir