How to convert framework in a cocapod? - objective-c

I have create new cocoa-pod with an example project which in original project used a framework (X.framework).
So it was like:
Original_Proj
|- four Classes (A,B,C,D{.h,.m})
|-Main.m
|- etc by default xcode project files
|-X.framework
Now those four classes imported the X.framework and used its functionality. (Purpose being only few classes of framework exposed project).
========================================================================
Now in a xcworkspace created by cocoapod, i have added all the Four classes and other necc. files in EXAMPLE folder but now i want the X.framework to be as Development pod so i can import it in those Classes in cocoapod embed project.
Following is my Cocopod project structure
Now i wanted to ask whether i have to put the complete framework it self in Dev. pods folder OR all X.framework's source files in Dev. pods folder. Will it expose those files to others if they install the pod in their project? Please guide with proper way if I am doing something wrong? Detail explanation would be really appreciated.

Remove that pod. follow the below steps
1) Open terminal
2) sudo gem install cocoapods (gem will get installed in Ruby inside
System library)
3) pod setup
4) create a xcode project
5) cd "path to your project root directory"
6) pod init
7) open -a Xcode Podfile (podfile will get open in text mode. Initially it will be empty put the following line of code.)
8) pod frame_name veraion (It’s finally time to add your first dependency using CocoaPods! Copy and paste the following into your pod file, right after target "Project" do:)

Related

Putting Pod installed project inside another project of Xcode.

I have to put projB inside ProjA. Both projects has installed pods. Also, projB is a Objective C project and ProjA is a Swift project. Could anyone please let me know how to do it.
I have tried This soultion. But It's not working.
as far as I know any project should only have one pod file, so u can copy the content of projectB's podFile ( not the whole content but the pods' names to project A's pod file , and then run pod install
First of all you should check pod versions. after that you can copy Project A podfile to B Project. You cant Use Both project pod files into one project as i think.

Error: RNFirebase core module was not found natively on iOS

I created a new app and I am trying to use react-native-firebase. But I continually get this error:
RNFirebase core module was not found natively on iOS, ensure you have
correctly included the RNFirebase pod in your projects 'Podfile' and
have run 'pod install'.
See http://invertase.link/ios for the ios setup guide.
Steps that I have done:
yarn add react-native-firebase
react-native link react-native-firebase
Set up my .plist file from Google under .../myproject/ios/myproject
Ran pod updateafter ensuring I was using Ruby 2.5.0
Ran pod install
The pod file that I am currently using is:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'MyProject' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Messaging'
target 'MyProjectTests' do
inherit! :search_paths
# Pods for testing
end
end
These are the versions that I am using:
"react": "^16.3.0-alpha.1",
"react-native": "0.54.2",
"react-native-firebase": "^3.3.1",
If you don't want to manually link, you can try installing RNFirebase as a pod install directly:
pod 'RNFirebase', :path => 'path/to/node_modules/react-native-firebase/ios'
Changing or hardcoding HEADER_SEARCH_PATHS did not help me. When the error recurs, it's not necessary to rm -rf node_modules nor delete the pod file etc, I found it useful to clear the cache.
I always prefer not to use pods with react native, however, the react-native-firebase's instructions for the non-pop installation will not work.
The reason for this is the package's search paths which assumes either /pods or /firebase
Hence, to make it link properly follow these steps:
download firebase sdk
make a folder directly under ios and call it Firebase, copy the frameworks needed of the sdk in that folder WITHOUT keeping the sub-folders (note, you have not entered XCode yet)
If you haven't already npm install -s react-native-firebase
Open XCode and drag and drop the desired frameworks to the Frameworks-folder in XCode (Eg. in my example the contents of the Analytics, Messaging and DynamicLinks folder). Do not copy items when asked as you already have then in the Firebase subfolder of ios:
In XCode right-click Libraries and select "Add files to [project]". Find RNFirebase-project in node_modules and select the RNFirebase.xcodeproj, do not "copy items"
In Project/Target settings go to Linked Frameworks and Libraries. Find and add libRNFirebase.a
In AppDelegate.m make adjustments as per the instructions from react-native-firebase, eg: import <Firebase.h> and [FIRAPP configure]; in didFinishLaunchingWithOptions
In Header Search Paths AND Framework Search Paths, add $(PROJECT_DIR)/Firebase
Don't forget to add you GoogleServices-Info.plist to your project
I had the same problem, while trying to fix it was making my app to crash on start up.
I moved it through the terminal under the ios/AppFolder/ but the Xcode was never aware of this file.
What helped me was to open my project in Xcode. Then left-click on my AppFolder > Add Files and then add the GoogleService-Info.plist.
I manually linked these react-native-firebase/* packages with
react-native link #react-native-firebase/xxx
"#react-native-firebase/analytics","#react-native-firebase/app","#react-native-firebase/auth","#react-native-firebase/crashlytics","#react-native-firebase/messaging"
which generated pod spec in pod and it worked.

Can I Copy Over React Native Files Initialized Under One Project Over To Another Separately Initialized Project?

Let's say I initialize a project under react-native init <filename>, installed a bunch of node packages, and added code.
Then separately I initialize a different project under react-viro init <filename>, installed a bunch of node packages, and added code.
If I wanted to combine what I created under react-native init into what I created under react-viro init, is it as simple as copying files over and reinstalling missing node packages into the react-viro project?
Assuming you are working in the ./src folder, every file is independent of iOS or Android as part of the JavaScript bundle.
You can simply copy the .js files over and install the node packages in that project.
You probably should not copy any files that are outside the ./src folder, but I also suspect you wouldn't need to. Files in the Android and iOS folders are rarely touched as they contain operating system config settings and custom modules that you would have wrote in the native languages.
If the file renders JSX, you will be safe to just copy it over and hook it back up.
To state it another way, go into the folder that has node_modules in it. You shouldn't copy anything that is in that folder except additional files that you created. This is where people normally create an src folder and place all their JavaScript. You probably have an index file in there that points to ./src/app.js or you may have an index.ios.js and index.android.js that both point to a ./src/app.js. Anything inside src is safe.
That's my best answer without seeing your folders and files.
If you intend to copy code from one react native project to another, make sure the code you intend to copy is JS and not any native files. Make sure you do register the correct component using AppRegistry. Rest assured you can copy the code from one project to another.
Assuming you have a project at folder
/my-project/android
/my-project/ios
/my-project/src
Copy my-project and paste it at your desired folder like
/new-my-project
Change git origin
git remote set-url origin https://gitlab.com/..../**.git
Open /new-my-project/android in Android Studio, and then rename app/java/com.myproject to com.newmyproject
Go to app/build.grade and change com.myproject to com.newmyproject and sync
Create firebase project and download google-services.json file and add to new-my-project/android/app
Build application, then test application under metro bundler
npx react-native start
Create keystore, test notifications, change base_url_api, test apk etc Android finish now, iOS
Update pods on new-my-project/ios
pod install && pod update
open myproject.xcworkspace
Change bundle identifier to org.reactjs.native.newmyproject, version to 1.0, build to 1 and desired Display name. Let it index completely
Setup in firbase and replace GoogleService-Info.Plist file and Clean build folder in xcode
Go to developer.apple.com and create identifiers, APNS certificates, profiles
Download certificates from keychain and upload to firebase
Build the project in simulator/device and test it.
Done

How to ignore untracked files when using CocoaPods?

I have a simple project and wanted to include a third party library (CocoaLumberjack) using CocoaPods. After creating the simple Podfile I ran pod install in my project directory. Everything worked fine, except I now have untracked files in my project that are marked with question marks in Xcode:
Is this how it's supposed to be? I don't remember having these question marks when I last used CocoaPods in a different project. Shouldn't CocoaPods automatically set up the correct gitignores for the pods?
CocoaPods doesn't do anything with your .gitignore.
I recommend using GitHub's Objective-C .gitignore (at least as a starting point). Alternatively, just make sure you ignore the Pods directory by adding an entry for Pods in your ignore file:
# CocoaPods
Pods

How to add GitHub's Mantle to Xcode using CocoaPods

I have added GitHub's Mantle project to a iOS 6 project using CocoaPods:
$ pod search Mantle
$ vim Podfile // here I added pod 'Mantle'
$ pod install // this installs Mantle 1.0
Then I have added the ($inherited) variable to the Header Search Paths of project's 'Build Settings' section, before my custom search paths. When importing the Mantle header file Xcode complains with
#import "Mantle.h" // => 'Mantle/MTLJSONAdapter.h' file not found
Am I missing some step? I have other pods installed as well (AFNetworking and SSKeychain) but only Mantle is giving me issues.
I have also added SSToolkit but following the instructions on its 'Getting started', i.e. not using CocoaPods.
Since the problem seemed to be related with the Xcode project/workspace configuration I tried all kind of 'cleaning' solutions:
Delete the Pods directory, the Podfile.lock file and install everything from scratch.
Delete the MyProject.xcworkspace directory and repeat step 1
Enter MyProject.xcodeproj, delete project.xcworkspace and xcuserdata directories and repeat step 1.
Go to the global Xcode directory (/Users/my_user/Library/Developer/Xcode), remove everything related to the project, specially the DerivedData subdirectory, and repeat step 1.
The final step seems to be the final solution, though I cannot tell which file/folder removal did the trick.
Have you added Mantle to your Podfile? You mention running pod install Mantle which doesn't/shouldn't do anything but show an error. ([!] Unrecognized argument:Mantle'`)
After you add Mantle to your Podfile and run pod install you should be able to link Mantle.h directly and there will be a few directories in your xcworkspace and the Pods project. After this you can use #import "Mantle.h" no issues.
I had the same problem, but the problem appears to simply be that my Mantle pod was too old. Changed version to '2.0.5' and pod updated, things work fine.