Using Cocoapods in Xcode 7.3

感情迁移 提交于 2019-12-24 15:42:42

问题


I installed Cocoapods using the terminal and everything went well, but I cant seem to figure out how to integrate it into my Xcode project. I change the directory to the main folder that contains the Xcode project and type $ pod init which creates an initial Podfile in the Xcode project folder. Then I open the Podfile in Xcode and make it look like this:

platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
  pod "ForecastIO"
end

Next, I go back to the terminal and type $ pod install and everything goes well. The problem is none of the files show up in the project directory inside of Xcode, yet they are in the Finder folder that contains all the project files. I tried dragging the new files into the project directory manually, but some of them still do not show up and the syntax for the Podfile code is not highlighted. Also doesn't allow me to import the cocoapod that it supposedly just installed. I am new to all of this and I'm probably missing something simple, but I cannot figure it out. Any help is appreciated.

Tl;dr How to implement ForecastIO Cocoapod into an Xcode project?

Lint to ForecastIO Pod Info: https://cocoapods.org/pods/ForecastIO


回答1:


Your opening the YourProjectHere.xcodeproj when you need to be opening the YourProjectHere.xcworkspace

  1. Create a new project in Xcode

  2. Go into your terminal and run this command from the same folder that your YourProjectHere.xcodeproj is located in

    $ pod init
    
  3. Edit your Podfile
  4. Run this command from the same folder that your YourProjectHere.xcodeproj is located in

    $ pod install
    
  5. A workspace should now be created. Run this command from the same folder that your YourProjectHere.xcodeproj is located in

    $ open YourProjectHere.xcworkspace/
    



回答2:


When you integrate a pod and a subsequent podfile to use with your project, it works alongside your application, not embedded within it anymore. Therefore, you will have to use the workspace file (the white one, not the blue) from here on out. It's a higher scoped file, because it encompasses both your project and the pods directory as a project.

It's common practice to close your application anyway when doing a pod install, and reopen the workspace afterwards. Some people have issues immediately importing a pod, so I would also build first with the pod installed, and then build again with the import statement.




回答3:


I know its too late to reply but I don't see any confirmed Answer for this question yet. In my case I've two versions of Xcode viz. 7.3.1 & 8.2.1 (for some reason I've to maintain it as my code is in Swift 2.3 and I'm using a couple of libraries). So when I tried to run pod install, the pods were getting downloaded and I could see them in Finder but the command was not Generating any WorkSpace file. I googled and landed on this question but I didn't find anything here that helped me get through the issue.

  • Well, I found the solution myself..
    1. In Xcode, Go to Preferences >> Locations
    2. Select proper version of Xcode in Command Line Tools
    3. Run pod install command in terminal

Voila, the workspace file gets generated!! :)

I hope this helps someone who has same issue. Cheers.



来源:https://stackoverflow.com/questions/36481926/using-cocoapods-in-xcode-7-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!