Search code examples
iosrubycocoapods

Installing Pod for More Than One Scheme Environment


I'm new in iOS Programming and right now I want to build multiple environment for my current apps. But when I'm installing pods, it success, but my pods are not recognized. It shows error

'No Such Module'

in all of framework that I install.

So here's my scheme look like: enter image description here

and here's my configuration file setting look like: enter image description here

enter image description here

and here's my Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

abstract_target 'InviseeCommon' do
target 'Invisee' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Invisee
  pod 'Alamofire', '~> 4.7.3'
  pod 'Gloss', '~> 2.0.1'
  pod 'RxSwift',    '~> 4.1.1'
  pod 'RxCocoa',    '~> 4.1.1'
  pod 'SkyFloatingLabelTextField', '~> 3.0'
  pod 'UICheckbox.Swift', '~> 1.0.0'
  pod 'M13Checkbox', '~> 3.2.2'
  pod 'ImageSlideshow', '~> 1.5'
  pod 'ImageSlideshow/Alamofire', '~> 1.7.0'
  pod 'SwiftyJSON', '~> 4.2.0'
  pod 'EPSignature', '~> 1.0.6'
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
#  pod 'netfox' # network debugging
#   pod 'NTMonthYearPicker' # date picker mode (for only show month and year
  pod 'SDWebImage', '~> 4.0'
  pod 'Kanna', '~> 4.0.0'
  pod 'IQKeyboardManagerSwift', '~> 6.1.1'
  pod 'RealmSwift'

  # UIs KIT
  pod 'SVProgressHUD' , '~> 2.2.5'
#   pod 'FlatUIKit' # flat ui kits
  pod "FDStackView", "1.0" # stack view backports  ( < ios 9.0 )
  pod 'XLPagerTabStrip', '~> 8.0.1' # android-pager-strip like tab
  pod "OALayoutAnchor", '~> 0.2.0' # layout anchor backport for ios <=8
  pod 'ActionSheetPicker-3.0', '~> 2.3.0' # ui sheet for picker
  pod 'Charts', '~> 3.2.0' # draw chart ability
  pod "FlexibleSteppedProgressBar", '~> 0.5.0'
  pod 'Pulley', '~> 2.6.0' # bottom sheet behavior like android
  pod "SwiftChart", '~> 1.0.1'
  pod 'LTHRadioButton', '~> 1.2.2'
  pod 'DropDown', '~> 2.3.6'
  pod 'QRCode', '~> 2.0'
  pod 'NVActivityIndicatorView', '~> 4.4.0'
  pod 'QRCodeReader.swift', '~> 8.2.0'
  pod 'EPSignature', '~> 1.0.6'
end

target 'Development' do
    pod 'InviseeDevelopment'
end

end

post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
        config.build_settings.delete('CODE_SIGNING_ALLOWED')
        config.build_settings.delete('CODE_SIGNING_REQUIRED')
        config.build_settings['SWIFT_VERSION'] = '4.0'
    end

    installer.pods_project.targets.each do |target|
        if ['Charts','DropDown', 'RealmSwift', 'Pulley', 'LTHRadioButton'].include? "#{target}"
            print "Setting #{target}'s SWIFT_VERSION to 3.0\n"
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.2'
            end
        else
            print "Setting #{target}'s SWIFT_VERSION to Undefined (Xcode will automatically resolve)\n"
            target.build_configurations.each do |config|
                config.build_settings.delete('SWIFT_VERSION')
            end
        end
    end
end

What should I do? Thank you.


Solution

  • @Lu's answer is no longer valid because link_with is replace with abstract_target from latest release of cocoapods.

    Please refer below profile structure for a common framework and different framework for each target

    # There are no targets called "InviseeCommon" in any Xcode projects
    abstract_target 'InviseeCommon' do
      pod 'Fabric'
    
      target 'Invisee' do
        pod 'Invisee'
      end
    
      target 'Development' do
        pod 'InviseeDevelopment'
      end
    end
    

    #Update:1

    #For a new new/duplicate target:

    Create a duplicate target instead of a new scheme. Please refer below screenshot how to create a duplicate target.

    How to duplicate target

    Sample Podfile for my demo project

    abstract_target 'InviseeCommon' do
      pod 'Fabric'
    
      target '56128499' do
          pod 'Alamofire', '~> 4.7.3'
      end
    
      target 'Development' do
          pod 'Alamofire', '~> 4.7.1'
      end
    end
    

    Here Fabric is common for all target and Alamofire(4.7.1) for Development and Alamofire(4.7.3) for 56128499

    #For a new scheme:

    Just reinstall cocoa pods