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.
Related
React Native Firebase installation for iOS gets held up at the "Run your app to verify installation" screen.
React Native Firebase has worked on Android for me before.
I followed these instructions.
https://rnfirebase.io/docs/v5.x.x/installation/ios
https://firebase.google.com/docs/ios/setup#add_the_sdk
Here are what I've done so far.
-Set up a project within Firebase.google.com page.
-Create an iOS app there.
-Install react-native-firebase via npm.
-Add GoogleService-Info.plist file to the project within XCode.
-Make changes to ios/[YOUR APP NAME]/AppDelegate.m file.
-Creat a new Podfile (Cocoa pod) and updated it by "pod update" command.
-Add and edited lines to the Podfile per the instruction.
-Run "pod install"
-Run "react-native link react-native-firebase" from the project root.
-Click "Next" button within Firebase console and move on to "Run your app to verify installation" section.
-Run the iOS app on simulator by running "react-native run-ios" command.
The app boots up and functions as normal in the simulator.
Nothing happens in the Firebase page.
This is the first couple of lines of my Podfile.
# Uncomment the next line to define a global platform for your
project
platform :ios, '9.0'
# Required by RNFirebase
pod 'Firebase/Core', '~> 5.20.1'
target 'My_App_Name' do
https://dev-yakuza.github.io/en/react-native/react-native-firebase-admob/
Check this guy's blog. In his particular case, he is integrating Firebase and Admob, but the first part is really descriptive on how to install and set the RNFirebase package.
I found the partial answer to this thanks to #Mike Hardy in the other thread here:
Error message - RNFirebase core module was not found natively on iOS
For the most part, you can trust the official instruction on this page.
https://rnfirebase.io/docs/v5.x.x/installation/initial-setup
However. There are a few things that are not articulated there you’d need to follow in order to install React Native Firebase on iOS.
I followed the below steps and I managed to get it through the infinite “Verify installation” loop.
-1) Comment out the following lines from your Podfile. You might see the same line in two locations. Comment out all of them.
use_frameworks!
-2) Also comment out a couple of lines just BEFORE the very last end in your Podfile. Once you’ve done this, you will only see one instance of end at the last line.
target ‘YourProjectName-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
-3) Insert the following line just before the final end.
system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")
-4) And then, run pod install and pod update from your terminal.
-5) Go to Xcode, Check the Build Phases/ Link Binary with Libraries section. Confirm that libRNFirebase.a is already there.
-6) Go to Xcode, select a device of your choice and hit “Run”*
*If you use the command from terminal, it will no longer open your app in the simulator. I don’t know why. But it looks as if once React Native Firebase is installed, the only way to test your app is through the Xcode.
react-native run-ios
**Please note I’ve only verified it with the ‘Firebase/Core’ pod. When I tried to add ‘Analytics’ or ‘AdMob’ module in the Podfile, it crashed.
The problem for me was that my GoogleService-Info.plist was actually from a different firebase project, so it had the wrong project id, bundle id, etc.
FOR REACT NATIVE
So I had the same problem and silly me I put the GoogleService-Info.plist file in the wrong place...
It needs to go directly in the /ios folder!
You need to include necessary modules in your Podfile.
Here is my Podfile
pod 'Firebase/Core', '~> 6.3.0'
pod 'Firebase/Messaging', '~> 6.3.0'
pod 'Firebase/AdMob', '~> 6.3.0'
Note that I had to manually change framework path of GoogleMobileAds with XCode to value $(SRCROOT)/../../../ios/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current in RNFirebase.xcodeproj file in Librairie > Build Settings > Framework Search Paths
I don't know if this works for you but this is what I did.
I backed up my files. created a new project.
Ran pod init and pod install on a fresh project with no code.
After this I closed Xcode and ran $ sudo gem install cocoapods --pre in the same terminal window.
Finally in terminal that I ran pod install and pod update again.
At this point I reopened my fresh project and reconnected my files.Worked like a gem.
I fought with this for probably 12 hours on my new Mac Book Pro.
You probably do not have the latest version of Firebase in your Pods.
Open your Pod file and add this before the "end" statement:
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
Go to Terminal and cd to your root folder of the Xcode project.
Now, type "pod install" and hit enter. This should update your Firebase SDK and build the latest version of Firebase when you build your app.
Note: You should also delete your app on Simulator and re-install it for the changes to take effect.
I'm doing the Ray Wenderlich tutorial called SimpleWeather.
The podfile is in the same folder as the project.
Here's my code from the podfile:
platform :ios, '7.0'
xcodeproj 'SimpleWeather'
pod 'Mantle'
pod 'LBBlurredImage'
pod 'TSMessages'
pod 'ReactiveCocoa'
The error message is this: [!] Unable to find the Xcode project /Users/myName/Developer/SimpleWeather.xcodeproj for the target Pods.
The name of the project is SimpleWeather.
I'm pretty sure you are not in the right directory. Are you sure your .xcodeproj is in the Developer folder? There might be a subfolder you need to navigate to.
The right way to enable CocoaPods in your Project is:
Open Terminal and execute: $ sudo gem install cocoapods
Navigate to your Project folder (I assume in your case it's cd /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj).
Setup Cocoapod pod setup
Create the Podfile touch Podfile
Open the Podfile open -e Podfile and insert your code for Podfile
Finally install the Podfile pod install
If you follow this instructions everything should work. When opening your project make sure to open the .xworkspacefile.
For more information, see this.
This error also occurs when you have multiple .xcodeproj in your Xcode project.
You don't need more than one .xcodeproj in general cases. Remove unnecessary .xcodeproj, and Cocoapods should get the correct path automatically afterwards.
Reiterating our original conversation:
Accordingly to Podfile Syntax Reference the Podfile looks right.
Make sure you are running $pod install from your project directory:
/Users/myName/Developer/SimpleWeather
Hey your path for the project might be wrong. Go to the project and right click on SimpleWeather.xcodeproj and select Get Info as show in the image below(The right side window is for Get Info here). Copy this path from the details window and paste it into the Podfile. After that append /SimpleWeather.xcodeproj to that pasted path. This might solve the problem(Note: It is a snap shot for my project). In your case the solution might be replacing the path with this /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj
To solve this issue, just follow below steps and your issue will get resolved :
Step 1 : Open Terminal and navigate to your project folder
Step 2 : touch podfile
Step 3 : open -e Podfile
Step 4 : Write below line in your text edit and close it
workspace '/Users/systemName/Developer/yourprojectname/yourprojectname.xcworkspace'
Step 5 : Pod install
And after successful process, you will not get this error again.
CheersKP
Maybe you have two project .xcodeproj, remove one.
Remove Podfile.lock, folder Pods. On Terminal cd /Users/myName/Developer/SimpleWeather and pod install
For people who are on Mac and also using code editors, the duplicate file that is causing this issue is ._projectname.xcodeproj because it has the same extension as the regular .xcodeproj files.
I had the same problem.
Then with many attempts of trials and errors I finally got the working solution:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'SimpleWeather'
pod 'Alamofire', '~> 3.4'
This works when you are in your project directory (I assume you should navigate using terminal to /Users/myName/Developer/SimpleWeather/)
You installed your Xcode..in application use this command to execute
sudo xcode-select -switch /Applications/Xcode.app
so okay i had tried every possible thing ...i had only one .xcodeproj file
but sill i couldnt install so finally i had tried with the following
1. open terminal cd to your project folder one with .xcodeproj
2. type pod init
3. type touch Podfile
4. type pod install
Magic happens and your pod files gets installed
Check your Podfile for the following lines
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
under
target '<project_name>' do
Hopefully this answer can be useful in times of many people using SPM. My case was the following: I had a binary framework package that had to be converted to the cocoapod, together with it's dependency tree. In the git repository where the package lived, the .gitignore file contained this line: /*.xcodeproj. This meant that even though everything worked fine locally, whenever the CI tried to run pod install it failed.
I am a newbie when it comes to CocoaPods so please bear with me!
I am looking at the tutorial (https://www.raywenderlich.com/97014/use-cocoapods-with-swift) however this is using the dependency "pod 'Alamofire', '2.0.2'". I have looked online for over a hour now and I can't find what to use for the Charts framework (https://cocoapods.org/?q=charts).
So Far i have done the following steps:
1.
sudo gem install cocoapods
and got the following output:
2.
pod setup --verbose
and got the following output:
3.
open -a Xcode Podfile
and got the following result :
4.
Uncommented "use_frameworks!" and uncommented "platform :ios, '6.0'" and changed it to "platform :ios, '9.0'"
Now i am stuck as i don't know what dependancies i need to use for the charts framework. Apologies if this is a very simple answer!
Thanks in advanced for your help :)
EDIT: After installing the pod files i dragged the 'Charts.xcodeproj file into my project.
When i try and embed binaries i have various options:
When i add them and build i get the following errors:
Hey First you have to decide which chart library You want to use.
Something like this https://github.com/danielgindi/ios-charts
for above chart library you have to use
pod 'Charts'
in your pod file inside the project .
Now your pod file will be something like this
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Charts'
Now open the terminal and go to your project directory and enter the command
pod install
and you are good to go.
Hope this help you.
Usually there are instructions on what CocoaPod name to use for installation on the GitHub or source code hosting page of the library.
After a pod install command under your correct project directory, you need to exit out of your .xcodeproject and open up the workspace file. This is what you do from now on after a project has a cocoapod dependency. The workspace now contains both your project, and the pods project as a package manager. The pod(s) you installed are there, and must be accessed by importing the name of the CocoaPod (can be seen in folder drop down view in the Pods project).
You do not need to drag anymore files in your own project or embed like before. Make sure to delete those.
If you're still having trouble, can you edit what your current podfile looks like?
I'm doing the Ray Wenderlich tutorial called SimpleWeather.
The podfile is in the same folder as the project.
Here's my code from the podfile:
platform :ios, '7.0'
xcodeproj 'SimpleWeather'
pod 'Mantle'
pod 'LBBlurredImage'
pod 'TSMessages'
pod 'ReactiveCocoa'
The error message is this: [!] Unable to find the Xcode project /Users/myName/Developer/SimpleWeather.xcodeproj for the target Pods.
The name of the project is SimpleWeather.
I'm pretty sure you are not in the right directory. Are you sure your .xcodeproj is in the Developer folder? There might be a subfolder you need to navigate to.
The right way to enable CocoaPods in your Project is:
Open Terminal and execute: $ sudo gem install cocoapods
Navigate to your Project folder (I assume in your case it's cd /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj).
Setup Cocoapod pod setup
Create the Podfile touch Podfile
Open the Podfile open -e Podfile and insert your code for Podfile
Finally install the Podfile pod install
If you follow this instructions everything should work. When opening your project make sure to open the .xworkspacefile.
For more information, see this.
This error also occurs when you have multiple .xcodeproj in your Xcode project.
You don't need more than one .xcodeproj in general cases. Remove unnecessary .xcodeproj, and Cocoapods should get the correct path automatically afterwards.
Reiterating our original conversation:
Accordingly to Podfile Syntax Reference the Podfile looks right.
Make sure you are running $pod install from your project directory:
/Users/myName/Developer/SimpleWeather
Hey your path for the project might be wrong. Go to the project and right click on SimpleWeather.xcodeproj and select Get Info as show in the image below(The right side window is for Get Info here). Copy this path from the details window and paste it into the Podfile. After that append /SimpleWeather.xcodeproj to that pasted path. This might solve the problem(Note: It is a snap shot for my project). In your case the solution might be replacing the path with this /Users/myName/Developer/SimpleWeather/SimpleWeather.xcodeproj
To solve this issue, just follow below steps and your issue will get resolved :
Step 1 : Open Terminal and navigate to your project folder
Step 2 : touch podfile
Step 3 : open -e Podfile
Step 4 : Write below line in your text edit and close it
workspace '/Users/systemName/Developer/yourprojectname/yourprojectname.xcworkspace'
Step 5 : Pod install
And after successful process, you will not get this error again.
CheersKP
Maybe you have two project .xcodeproj, remove one.
Remove Podfile.lock, folder Pods. On Terminal cd /Users/myName/Developer/SimpleWeather and pod install
For people who are on Mac and also using code editors, the duplicate file that is causing this issue is ._projectname.xcodeproj because it has the same extension as the regular .xcodeproj files.
I had the same problem.
Then with many attempts of trials and errors I finally got the working solution:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'SimpleWeather'
pod 'Alamofire', '~> 3.4'
This works when you are in your project directory (I assume you should navigate using terminal to /Users/myName/Developer/SimpleWeather/)
You installed your Xcode..in application use this command to execute
sudo xcode-select -switch /Applications/Xcode.app
so okay i had tried every possible thing ...i had only one .xcodeproj file
but sill i couldnt install so finally i had tried with the following
1. open terminal cd to your project folder one with .xcodeproj
2. type pod init
3. type touch Podfile
4. type pod install
Magic happens and your pod files gets installed
Check your Podfile for the following lines
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
under
target '<project_name>' do
Hopefully this answer can be useful in times of many people using SPM. My case was the following: I had a binary framework package that had to be converted to the cocoapod, together with it's dependency tree. In the git repository where the package lived, the .gitignore file contained this line: /*.xcodeproj. This meant that even though everything worked fine locally, whenever the CI tried to run pod install it failed.
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.