Created
March 26, 2014 06:30
-
-
Save roothybrid7/9777804 to your computer and use it in GitHub Desktop.
CocoaPodsでアプリ側ターゲットのbuild_settingsを変更する方法 ref: http://qiita.com/roothybrid7/items/403b2fb453b1674102a4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef APP_TESTING | |
// テスト以外のときだけ実行する処理 | |
// 広告SDKとかが勝手にブラウザへ飛ばす処理とか | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TESTING_TARGETS = %w[AppTests AppIntegrationTests] | |
post_install do |installer| | |
# アプリ側のxcode projectを開く | |
Xcodeproj::Project.open('App.xcodeproj').tap do |project| | |
targets = project.targets.find_all do |target| | |
TESTING_TARGETS.include?(target.name) | |
end | |
# Test用macro定義 | |
targets.each do |target| | |
target.build_configurations.each do |config| | |
if config.name == "Debug" | |
preprocessor_definitions = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] || ['$(inherited)'] | |
preprocessor_definitions = [preprocessor_definitions] unless preprocessor_definitions.instance_of?(Array) | |
preprocessor_definitions.push('APP_TESTING=1').uniq! | |
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = preprocessor_definitions | |
end | |
end | |
end | |
project.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment