1

Ok, let's start with the basics since I cannot friggin get this to work (see Xcode Workspace - Not finding imports from framework project pod)...

I want to create an Xcode workspace that has two projects:

  1. Cocoa Touch Framework Swift project
  2. Swift Demo app project for the framework

Nr. 2 should also contain a UI Testing target.

Then I want to use Cocoapods to provide the WHOLE workspace (both projects!) as a pod AND I want to 'link' the framework project into the demo app project so that it can be used there.

Can somebody guide me through this incl. how the pod file needs to look for this?

BadmintonCat
  • 9,416
  • 14
  • 78
  • 129

1 Answers1

2

You need define the pods that will be common for all your projects first

# Uncomment this line to define a global platform for your project
platform :ios, '8.2'
# Uncomment this line if you're using Swift
use_frameworks!

# Define main pods.
def main_pods

    #your main pods
    pod 'AwesomeCache', '~> 5.0'
    pod 'DZNEmptyDataSet', '1.8.1'


end

# Your FirstProjectName.
target 'FirstProyectName' do

    main_pods
    #here you can add any other for this specific project
    pod 'Branch'

end

# Your SecondProjectName.
target 'SecondProjectName' do

    main_pods
    #here you can add any other for this specific project
    pod 'Alamofire'
    pod 'Fabric'
    pod 'Crashlitycs'

end

target 'FirstProjectTestName' do

end

target 'FirstProjectTestUIName' do

end

post_install do |installer|
        puts("Update debug pod settings to speed up build time")
        Dir.glob(File.join("Pods", "**", "Pods*{debug,Private}.xcconfig")).each do |file|
            File.open(file, 'a') { |f| f.puts "\nDEBUG_INFORMATION_FORMAT = dwarf" }
        end
    end
end

Hope this helps

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
  • 1
    So far so good but my framework uses XCTest. I added `s.framework = "XCTest"` to my podspec file. Now the demo app compiles but it crashes with the error: `dyld: Library not loaded: @rpath/XCTest.framework/XCTest`. Any idea why this happens? – BadmintonCat Jul 19 '17 at 03:43
  • I don't know, I have a project with custom pod working with this pod scheme without problems... – Reinier Melian Jul 19 '17 at 14:57
  • @BadmintonCat finally my answer solve in any way your problem? – Reinier Melian Jul 21 '17 at 06:12
  • @BadmintonCat Did you ever solve the problem with `dyld: Library not loaded: @rpath/XCTest.framework/XCTest` ? – Sajjon Apr 30 '18 at 10:40
  • @Sajjon did you have the same issue? – Reinier Melian Apr 30 '18 at 10:41
  • I am using Xcode 9.3/Swift 4.1 and Cocoapods 1.5. I have multiple projects that are all included in my workspace file that I let pods create. One project is an app, the rest are Cocoa Touch Dynamic frameworks that the app uses. So each project has its own `abstract_target` in the Podfile, pointing out the project folder path, e.g. `project 'Common/Views/Views.xcodeproject'`. For each project/`abstract_target`, I have two targets one main and one for tests, e.g. `Views` and `ViewsTests` for the `Views` framework. The problem is that I get the `XCTest` runtime crash too. – Sajjon Apr 30 '18 at 10:52