Quantcast
Channel: Active questions tagged cocoapods - Stack Overflow
Viewing all articles
Browse latest Browse all 1024

Using Cocoapods in iOS Framework and App Projects in the same workspace

$
0
0

Okay, so maybe I'm doing something absolutely wrong so feel free to correct me. Let me explain what I'm trying to achieve.

I work on a project with multiple targets. Each target is used to create a separate app. The targets share a lot of core functionality but some targets add some additional code or only use a minimal set (e. g. some web services) of the "core".

Currently everything is packed into one Xcode project and I use the "Target Membership" functionality (in the File Inspector) to mark which class belongs to which target. Core classes are members of all targets and special classes are only member of one target.

That can easily get confusing and it brings another problem with it. I want to use a CI/CD server to automatically build and publish updates to Test Flight. Since currently all files are in one repository, I cant automatically detect which app needs to be updated.

My plan now is to separate my repository and my project into multiple parts. I thought of using one "Core" projects as well as one project for each app. Each project will reside in it's own GIT repository.

I then create a "master" repository and use GIT subtrees to add the other repositories. I then can setup triggers for each repository separately to build the corresponding apps (or all apps at once if I change something in the core).

The structure is looking good so far but I have a problem with setting up cocoapods correctly. My problem is that I use cocoapod dependencies in my core which is now a Framework. My Podfile currently looks like this:

source 'https://github.com/CocoaPods/Specs.git'workspace 'Master.xcworkspace'platform :ios, '10.0'use_frameworks!project 'core/Core'project 'app/MyApp'def common_pods    pod 'Firebase/Core'    pod 'Alamofire'endtarget 'Core' do  project 'core/Core'  common_pods    target 'CoreTests' do    inherit! :search_paths  endendtarget 'MyApp' do  project 'app/MyApp'end

And my filesystem looks like this:

  • Master (folder)
    • Master.xcworkspace
    • Podfile
    • core (folder)
      • Core.xcproject
      • Core (folder containing the files)
    • app (folder)
      • MyApp.xcproject
      • MyApp (folder containing the files)

If I now import the Core framework in one of the MyApp classes, I get a build error saying "Missing required module 'Firebase'" and if I add "common_pods" to the MyApp target, I can build but at runtime get a bunch of "Class xxx is implemented in both Core.framework and /.../MyApp.app/MyApp. One of the two will be used. Which one is undefined." errors and my app crashes.

I once read that one should make custom frameworks pods and use cocoapods to add them instead of adding them directly via the project targets embed binaries functionality but wouldn't that mean that every time I make a change to the core, I'd need to build the framework and then make a pod update before finally building and running my application? That can't be the solution.

What am I missing? What am I doing wrong? I hope you can help me figure it out.


Viewing all articles
Browse latest Browse all 1024

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>