2013-12-09 20 views
5

我的團隊最近開始使用的CocoaPods來管理我們的iOS應用項目依賴後恢復設置。支持的平臺,基地SDK,構建有源體系僅莢更新

這裏的podfile:

platform :ios, '6.0' 

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

但是,使用的CocoaPods後,對於iPhone 5的建設目標總是失敗,但成功的模擬器。

這裏的錯誤日誌:

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) 

我試過在CocoaPods Troubleshooting提到的解決方案,包括加入Pods靜態庫在列表的頂部,但它仍然失敗。我們發現在「Pods Project Settings」>「Build Settings」>「Architectures」,「Base SDK」中設置爲「No SDK(Latest OS X)」,「Build Active Architecture Only」>「Debug 「設置爲」是「和」支持的平臺「設置爲」OS X「。將它們分別更改爲「最新iOS(iOS 7.0)」,「否」,「iOS」後,iPhone 5和模擬器的構建都可以正常工作。

但是,每次我們做Pod update時間,所有的三個設置都恢復到先前的狀態,這是煩人。

我的問題是:

  1. 是這種情況下,通過設計或東西是錯誤與我的項目/工作區設置?
  2. 如何防止這些設置被還原爲錯誤的狀態?

任何幫助將不勝感激。

回答

0

The Pods Project設置無關緊要,重要的是Pod靜態庫的目標設置。但你不應該碰它們。

您可以發佈從項目/目標的構建設置? 故障排除指南建議some build settings in case of failed build,它們有幫助嗎?請務必啓用以顯示所有構建設置,並檢查一些設置是否覆蓋CocoaPods生成的xcconfig文件中指定的設置。

此外,請檢查您的項目是否基於項目「信息」選項卡中的xcconfig文件。 enter image description here

我希望這個事情有所幫助。

+0

奇怪的是,即使目標設置是正確的,Pods Project設置似乎也很重要。只有在手動更新Pods項目設置以確保它們具有基本SDK集後,才能在大多數情況下修復它。每次進行「pod更新」時,我都無法找出爲什麼Pods PROJECT設置恢復爲沒有基礎SDK。 –

3

正如CocoaPods issues提到的,你可以附加給你的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 

這將使所有吊艙建立所有牌坊。

1

我發現自己遇到了這種情況,以及使用的CocoaPods 0.36.3和Xcode的6.2。我非常懷疑這是最好的解決方案,但是我在Podfile的底部編寫了一個鉤子,用於重置Pods項目中的「BaseSDK」,「Platform」和「Build Active Architecture Only」設置。對於每個目標,我還將「僅限構建活動架構」設置爲「否」,以便採取較好措施(如上述帖子中所述)。

post_install do |installer_representation| 
    projectSDK = nil 

    puts"Updating all of the POD targets to not default to ONLY_ACTIVE_ARCH for debug" 
    installer_representation.project.targets.each do |target| 
     target.build_configurations.each do |config| 
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' 
      if projectSDK.nil? 
       projectSDK = config.build_settings['SDKROOT'] 
      end 
     end 
    end 
    puts "Updating ONLY_ACTIVE_ARCH for the project, as well. While the project settings aren't supposed to matter, I've not found that to be the case." 
    puts "Also setting the base SDK of the project to match that of the targets (doesn't matter which one); otherwise it defaults to No SDK (Latest OS X)" 
    installer_representation.project.build_configurations.each do |config| 
     config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' 
     config.build_settings['SDKROOT'] = projectSDK 
    end 
end 
0

對於任何使用最新的可可豆莢

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

1

我曾經遵循的程序......現在的CocoaPods多小時後,我選擇了此事:

# 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