Xcode 프로젝트의 podfile에서 여러 대상을 어떻게 지정합니까?
Xcode 4 프로젝트에서 CocoaPods를 사용하고 있으며 프로젝트에 대한 세 가지 대상 (기본값, 라이트 버전 빌드 및 데모 버전 빌드)이 있습니다. 모든 대상은 동일한 라이브러리를 사용하지만 CocoaPods는 기본 대상에 정적 라이브러리 및 검색 경로 만 추가합니다. 내 podfile은 다음과 같습니다.
platform :ios, '5.0'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
내가이 작업을 수행 할 수있는 유일한 방법은 모든 포드를 다시 나열하여 각 대상을 개별적으로 지정하는 것이 었습니다.
platform :ios, '5.0'
target :default do
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
target :lite do
link_with 'app-lite'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
target :demo do
link_with 'app-demo'
pod 'TestFlightSDK', '>= 1.1'
pod 'MBProgressHUD', '0.5'
pod 'iRate', '>= 1.6.2'
pod 'TimesSquare', '1.0.1'
pod 'AFNetworking', '1.1.0'
pod 'KKPasscodeLock', '0.1.5'
pod 'iCarousel', '1.7.4'
end
더 좋은 방법이 있습니까?
CocoaPods 1.0이 이에 대한 구문을 변경했습니다. 이제 다음과 같이 보입니다 :
def shared_pods
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
end
target 'Sail' do
shared_pods
end
target 'Sail-iOS' do
shared_pods
end
구식 Pre CocoaPods 1.0 답변 :
더 좋은 방법이 있습니다! 여러 대상을 지정할 link_with
수있는 위치를 확인하십시오 link_with 'MyApp', 'MyOtherApp'
.
I use this with unit tests like link_with 'App', 'App-Tests'
(beware of spaces in target's names).
Example:
platform :osx, '10.8'
link_with 'Sail', 'Sail-Tests'
pod 'SSKeychain', '~> 0.1.4'
pod 'INAppStoreWindow', :head
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
pod 'KSADNTwitterFormatter', '~> 0.1.0'
pod 'MASShortcut', '~> 1.1'
pod 'MagicalRecord', '2.1'
pod 'MASPreferences', '~> 1.0'
2017 update
You can use abstract_target
# Note: There are no targets called "Shows" in any of this workspace's Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
# The target ShowsiOS has its own copy of ShowsKit (inherited) + ShowWebAuth (added here)
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# The target ShowsTV has its own copy of ShowsKit (inherited) + ShowTVAuth (added here)
target 'ShowsTV' do
pod 'ShowTVAuth'
end
# Our tests target has its own copy of
# our testing frameworks, and has access
# to ShowsKit as well because it is
# a child of the abstract target 'Shows'
target 'ShowsTests' do
inherit! :search_paths
pod 'Specta'
pod 'Expecta'
end
end
I think better solution is
# Podfile
platform :ios, '8.0'
use_frameworks!
# Available pods
def available_pods
pod 'AFNetworking', '1.1.0'
pod 'Reachability', '~> 3.1.0'
end
target 'demo' do
available_pods
end
target 'demoTests' do
available_pods
end
Reference from : http://natashatherobot.com/cocoapods-installing-same-pod-multiple-targets/
If you want multiple targets to share the same pods, use an abstract_target.
# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
end
or just
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
source: https://guides.cocoapods.org/using/the-podfile.html
Easiest way is to use an abstract target, where each pod specified will be linked with all targets.
abstract_target 'someNameForAbstractTarget' do
pod 'podThatIsForAllTargets'
end
target 'realTarget' do
pod 'podThatIsOnlyForThisTarget'
end
'IT story' 카테고리의 다른 글
React Native에서 전체 화면 배경 이미지를 추가하는 가장 좋은 방법은 무엇입니까 (0) | 2020.06.26 |
---|---|
ASP.net Core WebAPI에서 CORS를 활성화하는 방법 (0) | 2020.06.26 |
인앱 결제 예제에서 Android Studio에 보조 파일을 추가하는 방법 (0) | 2020.06.26 |
Ruby on Rails : f.text_field에 자리 표시 자 텍스트를 어떻게 추가합니까? (0) | 2020.06.25 |
노드에서 엄격 모드를 강제하는 방법은 무엇입니까? (0) | 2020.06.25 |