Updating project to CocoaPods 1.0.0 resulting in many errors - ios

I am working on updating some of my libraries to work with CocoaPods 1.0.0.
I have updated my Podfile to use the new DSL syntax and ran pod update which seemed to work as expected.
Problem 1:
I now have a bunch of errors I have never seen before in my project mainly
Ambiguous use of internal linkage declaration XXX defined in multiple modules
Does anyone know what this error means and how to fix it?
Problem 2:
#import <CocoaPodName/Header.h> style imports can no longer find the appropriate header file.
Problem 3:
FBSnapshotTestCase will no longer build and gives the error Use of private header outside of module scope...
All of these problems began as soon as I ran pod update after updating to CocoaPods 1.0.0.
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'App' do
...
target 'Tests' do
inherit! :search_paths
pod 'FBSnapshotTestCase'
end
end
Update:
I was able to get everything to compile by removing use_frameworks! from the Podfile and using pod 'FBSnapshotTestCase/Core.
Ideally I would prefer to be able to use use_frameworks!, but it seems there may be a bug in CocoaPods 1.0.0?

Related

Xcode 10.1: Pods not compiling when running UITest

I am trying to implement UITests in an application I'm working on.
When I am in my UITests.swift file and I try to run the app from a test, Xcode gives the following error for some of the pods I'm using:
Command CompileSwift failed with a nonzero exit code
It gives this error for a bunch of pods that are compiling just fine when running the regular project:
My PodFile looks as follows:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
source 'https://github.com/cocoapods/specs.git'
project 'Project.xcodeproj'
use_frameworks!
# Define all thirdparty pods we need
def thirdparty
pod 'Moya', '~> 11.0'
pod 'Alamofire'
pod 'SwiftyJSON'
pod 'Differ'
.. a bunch of other pods
end
# Pods for Project project
target 'Project' do
thirdparty
end
# Pods for ProjectTests
target 'ProjectUITests' do
thirdparty
pod 'Nimble'
end
I'm having a hard time reasoning why this is happening, as my project normally compiles just fine. Other posts on S.O. regarding this problem report that the problem also occurs when building the project rather than just running for a test
Question How can I make sure that all pods I use in my project, also compile correctly when building from a UITest?
How can I make sure that all pods I use in my project, also compile correctly when building from a UITest?
The only way to know whether something will build or not is to try to build it. So when you change your CocoaPods configuration, even if that's just to update to a newer version of one or more pods, you need to try building each target.
target 'ProjectUITests' do
thirdparty
pod 'Nimble'
end`
According to your Podfile, you've got the pod Nimble being used only in the ProjectUITests target. If that's the only target that fills to build, then it seems likely that that pod is the culprit.
Except for one case (at least as far as you've shown) your Podfile doesn't specify versions for the various pods that it specifies. If you leave out the version for a given pod, your project will use the latest available version. That means that anytime you update your pods you'll pull down the latest version, even if that new version contains breaking changes. It would be safer to specify the version that you know works, or at least to limit the version to minor version and patch updates, like:
pod 'Nimble', '~>7.0'
That will let CocoaPods automatically use the latest version up to but not including 8.0. If the pod developer properly follows the semantic versioning scheme, that should ensure that you don't inadvertently pull in any breaking changes.
The problem is that target :AppModuleTests do do not have an app host and you are using inherit! :search_paths. This means that this target would find the dependencies to load them from the host but in this case there is none.
target TestApp do
pods
target :AppModuleTests
end
This worked for me.

Pods with multiple targets getting error?

Alright, Ive seen this problem in a lot of places but I cant find a clear solution - they all seem to be pretty convoluted. I am trying to add pods to a Message Extension. I get this error when doing the following and running pod install - this happens as soon as opening and trying to run the workspace:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'LaunchPack' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for LaunchPack
pod 'lottie-ios'
end
target 'MessagesExtension' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MessagesExtension
pod 'lottie-ios'
end
Here I pod to both targets and per solutions like https://www.bountysource.com/issues/35748866-missing-embed-pods-build-phase-for-messages-extension-target I have manually added the library (Lottie) to the Link Binaries with Libraries section of BOTH targets:
The link above describes "The issue can be fixed by ensuring that the framework is weakly linked and manually adding a "Run Script" build phase for the -frameworks.sh script"
however I don't understand what they mean by that. Where I can I link the framework other than where I have already?
How can I add pods to my MessageExtension?
I have faced the same issue when adding pods for multiple targets what I did was uninstalled and deleted all the pods file first. Then create multiple targets and after that add the pod file and installed it and works fine for me.

IOS Run custom shell script 'embed pods framework' file not found error

I am getting an error when building my app after i removed reference to a framework i added incorrectly. i am new to ios and cocoapods
/Users/MyMac/Library/Developer/Xcode/DerivedData/MyApp-ewxrexwuczochyctnqvlyusrtvvy/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Script-5874133373474758EEC76CFD.sh: line 2: /Users/MyMac/Documents/MyApp/Pods/Target Support Files/Pods-MyApp/Pods-MyApp-frameworks.sh: No such file or directory
I am aware that the file and directory don't exist and that is the way it should be but where is it finding the reference to this file so i can remove it and be rid of the error.
I have checked the following:
Linked Frameworks andLibraries under the general tab of my project
The frameworks group in the project
framework search paths under build settings tab
i have also run pod update after removing it from the pod file
How can i fix this?
Edit
back story
I was trying to add the framework https://github.com/Alliants/ALAccordion . in the instruction it said to use
# Podfile
target 'My Target' do
use_frameworks!
pod "ALAccordion"
end
so i added MyApp where my Target is and it created a framework named Pods-MyApp which i cant remove completely.
hope this helps
Cocoapods wrote a tool to completely deintegrate all of this stuff from your project so it goes back to running standalone. It sounds like you had an issue adding the correct target, so use this:
https://github.com/CocoaPods/cocoapods-deintegrate
Then try again so you can at least start from good ground. Hope this helps!
It happened with a prerelease version of Cocoapods 1.2.0.beta.1, by reverting to stable version and running pod install, then clean build, it worked.
why
use_frameworks!
after
target ... do
here is example
platform :ios, '8.0'
use_frameworks!
inhibit_all_warnings!
target 'XXX' do
pod 'RealmSwift'
end
target 'XXXTests' do
pod 'RealmSwift'
end

Objective C Project in Xcode 7 CocoaPods Error

The Terminal Error I am receiving after running pod install is:
I realize that ReactiveCocoa's cocoapod is entirely in SWIFT and that I need to Bridge the header files, but my attempts have been far from successful.
I did find this response from one of TeamTreehouse's Staff:
"The SimpleAuth library has it's own set of dependencies one of which is ReactiveCocoa. ReactiveCocoa was recently rewritten completely in Swift so that's the Swift code that's getting added to your project. Unfortunately there are 2 versions of ReactiveCocoa out there, written in Swift 1.2 and Swift 2.0.
SimpleAuth is currently automatically pulling the 1.2 version of ReactiveCocoa.
Swift 1.2 can only be run in Xcode 6.1 and not in Xcode 7 (which requires Swift 2).
So if you are using Xcode 7, then you're pulling in the Swift 1.2 version by default and this is causing all the Swift errors.
Also, you have to do some cleanup work to get Swift frameworks to run in a mixed Objective-C/Swift project which includes adding a bridging header and stuff."
.
^^ Explains my Problem ^^
Thanks in advance!
Edit
After adding use_frameworks! to my Podfile, I was receiving errors like:
The error message says to add the line use_frameworks! to your file called Podfile.
Add it below the first line that should probably say platform :ios, 'x.0'.
You need to use ReactiveCocoa 4.0, which is target Swift 2.0, yet still under alpha version.
If you want to have a try, check this out.
use_frameworks!
target 'YOUR_TARGET' do
pod 'ReactiveCocoa', '~> 4.0.0-alpha'
end
After attempting use_frameworks! within my pod file, I was still experiencing errors due to ReactiveCocoa and the .swift files (even after auto-correcting the errors that Xcode attempted to fix for me).
Within my Podfile I was able to resolve both sets of errors I was experiencing:
1. When including use_frameworks! in the Podfile
2. Also when running my original pod install in hopes of adding the Parse cocoapod
Final code in Podfile
pod 'ReactiveCocoa', '2.4.7'
pod 'SimpleAuth/Instagram', '0.3.6'
pod 'SSKeychain'
pod 'Parse'
You can actually request the latest version of the dependencies. Your Podfile should look like this:
platform :ios, "9.0"
use_frameworks!
target 'MyAppNameHere' do
end
pod 'Box', :head
pod 'Result', :head
pod 'SimpleAuth/Instagram'
Then peform a pod update and in your project, Product > Clean and Product > Build and will work again.

Trouble using AWSiOSSDKv2 via cocoapods 0.36 beta2

Using a Podfile like so:
platform :ios, '8.1'
source 'https://github.com/CocoaPods/Specs.git'
pod 'AWSiOSSDKv2'
I am getting a bunch of "file not found" errors in my xcode project related to the #imports being used in the AWSSDK. E.g. in AWSMobileAnalyticsContext.h:
#import "configuration/AWSMobileAnalyticsConfiguring.h"
I suspect this has to do with the fact that the project hasn't been updated with a dynamic framework output in mind (which is what the beta of cocoapods is using). I've gone through and actually tried hand-updating the paths to these imports, and I can clear most of the file not found errors, but then it starts complaining about the Mantle.h import elsewhere.
Anybody successfully gotten the AWSiOSSDKv2 to work with an app by using the cocoapods beta (or even a forked version that uses dynamic frameworks)?
I was able to get it to work today.
I deleted all traces of cocoapods since it had originally been installed using 0.35.
[project].xcworkspace
All mentions in [project].xcodeproj related to pods (yes, by hand with vim)
Pods/
Podfile and Podfile.lock
I then installed my swift pods using carthage instead. For me, this was Alamofire and SwiftyJSON.
I made a commit here, so I could easily go back to this point.
My podfile was just this, I could not get it to work with the use_frameworks! line.
target 'WhatsLegal' do
pod 'AWSiOSSDKv2'
pod 'Facebook-iOS-SDK'
end
I ran pod init and then pod install, and it started working from here!

Resources