Cocoapods --no-integrate command for different targets - static-libraries

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

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.

Building a React Native bridge but a file within the framework can't be found

I'm trying to build a React Native wrapper for the RichRelevance iOS SDK.
I've created the wrapper project and imported it into my React Native app. I'm using Cocoapods to add the RichRelevance SDK to the app
I'm now attempting to import the RichRelevance SDK into the wrapper project using:
#import <RichRelevanceSDK/RichRelevanceSDK.h>
The problem I have is that when the compiler attempts to compile the RichRelevanceSDK, it throws an error that one of the files is not found:
Line 63 is the original import that was written in the SDK. I added Line 62 to show that the file can be found if the type of import is changed. However, this isn't really an option since I don't want to modify the SDK (I don't own it).
In either type of import, I'm able to cmd+click the file and go to the definition. So XCode seems to know about the file. Additionally, I see the file in the Project browser under:
Pods -> Pods -> RichRelevanceSDK -> RCHImportable.h
The primary difference with this file is that, if I look in the file browser, that file is located in a sub-folder, relative to all of the other files in the SDK:
I'm hoping there's a way to change my wrapper project so that this file can be found, so I don't have to edit or fork the SDK files.
So far, I've attempted to update the various Search Paths in my wrapper project but with no luck. I've added the following two paths to all of the Search Paths:
UPDATE:
I was able to make some progress and I can now get it to compile.
I ended up:
cloning the SDK's repo to my computer
removing the SDK from the Podfile
adding the SDK's xcodeproj file to MyApp/Libraries
adding the SDK.framework file to MyApp -> Embedded Binaries
I can now import the SDK into my bridge module
I would still prefer to find a better way to do this though. This method either involves me committing the SDK to our repo or asking all of my colleagues to clone the repo to their machine. NPM can't seem to install the repo; my guess is this is due to the repo missing a package.json file
There does appear to be something wrong with the packaging, as the header in question would appear to be captured in the public_header_files glob in the Podspec.
However, I think more direct path is to simply include the RCHSDK.h file, as RCHSDK is the entrypoint to the SDK functions. The RichRelevanceSDK.h serves primarily as a shorthand for importing additional headers versus specifying them individually.
Alternatively, you can follow the instructions in Include of non-modular header inside framework module, this seemed to correct the issue in local tests.

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...

Carthage framework target can't find dependencies

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.

Install Fragaria framework

I was looking for a way to implement syntax highlighting on my cocoa app and I found the great Fragaria framework https://github.com/mugginsoft/Fragaria. Unfortunately I seem to be unable to install the framework in my app.
Here are the steps I follow:
Compile the framework from the source code target
Add the framework to the "Link Binary with Libraries" build phase of XCode 4
Drag the framework into "Copy Bundle Resources"of build phase
Unfortunately when I try to build my app I get this error:
dyld: Library not loaded:
#executable_path/../Frameworks/MGSFragaria.framework/Versions/A/MGSFragaria
Referenced from:
/Users/dedalus/Developer/DEGS/trunk/build/Debug/DEGS.app/Contents/MacOS/DEGS
Reason: image not found
Which step am I missing?
Don't add the framework product to the Copy Bundle Resources build phase. Instead, create a new Copy Files build phase, set its destination to the Frameworks directory and add the framework build product to this phase. The Copy Bundle Resources build phase copies the framework to the resources subdirectory (Contents/Resources on OS X), but the dynamic linker expects it to be in the frameworks subdirectory (Contents/Frameworks on OS X). The newly added Copy Files build phase will put it there.
BTW, the error you're seeing is a run-time error, not a compile-time error. So strictly speaking you get this error when running the app, not when building it.

Resources