I'm working with a CocoaPod private library. We have mock files that are being used for our Swift Previews.
What's surprising is that these mock files aren't added as a member to the pod's target. They're a a member of the Test Target. Yet they compile.
I don't understand why/how it's working
When I further inspected the setup I noticed that within the
PodSpec
, for itssource_files
field I saw something like the following:I believe the source files are added onto the target if either:
pod install
later adds them onto the 'Build Phase' of target under 'Compile Sources'source_files
paths. ATTENTION: things work only up until you do apod install
. As soon as you dopod install
it will stop working becausepod install
will remove it from the Build Phase. Hence this isn't something you should do or rely on. I just mentioned it as insight for debugging things.Tldr the PodSpec will supercede your Xcode configurations because
pod install
overrides things.But why is CocoaPods like this?
I suppose mainly because it wants to have a higher focus on the Swift/Objective-C language and less focus on Xcode.
When you rely on paths instead of a very specific Xcode project file, then other tools like the terminal, vim, VSC can be used a lot easier.
Like you don't need Xcode running (you need the Xcode Command Line Tools installed though) to execute
pod lib lint
. And this in itself is a great advantage. It simplifies the development process.