可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am running XCode 7, Swift 2.0, iOS 9.
I want to install Alamofire in my project using Cocoapods. I have done the following:
gem install cocoapods
pod setup
pod init
Updated Podfile to:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
use_frameworks!
target 'JSONeg' do
pod 'Alamofire', :branch => 'swift-2'
end
Then I installed the pod:
pod install
And I added the following to ViewController.swift
import Alamofire
This raises the following error:
Cannot load underlying module for 'Alamofire'
I tested with another pod and it raised the same error, so I guess the problem is with the installation of Cocoapods. Any help would be greatly appreciated.
回答1:
This seems to be a bug in XCode. I had the same problem, and as described in the comments of another answer to this question, building the project made the error go away.
回答2:
Go to Product > Build and it will resolve the problem:
回答3:
Cannot load underlying module for 'x'for SWIFT :
How to fix the Issue:
step:1 Create a New project and build&run Successfully without installing pod.
step:2 After build&run the Project Successfully ,Now try to install pod and then try to importrealm,alamofire,charts etc it will work like a charm.
Failure Case --> New project -> Add (realm,alamofire,charts etc) via cocoapods w/o building first -> open Xcode workspace -> build&run
Success Case -->New project -> build&run -> add (realm,alamofire,charts etc)via cocoapods -> open Xcode workspace -> build&run again = success
回答4:
This worked for me:
- Close your project
- In terminal go to your project directory
- Add this command: pod update
- After that all your pods will be updated. Just run your project
回答5:
Once you have installed Alamofire pod.
Step.1 you should open your project by double click on your_project_name.xcworkspace file.
Step.2 Go to project settings --> Build Phases --> Link Binary with Libraries --> Add framework "Alamofire.framework"
Thats it!!
Now you can import the module
回答6:
What has helped in my case:
1) Close the project and XCode
2) In the terminal repeat command
> pod install
3) Open the project
(If it does not help, try to remove Pod/ folder before reinstalling)
回答7:
I tried all of these solutions: Re-building, Cleaning, Re-installing the pods, etc., but In my case, it was a problem of changing my 'Build Active Architecture Only' setting to 'No', due to an AR library I was using. Changed it back to 'Yes' and it was fixed. Hope this helps somebody.
回答8:
I am on Xcode Version 8.3.1 (8E1000a). Somehow this problem occurs when I wanted to pod install SwiftCloudant module. Probably I did not close my Xcode when I run pod install.
I fixed this manually adding the SwiftCloudant.framework in the Targets > General tab.
Targets > General > Linked Frameworks and Libraries
回答9:
I had to do a Product > (Opt Click) Clean Build Folder ... then ran again and the issue was gone.
回答10:
Have you checked if you have a recent version of Cocoapods ? You can update by either updating all your gems :
sudo gem update
or just reinstall Cocoapods:
[sudo] gem install cocoapods
If that doesn't help take also a look at : CocoaPods - build for iOS 9 / Swift 2 with Xcode-beta
where is shows you how to easily change the Command-Line tools version in the Xcode Preferences "Locations" tab, and change "Command Line Tools" to Xcode 7.0.
回答11:
Could not load underlying module
- Check framework path:
Build Settings -> Framework Search Paths
.
- Make sure the path to a framework contains no space.
- If the path contains a variable, find the value of the variables by searching the variable name in your
Build Settings
.
- Make sure the value of the variables contains no space.
- If the path contains spaces, rename those directories that contain spaces.
- Clean and build the project.
In summary, make sure your <Project Root>
path contains no space. Otherwise, rename the dir
that contains spaces, then clean and build your project.
e.g. If this is your project root: /Users/handsomeboy/ios app/Fancy App/
, rename the folder that has spaces. One way to get rid of the space: change 'ios app'
to 'ios_app'
回答12:
Follow the steps:
1.Install pods
2.Open workSpace
3.Run/build your application
4.Then you can import the framework
回答13:
Same issue for me.
I solved that by removing Alamofire version in pod file.
Pod file as
# Uncomment this line to define a global platform for your project
platform :ios, "8.0"
# Uncomment this line if you're using Swift
use_frameworks!
target 'GettingSwift' do
pod 'Alamofire'
end
target 'GettingSwiftTests' do
end
回答14:
Setting GCC_SYMBOLS_PRIVATE_EXTERN
(displayed as "Symbols Hidden by Default" in target settings) to YES
in framework being linked helped me to get rid of this error. I've spent 2 days to find this out, hope it will help someone :)
回答15:
When installing CocoaPods, be sure to specify ios 9.0 by deleteing the #. Therefore, # platform :ios, '9.0'
should just be platform :ios, '9.0'
Then, if the error shows again, simply build and run. After you build and run, the error should not return.
Also, this can occur if you have more than one version of Xcode installed on your computer. Quit (not just close) all versions of Xcode first.
回答16:
Im my case it was a different reason, it was the Other swift flags in my targets build setting, i had to add inherited flag to the top.
回答17:
If you have verified that your Pods have been successfully installed, then the error may be associated with your derived data remaining from before you installed the Pods. You can clear your derived data by going to File -> Workspace Settings... -> Derived Data
. Deleting the derived data folder associated with your app and cleaning your build should solve the problem.
回答18:
In my case:
1. Comment line of //import Pod_Module
2. Go to Project -> Clean or use shortcut key (Command+Shift+K)
2. Close your project
3. In terminal go to your project directory
4. run > pod install
5. open .xcworkspace
file and build it!
6. Uncomment line of import Pod_Module
回答19:
try Build For testing works for me