如何将第三方框架导入我的Swift项目?

时间:2023-01-23 17:29:47

I am trying to import the DDMathParser framework into my Swift app. I tried following the installation instructions from the DDMathParser wiki, though it did not work:

我正在尝试将DDMathParser框架导入我的Swift应用程序。我尝试遵循DDMathParser wiki中的安装说明,但它不起作用:

DDMathParser is packaged as a Swift framework.

DDMathParser打包为Swift框架。

Add DDMathParser.xcodeproj to your workspace and link MathParser.framework into your app.

将DDMathParser.xcodeproj添加到您的工作区并将MathParser.framework链接到您的应用程序。

(Link: https://github.com/davedelong/DDMathParser/wiki/Installing)

Here's what I did:

这是我做的:

  1. I dragged in the .xcodeproj file into my project (from Finder to Xcode), and the file shows up under my project in the sidebar.
  2. 我将.xcodeproj文件拖入我的项目(从Finder到Xcode),文件显示在我的项目侧边栏中。

  3. I went to my project settings and clicked the '+' under "Linked Frameworks and Libraries" and neither "MathParser.framework" or "DDMathParser.framework" are showing up in the list of available frameworks.
  4. 我转到我的项目设置并单击“链接的框架和库”下的“+”,“MathParser.framework”或“DDMathParser.framework”都没有显示在可用框架列表中。

  5. I tried building my application after adding the xcodeproj, but the framework files are still not showing up.
  6. 我在添加xcodeproj之后尝试构建我的应用程序,但框架文件仍未显示。

What am I doing wrong, or how do I correctly install this framework?

我做错了什么,或者我如何正确安装这个框架?

(Using Xcode 7.2.1)

(使用Xcode 7.2.1)

3 个解决方案

#1


0  

Navigate to your project using the "Terminal app" once at the root folder type pod init a Podfile will be created you can open it with nano Podfile and add these changes with updated paths to your specific project.

使用“终端应用程序”导航到您的项目一次在根文件夹类型pod init将创建一个Podfile,您可以使用nano Podfile打开它,并将这些更改添加到您的特定项目的更新路径。

source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'YOURPROJECT.xcodeproj'
platform :ios, '9.0'
use_frameworks!

pod 'DDMathParser'

Then save your file.

然后保存您的文件。

type pod install and hit enter.

键入pod install并按Enter键。

Now open your new .xcworkspace that was created. In any file that you want to use the DDMathParser framework just add import DDMathParser to the top of your file.

现在打开创建的新.xcworkspace。在任何要使用DDMathParser框架的文件中,只需将导入DDMathParser添加到文件的顶部即可。

#2


0  

1) $ sudo gem install cocoapods (gem will get installed in Ruby inside System library)

1)$ sudo gem install cocoapods(gem将安装在Ruby里面的System库中)

2) create a xcode project

2)创建一个xcode项目

3) Open terminal

3)打开终端

4) cd "path to your project root directory"

4)cd“项目根目录的路径”

5) pod init

5)pod init

6) open -e podfile (podfile will get open in text mode. Initially it will be emppty put the follwoing line of code.)

6)打开-e podfile(podfile将在文本模式下打开。最初它将是emppty放下以下代码行。)

7) pod 'DDMathParser' (Cocoapods Podfile name ) // This is example

7)pod'DDMathParser'(Cocoapods Podfile名称)//这是一个例子

8) pod install

8)pod安装

CocoaPods 0.36 and above will support for swift

CocoaPods 0.36及以上将支持swift

#3


0  

Try the following as it helped me a lot of times:

