Migrating to CocoaPods 1.0.1 - cocoapods

I am trying to migrate our existing CocoaPod configuration from 0.39.0 to 1.0.1.
Our existing Podfile looks like:
platform :ios, '9.0'
use_frameworks!
target 'Tools' do
pod 'zipzap', '~> 8.0.4'
pod 'Argo', '~> 2.2.0'
pod 'Curry', :git => 'https://github.com/thoughtbot/Curry.git', :commit => 'eeb459fac309833288e61e134a4e8fad649e99b0'
end
target 'ToolsTests' do
end
This compiled and the tests ran just fine previously. After following the migration guide. I restructured the Podfile like so:
platform :ios, '9.0'
target 'Tools' do
use_frameworks!
pod 'zipzap', '~> 8.0.4'
pod 'Argo', '~> 2.2.0'
pod 'Curry', :git => 'https://github.com/thoughtbot/Curry.git', :commit => 'eeb459fac309833288e61e134a4e8fad649e99b0'
target 'ToolsTests' do
inherit! :search_paths
end
end
This compiles and links just fine. Unfortunately when the tests run they crash with:
2016-06-07 12:04:06.265 xctest[56474:789900] The bundle “ToolsTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-06-07 12:04:06.299 xctest[56474:789900] (dlopen_preflight($HOME/Library/Developer/Xcode/DerivedData/Tools-dbmncsubtoarlhhcrpchrswefprz/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ToolsTests.xctest/ToolsTests): Library not loaded: #rpath/Argo.framework/Argo
Referenced from: $HOME/Library/Developer/Xcode/DerivedData/Tools-dbmncsubtoarlhhcrpchrswefprz/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ToolsTests.xctest/ToolsTests
Reason: image not found)
Program ended with exit code: 82
In the migration guide it says:
A large fraction of the bug reports we receive is due to ambiguity in the Podfile. It gave a lot of freedom to create all kinds of CocoaPods setups that would work by luck of implementation details, or work but are significantly more complex than they needed to be.
Is this one of those cases that used to "work by luck of implementation details"? If not what is the correct Podfile syntax?
I should note if I duplicate the pod defs in the ToolsTests everything works just fine. Though this feels wrong.

Similar question: Cocoapods testing linker error
Seems to be a common problem people are facing when upgrading. Your new Podfile looks right to me.
If you haven't already, I would try:
cleaning the build folder (in Xcode -> Option+Shift+Command+K)
clearing the derived data folder (rm -rf ~/Library/Developer/Xcode/DerivedData)
clearing your CocoaPods cache (rm -rf ~/Library/Caches/CocoaPods)
and run pod install again
EDIT:
The question I mentioned above has an answer now: https://stackoverflow.com/a/37705768/3067051

Related

Trying to Rebuild a Legacy IOS App, Getting Error in Facebook-IOS-SDK Cocoapod

I've been asked to rebuild an existing IOS app that uses Facebook-IOS-SDK. The app is at least 5 years old so I expected things to be deprecated. I have some limited experience with XCode and IOS but I'm far from an expert. I've never used cocapods until today. I installed cocoapods and ran pod init. Facebook-IOS-SDK ver 3.24.4 loaded with no errors (other pods too, including Bolt, with no errors).
I've read the migration notes on the FB dev page regarding the versions and it's implied that I should be able to use 3.24. When I do a clean build I get the error:
(FBRequest *)requestForUpdateOpenGraphObject(id<FBOpenGraphObject>)object
{
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
}
Expected method to read dictionary element not found on object of type 'id<FBOpenGraphObject>'
This error is in FBRequest.m, the cocoapod code, not in my clients code. This code is marked read only. If this is the correct pod version, and I can't change it then is there some other dependency in the (large) project that needs to be updated?
Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, "9.0"
target "tbd" do
pod 'IQKeyboardManager'
pod 'UICKeyChainStore'
pod 'CocoaLumberjack', '~> 2.0.0-beta'
pod 'SDURLCache'
pod 'HockeySDK'
pod 'Facebook-iOS-SDK', '~> 3.23'
pod 'GoogleAnalytics-iOS-SDK'
pod 'UIActionSheet-Blocks', '~> 1.0'
end
target "tbdTests" do
end
The only, nasty, solution I found is to change the code inside FBRequest.m manually.
Change line 370 from:
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
to
return [FBRequest requestForUpdateOpenGraphObjectWithId:object.objectID graphObject:object];
this should make you project runs again.
Again, this is not a nice solution, but it works :)
Emilio
if you don't have the need to use Facebook-IOS-SDK ver 3.24.4 you can simply use the latest version 4.36.0.
have a look at your Podfile and see if there is any reference to Facebook-IOS-SDK, if there is something like:
pod 'Facebook-IOS-SDK', '~> 3.0'
you can replace it with:
pod 'Facebook-IOS-SDK', '~> 4.0'
otherwise post your Podfile and we can have a look.
Cheers

no such module 'Alamofire' but in Podfile

I have adopted a Swift project from about 6 months ago and am getting the error:
It's probably not an Alamofire issue as changing the order with SwiftlyJSON causes me to get a No such module 'SwiftlyJSON' error.
I have Product -> Clean'd it and rebuilt but nothing seems to work. Here's a copy of the Podfile.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "9.3"
use_frameworks!
target 'TatterTwo' do
# pod 'pop', '~> 1.0'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'KeychainAccess'
pod 'Alamofire'
pod 'MBProgressHUD'
pod 'SwiftyJSON','3.0.0'
# pod 'Timberjack', '~> 0.0'
end
I am sure I am using the .xcworkspace rather than .xcodeproj
Ok, there might be different reasons behind this error
First, try to stop the build and start again. If this doesn't work then
Open your Podfile, that is supposed to be located inside of the project folder. Podfile configuration. Make sure your target matches the project name. If you did any modification then go to terminal locate the project folder and run sudo pod update, it should give you an output "Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed". After this restart your xcode file. Oh yeah and the last make sure you are opening .xcworkspace instead of xcodeproj
Reinstall Alamofire manually, and restart Xcode.
Make sure you check "No" on the project file for ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
It took ages for me to get it to work.

SDK image not found when running OSX UI Tests with Cocoapods

I am trying to add my first automated UI tests to my application and am running into quite a bit of difficultly.
The app will build in its current state and the main application itself runs just fine. However, when I try to run my tests I get the following error:
2016-08-02 19:39:33.340 XCTRunner[17590:966857] Running tests...
2016-08-02 19:39:33.407 XCTRunner[17590:966857] The bundle “MYAPPUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-08-02 19:39:33.407 XCTRunner[17590:966857] (dlopen_preflight(/Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests): Library not loaded: #rpath/HockeySDK.framework/Versions/A/HockeySDK
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests
Reason: image not found)
I've seen that there are a few related questions on SO but none of them see to help me out.
Originally, I was implementing my tests in Swift on top of an Objective C application and thought that might be the problem. However, I discovered after making an Objective-C based test target that I am running into exactly the same issue in Objective C.
Thanks for any help.
EDIT
Some additional information: I have tried this using both Cocoapods 0.39.0 as well as the latest non-beta 1.x release. Both resulted in the same error.
My podfile is listed below (for 0.39.0)
platform :osx, '10.9'
link_with 'MYAPP', 'MYAPP MAS', 'MYAPPUITests'
pod 'AFNetworking', '~> 2.5.0'
pod 'ISO8601DateFormatter'
pod 'CDEvents', :git => 'https://github.com/rastersize/CDEvents'
pod 'MASShortcut', '1.3.1'
pod 'libPusher', '1.6'
pod 'NPReachability', :git => 'https://github.com/Abizern/NPReachability.git', :commit => 'e57753d'
pod 'CocoaLumberjack'
pod 'SocketRocket', :git => 'https://github.com/marianoabdala/SocketRocket.git'
pod 'HockeySDK-Mac'
pod 'INAppStoreWindow', '~> 1.4'
I was able to fix this after spending 2-3 days on this by adding an obscure step to my Build Phases.
I created a Copy Files build step after the Link Binary With Libraries step and before the Embed Pods Frameworks step.
I copied the offending framework ("HockeySDK") into the Products Directory. This solved the issue!
Ultimately this may be related to my app being a StatusBar App, not a regular app, as the solution which finally worked for me was related to a CommandLine application running into the same bug.
Link to Github bug page with the solution that worked for me

Cocoapods frameworks.sh error: no such file

So I'm fairly new at both Swift and working with cocoapods, and after spending several days of researching I cannot figure out why my project isn't building. I get the following error:
(My project)/Pods/Target Support Files/Pods-(My project)/Pods-(My project)-frameworks.sh: No such file or directory
I am using Xcode 7.2.1 and Cocoapods 0.39.0 and I seem to have tried all the troubleshooting tips from Cocoapods' website. Can anyone tell me what I need to do to make it work?
My podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
use_frameworks!
pod 'GoogleMaps'
pod 'FontAwesome.swift'
pod 'Lock', '~> 1.21'
pod 'JWTDecode', '~> 1.0'
pod 'Lock-Facebook', '~> 2.1'
pod 'SimpleKeychain', '~> 0.7'
pod 'Bolts', '~> 1.6'
pod 'FBSDKCoreKit', '~> 4.1'
pod 'FBSDKLoginKit', '~> 4.1'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'Alamofire', '~> 2.0'
pod 'CocoaLumberjack/Swift'
pod 'AFNetworking', '~> 2.5'
pod 'Auth0', '~> 0.2'
You're probably missing the target block for your target, in the Podfile.
I added a target to my project, and forgot to add a target block to the Podfile for that target, and I had the same error.
(My project)/Pods/Target Support Files/Pods-(My project)/Pods-(My project)-frameworks.sh: No such file or directory
The path components are actually named after the target:
(My project)/Pods/Target Support Files/Pods-[target]/Pods-[target]-frameworks.sh
Cocoapods builds configuration files for each target that you specify. Try adding a target entry to your Podfile, like so:
target "SOME TARGET" do
specify pods here
end
If you end up adding a lot of targets, it might be a good idea to define pod groups that you can easily use inside your target entries. So, you would define your groups above your target entries, like so:
def commonPods
specify pods here
end
Then you can use the group name in your pod entry, instead of copying all the pod entries for every target:
target "SOME TARGET" do
commonPods
end
Adding the target entry in your Podfile will cause CocoaPods to generate a new set of files the next time you run pod install. However, before you run that command, you will probably need to set your configurations to None, so that Cocoapods can assign its own configuration. Here's how to do that:
Go to your project-level target
For each configuration listed under Configurations, select None for your target, in the drop-down menu under Based on Configuration File.
These steps will eliminate the Cocoapods warning that reads:
CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all...
Once you've edited your Podfile and you nullified your configurations, you're ready to run pod install on the command line. After the process is completed, check back with your base configuration settings, and note that they have been set to the configuration file that was generated by CocoaPods!
I hope that helps!
This is kind of dumb, but it happened to me:
You might be in the wrong directory.
I was running pod install from directory Desktop/Project/Project Files, and I kept getting an error like this.
Then I realized I was in one step too far, so I went up to directory Desktop/Project, and it worked.
As to why pod install even ran considering the Podfile was in Desktop/Project and not Desktop/Project/Project Files... ¯\_(ツ)_/¯
My problem is that " blablabla Pods-XXXX-frameworks.sh: No such file or directory"
Firstly, I fix it by using command line "pod install" , it has nothing effection.
The finally solution :
Touch "Build Phases" -> "Embed Pods Frameworks" ,you can see the path :XXXXX.sh"
Be sure that the XXX.sh is the same as your project's. if not, change the path.
Then clean and build.
It's done.
Make sure that you are running pod install in the same directory where you have your xcode project.

Kiwi and CocoaPods with a static shared library

I have a workspace with 3 projects:
MyApp
Common
Pods
Common is a common library that MyApp depends on. I'd like to setup CocoaPods and Kiwi to work correctly in this project. How do I go about this?
I found https://stackoverflow.com/a/16472563/62, but when I try to follow this approach, I get an error when building MyApp before I even try adding Kiwi:
ld: library not found for -lPods
Here's the repo on GitHub: https://github.com/lyahdav/cocoapods_kiwi_shared_library
My Podfile is:
workspace 'MyApp.xcworkspace'
platform :ios, '7.0'
target 'Common' do
xcodeproj 'Common/Common.xcodeproj'
pod 'AFNetworking'
pod 'Reachability'
target 'MyApp', :exclusive => true do
xcodeproj 'MyApp.xcodeproj'
end
end
I finally found a working solution for this. Here's the Podfile:
platform :ios, '7.0'
workspace 'MyApp.xcworkspace'
xcodeproj 'MyApp'
pod 'CupertinoYankee', '~> 1.0'
target :MyAppTests, :exclusive => true do
pod 'Kiwi/XCTest'
end
target :Common, :exclusive => true do
xcodeproj 'Common/Common'
pod 'CupertinoYankee', '~> 1.0'
end
target :CommonTests, :exclusive => true do
xcodeproj 'Common/Common'
pod 'Kiwi/XCTest'
end
This example Podfile shows both MyApp and Common configured to use Kiwi for tests and they can both use pods (CupertinoYankee in this example).
I did manually have to configure in Xcode that MyApp links with Common with these steps:
In MyApp project settings > MyApp target > Build Phases > Link
Binary With Libraries > add libCommon.a
In MyApp project settings > Build Settings > User Header Search Paths > add ${SRCROOT}/Common/Common/**
This repo has a working example: https://github.com/lyahdav/cocoapods_kiwi_shared_library
The only slightly annoying thing I didn't manage to figure out was if there's a way to not duplicate each pod that I want to use both in MyApp and Common. If anyone has a solution that does all of what my solution does and solves that, I'll gladly mark it the accepted answer.
Posted as an edit by anonymous user. Here's his answer:
I have forked the repository and made few changes for new cocoapods versions to make it still working.
platform :ios, '8.0'
workspace 'MyApp.xcworkspace'
project 'MyApp'
target :MyApp do
pod 'CupertinoYankee', '~> 1.0'
end
target :MyAppTests do
pod 'Kiwi/XCTest'
end
target :Common do
project 'Common/Common'
pod 'CupertinoYankee', '~> 1.0'
end
target :CommonTests do
project 'Common/Common'
pod 'Kiwi/XCTest'
end
https://github.com/chrishunterkiller/cocoapods_kiwi_shared_library
I'm not sure how to fix the setup you have, but if I were you I would make Common into its own Pod. Pods can be private and just stored in GitHub as a repo. Of course, you need a podspec for Common but I built a sample to test that setup for our build service and it took me less than 30 mins to get it right.
Then in your Podfile for MyApp, you do something like this:
pod 'Common', :git => 'git#github.com:lyahdav/Common.git', :commit => 'a1b2c3d'
And AFNetworking and Reachability can be referenced in the podspec of Common (assuming that's the right dependency).
This setup also allows you to include Common in whatever other apps you're building without having to embed the code. Again, making assumptions about what you're trying to achieve, so add more detail to the question if that's not right.
You could hack a solution that may get broken again, or better yet as Common is your library, start using CocoaPods for your Common library as well.
It will show up as a local "Dvelopment Pod", which means that you can directly edit the library code as well.
To begin easily just create a Common.podspec at the root folder:
$ pod lib create Common
Then just edit the minimum required parameters, such as platform, source_files, requires_arc and dependency if any.
You can take a look at how your library looks as you change it (and compare it to what you had with your manually created Common library):
$ pod lib lint --no-clean Common.podspec
Finally remove the no-longer needed Common from your workspace and add this to your Podfile:
pod 'Common', :path => '../Relative/Path/To/CommonSources/'
It will take you no more than 30 minutes and you'll learn many things in the process.
Next you could take a look at making private pod repositories.

Resources