2
votes

I'm trying to run my app to iPhone Simulator. Now I'm using a CocoaPods.

Structure of my project:

  • StepicIOS.workspace
  • Features
    • ExternalWorkers
      • ExternalWorkers.xcodeproj
  • Common
    • StepikCore
      • StepikCore.xcodeproj

Pod file:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

workspace 'StepikIOS'

xcodeproj 'Common/StepikCore/StepikCore.xcodeproj'
xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'

def net_pods
    pod 'Alamofire', '~> 4.7.2'
end

target :ExternalWorkers do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

target :ExternalWorkersTests do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '4.0'
        end
    end
end

enter image description here enter image description here

When I run the application I get an error:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: /Users/nikita/Library/Developer/Xcode/DerivedData/StepikIOS-ghofwgasymvhnxbjmtdesdkbcdal/Build/Products/Debug-iphonesimulator/ExternalWorkers.framework/ExternalWorkers Reason: image not found

How to fix this error?

1

1 Answers

6
votes

I changed my Pod file as follow:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

workspace 'StepikIOS'

xcodeproj 'SteoikIOS.xcodeproj'
xcodeproj 'Common/StepikCore/StepikCore.xcodeproj'
xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'

def net_pods
    pod 'Alamofire', '~> 4.7.2'
end

target: StepikIOS do
    xcodeproj 'SteoikIOS.xcodeproj'
    net_pods
end

target :ExternalWorkers do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

target :ExternalWorkersTests do
    xcodeproj 'Features/ExternalWorkers/ExternalWorkers.xcodeproj'
    net_pods
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '4.0'
        end
    end
end

Because all dependencies must be installed for the main app target.