Using Xcode-6.3.1, iOS-8.3 and MacOS-10.10.3, I am trying to use RealmSwift (0.92.3) and CocoaPods 0.37.1
I use the following procedure :
install cocoapods (in terminal):
$ sudo gem install cocoapods
Create new Xcode project (named MyApp)
Create Podfile
platform :ios, '8.3'
use_frameworks!
target 'MyApp' do
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyAppTests' do
pod 'RealmSwift', '>= 0.92.3'
end
Place the Podfile in the MyApp folder (next to MyApp.xcodeproj)
Download the newest Realm (0.92.3 from here) (i.e. Swift version)
unzip it
go to /ios folder
copy RealmSwift.framework also to your MyApp-project folder
(after Point 4 and 5 you end up like in the picture here)
Inside a terminal, go to your MyApp-folder and type
pod install
After pod-install, I end up with the following text inside the terminal:
After that, I simply open the new MyApp.xcworkspace
It basically looks ok - except: NO FRAMEWORK SEEMS TO BE FOUND !! (see screenshot below)...
What am I still missing ????
Any help greatly appreciated!
I finally found out that the "red" colored missing frameworks are no harm. Using CocoaPods these frameworks are not physically there - therefore Xcode cannot change the color. It, for sure, does not indicate a mistake here...
THREFORE THE ABOVE WORKFLOW (pt 1-8) IS CORRECT !
However, the Podfile above is not the right one if you want to use your "MyApp WatchKit Extension". The correct one is:
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'MyApp', 'MyApp WatchKit Extension'
def shared_pods
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
Also, it is important that you still "import RealmSwift" in your Realm-Object definition(s) as can be seen in an example below:
Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):
Related
I recently upgraded to Xcode 8 and an existing project to Swift 3. After having a variety of issues with Cocoapods, I decided to start over from scratch. After running pod deintegrate and deleting Podfile, Podfile.lock, and [Project].xcworkspace, I had a blank slate as far as Cocoapods was concerned.
I then took the following actions:
Opened a terminal at the project location and ran pod init, then pod install (using the stub Podfile that pod init creates).
This appeared to be successful, but came with the following two warnings:
[!] The `Xena [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Xena [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
At this point, opening Xcode and building the project gives the "No such module" error, which is entirely expected.
Following the instructions at this question solves this problem and rerunning pod install is a success.
Closed Xcode, added the modules I'm using to the Podfile (see below), the ran pod install again. According to the terminal output, this is successful.
Opened Xcode and built the project. I again receive the "No such module" error, specifically No such module 'ReactiveCocoa'
I have confirmed that the same problem occurs with SnapKit, Hue, KMPlaceholderTextView, KeychainSwift, and Siren, depending on the order of the import statements. For some reason, none of the Google modules are affected by this problem.
My Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Xena' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Xena
pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git'
pod 'SnapKit', '~> 3.0.2'
pod 'Hue', '~> 2.0.1'
pod 'KMPlaceholderTextView', '~> 1.3.0'
pod 'GooglePlacePicker'
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'KeychainSwift', '~> 7.0'
pod 'Siren'
target 'XenaTests' do
inherit! :search_paths
# Pods for testing
end
target 'XenaUITests' do
inherit! :search_paths
# Pods for testing
end
end
Make sure you are opening .xcworkspace and not .xcodeproj file.
You may further look into this post.
Also under : Target > General > Linked Frameworks and Libraries
Make sure your frameworks are there. Even Pods_Xena.framework is there
Try:
Xcode ->Preferences ->Location ->DerivedData
open the folder DerivedData and move it to Trash
Uncomment the next line to define a global platform for your project
platform :iOS, '9.0'
Uncommenting the second line in your pod file will help you.
I've been learning swift for three days. I'm planning to build my skill in swift especially in iOS development. I just advised by my colleague who is an iOS developer to learn swift while writing test in our app -- this is for the benefit to the company and myself which it makes sense for me. Now, I'm trying to follow this tutorial
https://medium.com/#ynzc/getting-started-with-tdd-in-swift-2fab3e07204b
After following the tutorial to rewrite the test in a framework called Quick which is very similar with Rspec. I did the installation of the CocoaPod then follow the install of the Quick framework. Use the .xcworkspaces instead of the .xcodeproj. But still I'm getting the error of No such module 'Quick'.
I did research already and removing the pods but still getting the error.
platform :ios, '9.2'
target 'FizzBuzz' do
use_frameworks!
def test_pods
pod 'Quick', '~> 0.9.0'
pod 'Nimble', '~> 3.2.0'
end
target 'FizzBuzzTests' do
inherit! :search_paths
test_pods
end
target 'FizzBuzzUITests' do
inherit! :search_paths
test_pods
end
end
screenshot of the project folder:
I recently had this issue and none of the current answers solved this for me.
The reason I was getting this error was that the Test/Spec file (NetworkSpec.swift) that I had created had a target membership of the main application target, not the tests target.
To update this, I opened the project in xcode, selected the file in the project explorer and then in the properties window on the right hand side. Then in the target membership area. I had two options.
ProjectName
ProjectNameTests
I unchecked the checkbox next to ProjectName (not the app's real name) and then checked the one next to ProjectNameTests and re-ran the tests. Everything worked as expected.
I ran into the same issue. I did not need to nest the test targets in my podfile. e.g.
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'MyAppName' do
pod 'RealmSwift'
pod 'GoogleMaps'
end
target 'MyAppNameTests' do
inherit! :search_paths
pod 'Quick'
pod 'Nimble'
end
target 'MyAppNameUITests' do
inherit! :search_paths
pod 'Quick'
pod 'Nimble'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0' # or '3.0'
end
end
end
I am using Xcode 8.1. Click on the currently selected scheme.
Select 'manage schemes'.
Selected scheme.
Put check mark next to test schemes and Quick.
Click on your app scheme again. Select each scheme and go to Product > Build. Finally select your main app scheme again. Now try adding 'import Quick' in one of your test classes.
Schemes
ISSUE RESOLVED
I was getting same issue. Files within Test folder did not see Nimble and Quick pods despite my Podfile was configured correctly and Target Membership for my test file set up correctly as well. I was unable to import both Pods.
Running below commands on Project folder via CLI resolved issue for me.
$ pod update Quick
$ pod update Nimble
My Podfile implementation of both pods for reference:
def include_test_pods
pod 'Quick'
pod 'Nimble'
end
Try this. Cocoapods may need to be rebuilt.
Quit XCode. Go to terminal and cd into your project.
Run pod deintegrate.
Run pod install.
Open Xcode and clean and build your .xcworkspaces project.
I had this issue that persisted through build cleans. I noticed that it was only happening in one file and files that did not have this issue had import foundation. After importing foundation on the line before it, it then worked. I thought maybe it was simply modifying the file that had done it so I removed the foundation import and the error came back. So try adding that import if you do not have it.
First thing first you just need to use pod inside your target project, so it gona share for your test target like that
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'TestNetWorkLayer' do
use_frameworks!
pod 'SwiftyJSON'
pod 'Quick'
pod 'Mockingjay'
pod 'Nimble'
pod 'Alamofire', '~> 5.0.0-rc.3'
target 'TestNetWorkLayerTests' do
inherit! :search_paths
end
end
After that you can import it inside your project
import Quick
import Nimble
class NativeApiClientSpec{
}
In my Podfile i use smth like this:
target 'Specs' do
pod 'Quick'
pod 'Nimble'
shared_pods
end
Additionally, re-open the project or use the following command: Product -> Clean and build folder
I had same issue. After a lot of trial and error, I found fix here: https://github.com/Quick/Quick/issues/402#issuecomment-149459840. I had to delete derived data and regenerate project to get Quick as build scheme
Try this;
Close xcode project
Run $ pod deintegrate
Delete Podfile.lock
Run $ pod install
and Build again!
I'm trying to include Alamofire in my Swift project following the github(https://github.com/Alamofire/Alamofire#cocoapods) instruction.
I've created a new project, navigated to the project directory and run this command sudo gem install cocoapods. Then I faced following error:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
After searching I managed to install cocoapods by running this command sudo gem install -n /usr/local/bin cocoapods
Now I generate a pod file by pod init and edited it this way:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Law
pod 'Alamofire'
target 'ProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
target 'ProjectNameUITests' do
inherit! :search_paths
# Pods for testing
end
end
Finally I run pod install to install Alamofire. After that I open the project and import Alamofire statement gives me following error No such module 'Alamofire'
Update-1: Results of pod install is:
Analyzing dependencies
Downloading dependencies
Using Alamofire (3.4.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Open the .xcworkspace not the .xcodeproj
go to Product -> Scheme -> Manage Schemes...
and check Alamofire true
this work for me
Sometimes with no reason xcode can't load a module Alamofire. It can happen after a work session, after opening a project. The fix for this is to select a schema -> Alamofire, and run. If the message is "Successful", the schema can be changed back to project and it will work with no problems.
I suggest you to change your pod file like this below:
# 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!
pod 'Alamofire', '~> 3.0' <<<---- Alamofire library is cross beetween projects
target 'NotifyM' do
end
target 'NotifyMTests' do
end
target 'NotifyMUITests' do
end
Another thing is use_frameworks! you should use this if the project is Objective-C based and try to use Swift pod library.
UPDATE: for the new cocoapods version 1.x the shared library should be like this:
# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
end
as indicated into cocoapods website :http://guides.cocoapods.org/using/the-podfile.html
you have to clean project and build, before you can import that library.
Install this way Pod file
# 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 'NotifyM' do
pod 'Alamofire', '~> 3.0'
end
target 'NotifyMTests' do
end
target 'NotifyMUITests' do
end
I suggest that and it's work for me :
platform :ios, '8.0'
use_frameworks!
target 'App' do
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
end
After that, run : pod install in your project repository
2021 M1 USERS
according to: https://developer.apple.com/forums/thread/123614?answerId=683594022#683594022
close XCode
open Finder app and show there "Applications"
right click on icon Xcode and click on "Get info" (or something similar)
there is checkbox "Open with Rosseta" (or something similar). Select it
run Xcode again and try to build
it worked for me hope it works for you.
After a lot of efforts and all solutions provided above. I have fixed on Xcode 13.0:
Use for Simulator:
Go to:
- Build settings -> EXCLUDED_ARCHS = arm64
- Build settings -> VALID_ARCHS = arm64e armv7 armv7s arm64 x86_64
Use for Realm Device:
Go to:
- Build settings -> EXCLUDED_ARCHS =
- Build settings -> VALID_ARCHS = arm64e armv7 armv7s arm64
You should tap the Target to select Alamofire and build it once before coding.
When using Cocoapods to include dependencies always open your .xcworkspace
In Podfile use use_frameworks!
Remove any linked libraries from build phases.
In Build Setting look for Framework Search Path and add $(inherited) in both debug and release.
Do the same for Header Search Path too.
Now try a clean build.
Using iOS-8.3, Xcode-6.3.1 and MacOS-10.10.3 - The CocoaPods (v0.37.1) installation of the RealmSwift (v0.92.3) described here and here basically works, except the WatchKit Extension does not find any Realm keywords.
My Podfile looks as follows:
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
def shared_pods
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
link_with 'MyApp', 'MyApp WatchKit Extension'
All my Realm-keywords in the WatchKit Extension do not work as can be seen in the following error messages (...having commented out any import RealmSwift statements) (see pictures below)
Any idea strongly appreciated of what could still be wrong ???
Any idea on how the target-settings must be. Hint: The NameEntry Realm-Object is used in both targets (i.e. MyApp and also MyApp WatchKit Extension). This seems to add complexity to the CocoaPods usage. Any idea if the double-usage (i.e. in both targets) need a special cocoapods setting ?? What about "import RealmSwift" - is this necessary or not ??
The Podfile above is actually the right one !!
However, it is important that you still "import RealmSwift" in your Realm-Object definition(s) using CocoaPods as can be seen in the corrected example below. This will make your error messages of the WatchKit Extension not recognizing any realm-object go away !
Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):
I try to build a WatchKit Extension for my app...
I Updated the pods file to look like this:
platform:ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
link_with 'my-team-ios', 'My Team WatchKit Extension'
def shared_pods
pod 'DOSingleton'
pod 'JSONModel'
pod 'MagicalRecord'
end
target :'My App' do
shared_pods
pod 'Facebook-iOS-SDK', '~> 3.23.1'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
... some more pods here...
end
target :'My Team WatchKit Extension' do
shared_pods
end
How I install the pods and don't get an error...
But, when I build the App, I get this error:
ld: framework not found Pods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What is my problem here?
I'm using Pod 1.2.1 and facing the same problem i.e. No such module XYZ and for anyone who came across the same issue here what I did to overcome it:
use_frameworks!
def shared_pods
pod 'XYZ'
end
target 'MyApp' do
platform :ios, '8.0'
shared_pods
pod 'Blah'
pod 'blah'
end
target 'Watch Extension' do
platform :watchos, '3.2'
shared_pods
end
I just added platform under each target e.g platform :watchos, '3.2' which was missing before and it solved my problem.
You need to open the xcworkspace file instead of the project file when using CocoaPods.
The problem is when updating to cocoapods 0.36.x they are now creating Frameworks out of each pod library. See the blog post about it.
This causes issues with any pod library that is dependent on other pods and how its referencing them in their import statements, or how your code is importing them as well. The Pod process now turns them into frameworks and when they used to be imported as
#import "ThisOtherPodClass.h"
Now need to be imported as
#import <ThisPodsFrameworkName/ThisOtherPodClass.h>
There is a new version of cocoa pods .38, that is designed to support WatchKit. However, if you want to work with the current version, check o make sure that libPods.a is added to the Target, WatchKit Extension in Included Libraries and Frameworks. Second, make sure that Pods.debug and Pods.release are added to Watchkit Extension in the General tabl
https://github.com/CocoaPods/CocoaPods/issues/3382
neonichu commented on Apr 15, 2015
would start by making sure OTHER_LDFLAGS isn't overwritten with unnecessary things, both in the project and the targets.
That set OTHER_LDFLAGS in buids settings solved my issus.
Try to change this lines
target :'My App', target :'My Team WatchKit Extension'
and remove colons:
target 'My App', target 'My Team WatchKit Extension'
I found a "temporally solution" for me:
Switch back to CocoaPods 0.35
Now everything is working fine, with our any changes to my project / pod file (except removing the 'use_frameworks!')
I think, that should not be the final solution here...
A short test by upgrading again to 0.36 raises the same problem as before...
Here is a link to the GitHub Issue:
Rename the target so it doesnt include any spaces -> MyTeamWatchKitExtension both in podfile and also in General -> Targets. This solved my problem