iOS project not seeing local changes when developing a Cocoapod project - ios

I'm working on a framework that is available via Cocoapods.
I have my project set up using their suggested setup, and their development page says "You can work on the library from its folder on your system." but when I make changes to the files in the "Development Pods" folder and build my project, the changes do not show up.
I've tried running $ pod install on the project, which regenerates the xcworkspace file, but the changes still don't show up. I'm unsure how the changes are being missed, as I've commented out a large chunk of code and added a few NSLogs, but it still runs as if I never made the changes.
I've also tried cleaning the project via xcode.
Any ideas?
Bonus q: What is the correct way to work on a cocoapod framework? The documentation is rather lacking when it comes to setting up a project like this.
Edit: Here's the podfile:
platform :ios, "6.0"
pod "MyFramework", :path => "../"
(using an example name as the pod is't published yet)

The fix was to delete my xcworkspace [rm -rf MyFramework.xcworkspace] and recreate it via pod install.
The only difference I can see is that Pods is now included in the build targets for my demo app's scheme.

Here's the general process for developing a cocoapod.
Run pod lib create <Pod Name> to create your project.
cd MyDirectory
pod lib create MyPod
Make sure to run pod install inside your example project. This will generate a .xcworkspace file.
cd MyPod/Example
pod install
Open your example project via the .xcworkspace file.
Xcode -> File -> Open -> MyPod.xcworkspace
Edit your pod via Pods/Development Pods.
Project Navigator -> Pods -> Development Pods -> MyPod -> <file>
Clean, build, & run your example project.
Make sure to clean (cmd+shift+k) your project before running, otherwise changes made to your pod will not be captured.

Related

Automatically build cocoa pods for Xcode Workspace

Just wanted to know what is the best way/place to run pod install or pod update so that each time when I build the project in Xcode, the command runs automatically.
I tried with putting pod install in Xcode Project -> Scheme -> Pre-actions, but was not able to see any output. Is there any other better way?

Running a Github iOS project containing Cocoapods

I'm quite new to iOS development. Let's say I want to use a UI element from Github that uses Cocoapods.
Like this one:
Whisper by hyperslo
After downloading the zip file from Github:
Could someone give a step-by-step guide to
Run the demo project
Integrate the UI element into my own project
Thanks!
Running the demo is a little tricky. Apparently you have to first do a pod install, then open the workspace.
Make sure you have cocoa pods installed. For how to install it, go to https://cocoapods.org
Use the command line to navigate to the directory where the .xcworkspace file is located i.e. /Whisper-master/Demo/WhisperDemo
Run pod install
After that, open up WhisperDemo.xcworkspace in Xcode and you can run the demo.
To install this as a pod of your own project, you first navigate to your project's directory and do a pod init. A Podfile will be generated. Write in the Podfile the following:
platform :ios, '10.0' # or whatever your target platform is
target 'Your target's name' do
use_frameworks!
pod 'Whisper'
end
Then do a pod install. From now on, do not open the .xcodeproj file. Instead, open the .xcworkspace whenever you want to work on the project.

Cocoapods error for one project target while others are working fine

I have create 3 project target (Development, Production and Staging).Expect Production other working fine after pull the changes of others while building the production target xcode giving the error :
gone through some of the available solution but no success!!!
If you change something the conflict will be occur, do like remove your WorkSpace once and again install or update your Pods,it will Work
Run pod install or pod update your CocoaPods installation.
For additional Information see this1
Choice-2
there's a problem with Cocoapods in your project. Sometimes cocoapods can get out of sync and you need to re-initiate cocoapods. You should be able to resolve this error by:
Deleting the Podfile.lock file in your project folder
Deleting the Pods folder in your project folder
Execute pod install in your project folder
Do a Clean in Xcode
Rebuild your project
Conclusion: don't run pod install while project opened in the Xcode.
Update answer
I. Project Cleanup
In the project navigator, select your project
Select your target
Remove all libPods*.a in Linked Frameworks and Libraries
II. Update CocoaPods
Launch Terminal and go to your project directory.
Update CocoaPods using the command pod install
I have solved my problem by this way :
After implementing lot many solution i got this error :
By removing Check pods manifest.lock, Copy pods resources and Embed pods frameworks from Build Phases of Tests project target(xxxTests) i solved the issue.
NOTE: If any one still getting any issue related to pods, then try to remove libpods-xxx.a from Link Binary with libraries and again add it.

Alamofire No Such Module (CocoaPods)

Using Xcode 7
I am trying to install Alamofire in a sample project. Have used the instructions from Ray Wenderlich's page
Only change from above link is the podfile -- which is from GitHub page here because the version has been updated. I have also used the Swift 2.0 branch.
Below is the snapshop of the error, my pod file and my terminal post installing the pod
PODFILE
TERMINAL
P.S: I want to use cocoapods to install Alamofire. I don't want to download it from github page
The Trick for me was to open the .xcworkspace file rather then the original project file itself.
working this:
Scheme -> Manage Schemes...
checked Alamofire checkbox → Build Alamofire scheme
and, if you used Playground , you should change settings Playground:
View -> Utilities -> Show File Inspector
Platform OSX → iOS
Try this one.
For Swift 2.0 there is no need to add Alamofire.xcodeproj into your xcode. Simply copy and paste source folder from https://github.com/Alamofire and you are done.
or if you want to install Alamofire from Cocoapods then try below code.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 2.0'
import Alamofire after importing UIKit
Then comment it out, build the project first.
Uncomment it.
(this worked for me, and others, when the other answers did not).
For reference to anyone who comes across this problem in the future:
Swift 2.x + CocoaPods 1.x
Symptoms: build works in Xcode for debug configuration but fails when xcodebuild is executed from console using pod lib lint or similar command. The result is error: no such module 'X'
Solution:
In MyProject.podspec add your dependencies without specifying versions:
spec.dependency "Alamofire"
The Podfile should also contain the same dependencies. Then run:
$ pod install && open MyProject.xcworkspace
You should open .xcworkspace instead of .xcodeproj. The build will now work in both Xcode and console and pod lib lint passes validation.
I wrote this because I was trying to publish a new CocoaPods pod library and had a similar issue but found no answer and also because Google leads to this question.
Here is what to do:
close your project,
install your pod library,
then install alamofire.
After you do all things, don't open the file with extension .xcodeproj but open the file with extension .xcworkspace
My problem was solved using these steps :
Clean Project
Goto Project > Build Setting > Framework Search Path
and add
"$PODS_CONFIGURATION_BUILD_DIR/Alamofire" as non-recursive
$(inherited) as non-recursive
$(SRCROOT) as recursive
Adding Alamo Fire to all of my target's build phases fixed it for me.
There is only one way to solve this issue.
Quit Xcode.
Delete project's temp files located at
/Users/username/Library/Developer/Xcode/DerivedData
Delete ProjectName.xcworkspace
Delete Podfile.lock file and Pods folder Run pod install.
Open the newly created ProjectName.xcworkspace file and build.
credits to Dimitris Bouzikas here
Have been facing the same problem, following trick resolved the issue
Go to Manage scheme -> Select pod library that is causing issue -> Build
Change back the scheme to project and then run the app, you are good to go
Note: If you don't see the pod library in the scheme, go to Manage scheme and select the pod library that you would like to build.
After doing #satoshin answer, I also had to check the Shared box on the right hand side of the Manage Schemes window.
go to finder locate the project and navigate to the '.xcworkspace' file. thats where your pods are installed. if you go to your original project '.xcodeproj' you will only the pod debug files. hopes this helps. took me a while to figure out the problem too.
I am using swift 3, I fixed this problem by deleting Derived Data for this project.
Cheers...!!!
If clean project/restart xcode/reinstall cocoapods etc, did not work. You can try running Product -> Build for -> Testing (cmd + shift + u). The build failed but the import worked right after.
As for me worked to change the name of the project. Accidentally put
ProjectNameTests
instead of
ProjectName
No schemas needed if you've configured the names correctly everywhere:
Check Podfile
Check which project file you've launched.
(The white icon should be created for "xcworkspace")
Product -> Clean Build Folder
Product -> Build (Now you can run in a simulator).
Start from the scratch, because most of the errors always occur in a cause of humanity mistake, not developers.
If you've put the wrong name for project in Podfile check "Linked Frameworks...". If so - delete this framework. The path is showed below at screenshot.
Example of correct Podfile (Alamofire):
'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target 'ProjectName' do
pod 'Alamofire', '~> 4.7'
end
ProjectName should not contain any extensions(file types).
[For future seekers] you could have missed the second step from the below :
Go to Project Setting
Go to Build Phase tab, create a new run script phase and add an input file to your Alamofire framework. In my case I set $(SRCROOT)/Carthage/Build/IOS/Alamofire.framework
Go to General tab, scroll down to linked framework and libraries add Alamofire.Framework folder. You probably won't find it from list so you need to press "Add Other" button and introduce it yourself.
For absolute newbie just close xcode project and open by the new way.
Choose in your folder file which contains extension like this: .xcodeproj and just enjoy you life.
For me, solution was to exclude arm64 devices from Pods and Project.
Image is in attachment.
You can start by making sure you open the Xcode workspace file (with the extension .xcworkspace) instead of the project file (with the extension .xcodeproj). The workspace file contains dependencies installed by CocoaPods, and it is necessary to use it to work on your project.

Using link_with makes my project failed, CocoaPods 0.37

All my targets use the same libraries, so I use link_with to make my podfile neat. But to my surprise the project compiled failed. Xcode complains it can't find some files in pod, e.g.
diff: /../Podfile.lock: No such file or directory diff:
/Manifest.lock: No such file or directory error: The sandbox is not in
sync with the Podfile.lock. Run 'pod install' or update your CocoaPods
installation.
And
'DDLog.h' file not found
I run pod install again and clean xcode again and again. But no luck. I was not able to figure out why. From what I can see cocopods only changed shellScript for each target to one single Pods-resources.sh, which is what link_with is supposed to do, right?
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CloudPhone/Pods-"my target"-resources.sh\"\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
Is this a cocopods's bug? I am using latest one 0.37 and now I went back to specify each target individually.
Update:
CocoaPods 1.0 has removed link_with in favour of abstract_target
I think this is a pods bug. The pods doesnot update the script location, when a project specify target specific configuration initially and later tries to combine it.
To fix, go to Build phases->Embedd pod framework-> update the script file location to reflect the universal pod folder (like /Pods/Pods-frameworks.sh"). [You can navigate in finder to find exactly where the sh is present]. Remove any other script which doesn't reflect in physical folder. Now the project should compile.
Quick solution: remove Embed Pod Frameworks and run pod install again
Came across the same error. Just want to add to Sukitha's Answer.
Go to build phase -> Embed pod framework -> $SRCROOT
Be sure to check that this SRSCROOT file block correctly leads up to the frameworks.h file.
You will need to edit in order to correct issue.
Cheers

Resources