Ich bin jetzt ein paar Tage lang herumgereist und habe versucht herauszufinden, warum mein post_install-Hook nicht die Ausgabe produziert, die ich erwarte. Hier ist mein Podfile:Warum aktualisiert mein post-install-Hook von cocoapods nicht meine Preprozessor-Makros?
source 'https://github.com/CocoaPods/Specs.git'
target "SCCommon" do
platform :ios, "6.0"
pod 'AFNetworking', '~> 1.2.1'
pod 'Mantle', '~> 1.3'
pod 'PubNub', '3.5.5'
end
target "SCCommon-TestHarness" do
platform :ios, "6.0"
# inhibit_all_warnings!
pod 'SCCommon', :path => '../SCCommon.podspec'
end
target "SCCommon-UnitTests" do
platform :ios, "6.0"
# inhibit_all_warnings!
pod 'OCMock', '2.2.3'
pod 'SCCommon', :path => '../SCCommon.podspec'
end
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
if target.name == 'Pods-SCCommon-UnitTests'
puts "Setting preprocessor macro for #{target.name}..."
target.build_configurations.each do |config|
puts "#{config} configuration..."
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','SC_DEBUG_SCCOMMON=1','FOOBAR']
puts config.build_settings['GCC_PREPROCESSOR_DEFINITIONS']
puts '---'
end
end
end
end
Nach pod update
auf dem oben ausgeführt wird, erhalte ich die folgende Ausgabe:
Update all pods
Analyzing dependencies
CocoaPods 0.35.0 is available.
To update use: `sudo gem install cocoapods`
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Fetching podspec for `SCCommon` from `../SCCommon.podspec`
Downloading dependencies
Using AFNetworking (1.2.1)
Using Mantle (1.5.1)
Using OCMock (2.2.3)
Using PubNub (3.5.5)
Using SCCommon (0.3)
Generating Pods project
Setting preprocessor macro for Pods-SCCommon-UnitTests...
Release configuration...
$(inherited)
SC_DEBUG_SCCOMMON=1
FOOBAR
---
Debug configuration...
DEBUG=1
$(inherited)
---
Integrating client project
Die Frage, die ich habe, ist: Warum die neuen Makrodefinitionen nicht die Debug-Konfiguration Aktualisierung ist ? Sie können in der Ausgabe sehen, dass die Release-Konfiguration korrekt eingerichtet ist, aber nicht Debug.
Irgendwelche Ideen?
Sie brauchen nicht die zweite Zeile config.build_settings ['GCC_PREPROCESSOR_DEFINITIONS'] << 'SC_DEBUG_SCCOMMON' Dies würde nur den Text ohne Wert hinzufügen, zumindest habe ich es jetzt beim Testen bekommen. Für diejenigen, die das gleiche Problem haben, prüfe vorher, ob der Zielname korrekt ist. – David