Carthage framework target can't find dependencies - xcode

I've created a library, which I would like to distribute via CocoaPods and Carthage.
I can't get my shared framework target to build with Carthage, I get a build error, basically stating it can't find Alamofire and SwiftyJSON, which are dependencies of my framework. I've added SwiftyJSON and Alamofire to my Cartfile and to the Linked Frameworks and Libraries section of my shared framework target.
If I run Pod install first everything works fine, presumably because CocoaPods makes my dependencies available, but obviously this is not a good solution.

Related

How Do I Define a Host Target That Embeds a Framework Target?

I have an existing workspace file in a directory whose sub-directories contain the Xcode project files. When I issue the 'pod install' command (my pod version is 1.2.0) from the workspace file's directory, I get the following warning:
[!] The Podfile contains framework targets, for which the Podfile does not contain host targets (targets which embed the framework).
If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).
The general form of my pod file is:
workspace 'MyWorkspace'
use_frameworks!
target 'MyFramework' do
pod 'PodA'
project 'MyFramework/MyFramework'
end
target 'MyApplication' do
pod 'PodA'
project 'MyApplication/MyApplication'
end
The above pod file works for me. Note however that I am having to express the PodA dependency for both the framework (which does indeed need it) and the application (which needs it indirectly via its dependence upon the framework). I suspect that this would not be necessary if I only knew how to do what the warning is prompting me to do - i.e. express, in the pod file, the application's dependency upon the framework. I have googled, experimented, and read on CocoaPods.org. All to no avail. Target embedding seems to be used to scope pod dependencies - the inner target inherits the pod dependencies of the outer target. I cannot find an example of a host target which embeds a framework target. Can anyone help?
Cocoa Pods is complaining that there is no target in the pod file that using the static library \ framework in the pod file.
Take a look at this sample project
tl;dr
In case of static library you need to go to "build phases" in your 'host' project and add the static library as a "target dependency", also add the static library .a file in "link binary with libraries"
The process for Frameworks is a little more confusing so I suggest to clone the sample project and take a look at the configuration.

cocoapods show Swift error when installing

I try to 'pod install' my project with some libraries (AFNetworking, GooglePlaces and GoogleMaps). However, it always shows the error:
[!] Pods written in Swift can only be integrated as frameworks; add
use_frameworks! to your Podfile or target to opt into using it. The
Swift Pods being used are: Alamofire, GooglePlaces, and ObjectMapper
But I only use objective-c frameworks, for Objective C project. I did the research but cannot find how to fix this. My current version of cocoapods is 1.0.0.
The Swift Pods being used are: Alamofire, GooglePlaces, and ObjectMapper
You may be writing in Objective-C but the pods you want to use are not. You would need to add use_frameworks! to the Podfile to say that you are fine with making them all frameworks in order to support Swift.

How can I add a cocoapod as a submodule rather than using it via cocoapods?

I am wanting to add a cocoapod as a dependency within my Xcode project. However, I am trying to avoid using cocoapods within my project for various reasons. How can I add the pod to my project like a submodule as an alternative?
The cocoapod that I'm attempting to use is InstagramKit. I attempted to install the git repository as a submodule, which worked fine. Once there I tried adding the entire cocoapods project to my xcode project. I added it as a project dependency, but the build fails with no indication as to what went wrong. I did run pod install on the InstagramKit project that I added to my project. So all of its dependencies were properly configured. Any idea how I can add this to my project?

Cocoa Pods without workspace?

I have read about a possibility to add CocoaPods to an XcodeProject without getting the xcworkspace file, instead you get a xcodeproj file that you can integrate into your current project. How can I do that? Would love to use the xcodeproj file instead of xcworkspace.. I'm programming in swift (if that makes any difference).
Yes, its possible. But, we need to do few steps to proceed.
Check this Github thread.
The below line in pod.file will not let the client integration process.
install! 'cocoapods', :integrate_targets => false
We can drag and drop the Pods.xcodeproj to the main project
Link the target dependencies and Link Binary with Libraries in Build phases.
Thats it.
You can not do this.
The CocoaPods website guide to using CocoaPods found here directs you to using the .xcworkspace it creates. Several other guides found across the Internet all direct you to use this file indicating that using the .xcodeproj file will now result in build errors.
There is simply no evidence that this is a possibility at all.
From the CocoaPods website guide on using CocoaPods:
Save your Podfile.
Run $ pod install
Open the MyApp.xcworkspace that was created. This should be the file you use everyday to create your app.
More from their website:
Now you can install the dependencies in your project:
$ pod install
Make sure to always open the Xcode workspace instead of the project
file when building your project:
$ open App.xcworkspace
And from the Ray Wenderlich guide regarding using CocoaPods with Swift:
Open the project folder using Finder, and you’ll see that CocoaPods
created a new IceCreamShop.xcworkspace file and a Pods folder in which
to store all the project’s dependencies.
And from an NSHipster article on CocoaPods:
CocoaPods will create a new Xcode project that creates static library
targets for each dependency, and then links them all together into a
libPods.a target. This static library becomes a dependency for your
original application target. An xcworkspace file is created, and
should be used from that point onward. This allows the original
xcodeproj file to remain unchanged.
In older versions of cocoapods it was possible to install and update pods with the option '--no-integrate'. It allows you to create a library project, which could be imported into an existing project (read more). But this option is missing now. I've build a Xcode project for a maven-build with this option earlier. Today I've updated the pods of this project with the newest cocoapods version (1.0.0) but without the '--no-integrate' option and it still works. So eventually there is a way...

Cocoapods --no-integrate command for different targets

As per http://guides.cocoapods.org/terminal/commands.html#pod_install, if you want to integrate libs or external dependency at yourself you can use -no-integrate option.
Basically i have my static library (comms.a) and header (comms.h). My application will import this library for server communication. My application is not using cocoapods to integrate. (Manually linking from xcode).
But my static library is having below structure.
- Comms (main target) [Dependency on AFNetworking using cocoapods]
- CommsTest (test case target) [Dependency on GHUnit using cocoapods]
What should be my podfile so that it will fetch AFNetworking but integration is up to me and fetch GHUnit and integrate to my testcase target.
NOTE: I don't want my static library to integrate in my application using cocoapods.
Please go through the Command Line switches available in CocoaPods: http://guides.cocoapods.org/terminal/commands.html#pod_install
You will find --no-integrate switch to Skip integration of the Pods libraries in the Xcode project(s).
This means that CocoaPod will not generate the xcworkspace file in this case. Also, with this you will manually have to add Pods.xcodeproj file in your main project as child Project.
Once you add Pods.xcodeproj in your main project, you will also have to add reference of the Public headers and Library in your main project.
For more info you can view the previous post: Building a distributable static library that uses cocoapods

Resources