尝试以下操作,因为它帮助了我很多次:

  1. Create a workspace eg. I named it Beacon
  2. 创建工作区,例如。我把它命名为Beacon

  3. Create a project in it e.g. I create a project named BeaconDemo
  4. 在其中创建一个项目,例如我创建了一个名为BeaconDemo的项目

  5. Create a Podfile in the folder where you created the workspace
  6. 在创建工作区的文件夹中创建Podfile

  7. The contents of Podfile :

    Podfile的内容:

    workspace 'Beacon'

    xcodeproj 'BeaconDemo/BeaconDemo.xcodeproj'

    platform :ios, '8.0'

    平台:ios,'8.0'

    use_frameworks!

    pod 'NearbyMessages', '~> 0.9'

    pod'NearlyMessages','〜> 0.9'

    pod 'EstimoteSDK', '~> 3.8'

    pod'EstimoteSDK','〜> 3.8'

    pod 'Charts', '~> 2.2'

    pod'图表','〜> 2.2'

    pod 'GoogleMobileAds', '~> 7.6'

    pod'GoogleMobileAds','〜> 7.6'

  8. Open terminal and go to your workspace

    打开终端并转到您的工作区

  9. Hit pod install
  10. 点击pod安装

  11. Then open the workspace that you have created e.g. over here as in step 1
  12. 然后打开您创建的工作区,例如在这里和第1步一样

#1


0  

Navigate to your project using the "Terminal app" once at the root folder type pod init a Podfile will be created you can open it with nano Podfile and add these changes with updated paths to your specific project.

使用“终端应用程序”导航到您的项目一次在根文件夹类型pod init将创建一个Podfile,您可以使用nano Podfile打开它,并将这些更改添加到您的特定项目的更新路径。

source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'YOURPROJECT.xcodeproj'
platform :ios, '9.0'
use_frameworks!

pod 'DDMathParser'

Then save your file.

然后保存您的文件。

type pod install and hit enter.

键入pod install并按Enter键。

Now open your new .xcworkspace that was created. In any file that you want to use the DDMathParser framework just add import DDMathParser to the top of your file.

现在打开创建的新.xcworkspace。在任何要使用DDMathParser框架的文件中,只需将导入DDMathParser添加到文件的顶部即可。

#2


0  

1) $ sudo gem install cocoapods (gem will get installed in Ruby inside System library)

1)$ sudo gem install cocoapods(gem将安装在Ruby里面的System库中)

2) create a xcode project

2)创建一个xcode项目

3) Open terminal

3)打开终端

4) cd "path to your project root directory"

4)cd“项目根目录的路径”

5) pod init

5)pod init

6) open -e podfile (podfile will get open in text mode. Initially it will be emppty put the follwoing line of code.)

6)打开-e podfile(podfile将在文本模式下打开。最初它将是emppty放下以下代码行。)

7) pod 'DDMathParser' (Cocoapods Podfile name ) // This is example

7)pod'DDMathParser'(Cocoapods Podfile名称)//这是一个例子

8) pod install

8)pod安装

CocoaPods 0.36 and above will support for swift

CocoaPods 0.36及以上将支持swift

#3


0  

Try the following as it helped me a lot of times:

尝试以下操作,因为它帮助了我很多次:

  1. Create a workspace eg. I named it Beacon
  2. 创建工作区,例如。我把它命名为Beacon

  3. Create a project in it e.g. I create a project named BeaconDemo
  4. 在其中创建一个项目,例如我创建了一个名为BeaconDemo的项目

  5. Create a Podfile in the folder where you created the workspace
  6. 在创建工作区的文件夹中创建Podfile

  7. The contents of Podfile :

    Podfile的内容:

    workspace 'Beacon'

    xcodeproj 'BeaconDemo/BeaconDemo.xcodeproj'

    platform :ios, '8.0'

    平台:ios,'8.0'

    use_frameworks!

    pod 'NearbyMessages', '~> 0.9'

    pod'NearlyMessages','〜> 0.9'

    pod 'EstimoteSDK', '~> 3.8'

    pod'EstimoteSDK','〜> 3.8'

    pod 'Charts', '~> 2.2'

    pod'图表','〜> 2.2'

    pod 'GoogleMobileAds', '~> 7.6'

    pod'GoogleMobileAds','〜> 7.6'

  8. Open terminal and go to your workspace

    打开终端并转到您的工作区

  9. Hit pod install
  10. 点击pod安装

  11. Then open the workspace that you have created e.g. over here as in step 1
  12. 然后打开您创建的工作区,例如在这里和第1步一样