简体   繁体   English

将JWTDecode添加到现有的iOS项目中,找不到框架

[英]adding JWTDecode to existing iOS project, framework not found

I have an existing iOS project, and now the times has come to authenticate the users in the apps share extension. 我有一个现有的iOS项目,现在是时候对应用程序共享扩展中的用户进行身份验证了。 For this I need to decode a JWT to see if it is expired or not. 为此,我需要解码JWT以查看其是否过期。 I'm used to use jwt with javascript and jwt-decode from npm. 我习惯将jwt与javascript和nwt的jwt-decode一起使用。 For iOS i believe the equivalent to npm is cocoapods ? 对于iOS,我相信相当于npm的是cocoapods吗?

I have found this module: https://github.com/auth0/JWTDecode.swift that claims do do exactly what I need. 我找到了这个模块: https : //github.com/auth0/JWTDecode.swift ,声称确实可以满足我的需求。 It even comes with an install guide which explains how to install with cocoapods. 它甚至附带安装指南,该指南说明了如何使用cocoapods进行安装。

I have follwed these steps to install cocoapods: 我遵循了以下步骤来安装cocoapods:

Afther that I tried to install the package: 在我尝试安装该软件包之后:

  • cd my-ios-prject
  • pod init - this created a Podfile pod init init-这创建了一个Podfile
  • in the podfile I added pod 'JWTDecode', '~> 2.3' 在podfile中,我添加了pod 'JWTDecode', '~> 2.3'
  • pod install this downloaded: Using JWTDecode (2.3.0) pod install此下载文件:使用JWTDecode(2.3.0)

I went to Xcode and tried to build the project but im getting the error:ld: framework not found JWTDecode which I find confusing, because I didn't even import the lib anywhere yet, I only installed it exactly how the guide said so. 我去了Xcode并尝试构建该项目,但是却收到error:ld: framework not found JWTDecode ,这让我感到困惑,因为我什至还没有导入lib,我只是按照指南的指示安装了它。

This is what my podfile looks like: 这是我的podfile的样子:

target 'appname' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for appname

  target 'appnameTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'appname-share' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  pod 'JWTDecode', '~> 2.3'
  # Pods for appname-share

end

target 'appname-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for appname-tvOS

  target 'appname-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

I only want to use the JWTDecode lib inside the share extension which is why I added it under target 'appname-share' do 我只想在共享扩展名内使用JWTDecode lib,这就是为什么我在target 'appname-share' do下添加它的原因

Please cut me some slack and spare me from "this is duplicate" shaming, I read all the tops posts and they do not solve my issue. 请给我一些懈怠,并避免我遭受“这是重复的”羞辱,我阅读了所有热门文章,但它们不能解决我的问题。 Deleting .framework files doesn't do anything. 删除.framework文件不会执行任何操作。 I have also checked and confirmed that in my project -> target -> build phase -> link binaries that pods_appname.framework is listed. 我还检查并确认在我的project -> target -> build phase -> link binaries中列出了pods_appname.framework。

After installing the pod you have to close the ProjectName.xcodeproj and open and use ProjectName.xcworkspace. 安装Pod之后,您必须关闭ProjectName.xcodeproj,然后打开并使用ProjectName.xcworkspace。 In that you can see all your pods too. 这样您也可以看到所有吊舱。 Got to build phases add the libraryName.a to your linked frameworks and libraries and then, clean and build. 进入构建阶段,将libraryName.a添加到链接的框架和库中,然后清理并构建。 It wouldn't throw any error. 它不会抛出任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM