I'm trying to use PayMill SDK in a Swift project.
I used CocoaPods as described by PayMill, the framework, and it generated 'Pods_PayMilDSK'
After that I tried to import it on my file but I can't get access to any to the functions included in the framework.
I also tried to import the framework directly in my project but I can't access the PayMillSDK framework (i.e. import does not 'see' it).
Any help would be greatly appreciated.
Rodolphe
After running pod install You should always Build your project, cmd + B, because your project still hasn't read the contents of the library you just installed.
Also make sure you're using the .xcworkspace and not the .xcodeproj
I can now make the import of the PAyMill module but functions are not available
This project came to me to be updated to the new iOS 10.It uses frameworks downloaded with cocoa pods. Some of these frameworks are written in swift.Now that I made few changes on the project code, when I try to build the project, I get errors on the frameworks I downloaded as if the project can't read swift!
Is there somewhere where I can set my project to accept swift classes?
Updated Xcode to Xcode 8 and it updated the code and fixes theses issues. Thanks Folks.
Hi Can any one help in resolving this issue.
I have created a dynamic framework in swift. My framework is referring some external frameworks like alamofire, xcglogger etc into my framework project. I am using carthage for this purpose.
It works perfectly. But when I create the framework and use it in another project its giving me error on my framework
Missing required modules : 'Alamofire','XCGlogger'
Can anyone help me in this.
I am using carthage 0.16.2
xcode 7.3.1
Swift
I have followed the steps provided to add the framewowrk from this link https://realm.io/docs/swift/latest/
It gives this error what could be the issue?
Is it because it is compiled with an older version of xcode, since I have the latest xcode 7 beta?
If so, how would I solve this?
You'll have to wait for us to support Swift 2.0 (#2062) before you can use Realm Swift in your Swift 2.0 project.
Because the framework written in Swift which was built in the old version compiler is not able to use in Xcode 7. Therefore, it will be needed to re-build using the compiler of Xcode 7. However, Swift 2 is required on Xcode 7; we are working to adapt RealmSwift.framework to the Swift 2.
I got Realm to work with Swift 2 by doing the following (this is from memory)
Checkout Swift-2.0 branch https://github.com/realm/realm-cocoa/tree/swift-2.0
Build by running /build.sh ios-swift
Copy Realm.framework and RealmSwift.framework into project
Use let realm = try! Realm() as my initializer in place of let realm = Realm()
I use Carthage for all my frameworks, so to keep things uniform I copied the RealmSwift and Realm frameworks into the carthage/build/ios directory and the /usr/local/bin/carthage copy-frameworks build script picks them up
This just randomly started happening to me as well for some reason. Manually compiling the swift-2.0 branch didn't end up working at all.
I ended up converting my entire project to Swift 2.1, and using the pre compiled frameworks. Now I'm up and running.
FWIW - The conversion to 2.1 from 2.0 wasn't nearly as painful as any of the other conversions from 1.0, or 1.2.
How do I import 3rd part frameworks into Xcode Playground?
Swift Playground obviously has a framework import mechanism because we can import Cocoa, SpriteKit, and in an OSX Playground, XCPlayground (XCPlayground seems missing from iOS, oddly)
What I'd really like to do is hide code from my playground and be able to show a minimal example. Any thoughts on how to load a Framework into Swift playground?
See also:
How to import own classes from your own project into a Playground
Is it possible to import third-party Objective-C code into a Swift playground?
(This question is different because the request is to use a framework in Playground rather than simply regular swift files)
There is currently no supported way to import your own framework or app code into a playground, short of pasting it into the playground editor. We're aware that this is very desirable functionality, but as always we encourage people to "vote with bugreporter" at bugreport.apple.com
Right now, if you're just trying to hide code for showing in an example, code folding in the editor might do the trick.
It is now possible to import your own frameworks into a playground. This provides a way to share code between your applications and playgrounds, which can both import your frameworks. To do this, your playground must be in the same workspace as the project that produces your framework. You must have already built your framework. If it is an iOS framework, it must be built for a 64-bit run destination (e.g. iPhone 5s). You must have an active scheme which builds at least one target (that target's build location will be used in the framework search path for the playground). Your "Build Location" preference (in advanced "Locations" settings) should not be set to "Legacy". If your framework is not a Swift framework the "Defines Module" build setting must be set to "Yes". Once all these conditions are fulfilled, importing your framework will work in a playground.
Edited: As of Beta5 this is now supported when the playground is part of the workspace that builds the framework as a target. There are more details on the Apple dev forums site, but hopefully #Rick Ballard will add them to his answer here and that should becoke the definitive answer for this question.
Don't do the below anymore!
For the short term, while there's no supported solution, if you're producing a Module/Framework you can copy it into the SDKs System/Library/Frameworks directory and then just import <#Module#> the same way as you import system Frameworks.
For an OS X Playground: /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks
And for iOS: /Applications/Xcode6-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/
But before you do that... go file a radar as #Rick says in his answer.
I've written a tutorial covering import of custom frameworks in Beta 6
In short, if you've got your playground and framework either in the same project or workspace, and your framework is built for 64 bits (even for iOS), they play very well together.
source: http://qiita.com/ryokosuge/items/2551cd4faa9dca324342
If there is anyone who still had difficulty understanding how to go about it after reading the accepted answer, this may help.
It's not in English though so I will explain here:
Using Carthage:
1: Setup your Cartfile in the root of the project, add your libraries and run:
carthage update --platform iOS --use-submodules
2: Make sure your project is saved as a Workspace. From the Xcode menu bar: File > Save As Workspace. Shutdown Xcode and reopen from the new .xcworkspace file.
3: Add your library's .xcodeproj file in your workspace: File > Add files to "your_workspace_name". Then find it in: ${SRCROOT}/Carthage/Checkouts/your_library_name/your_library_name.xcodeproj
4: Find the Embedded Binaries and Linked Frameworks and Libraries section in your project's general settings. Add your library's .framework file to both.
5: Clean(⇧+⌘+K) and build(⌘+B).
6: Import your library in the playground.
I solved it by copying the built frameworks to the Built Products Directory, where Playgrounds in the workspace also searches for frameworks. Note: you also need to run lipo and strip away unused architectures from the FAT binaries.
The steps needed (in a nutshell):
Create an aggregate target
Add a script phase to copy the frameworks
from Carthage/Build/iOS/ to BUILT_PRODUCTS_DIR (I use a swift script
in the example below, but you can use also use bash, ruby python
etc.)
Run aggregate target Now you can import the framework(s) in a
Playground
Additionally you can leverage the aggregate target in your app:
Embed frameworks from BUILT_PRODUCTS_DIR, not Carthage/Build/iOS/
Add aggregate target to app scheme to re-establish frameworks after a clean.
Here is an example project setup as above: https://github.com/richardnees/CarthagePlaygrounds
Like using Objective-C classes in Swift code, you can import 3rd-party library/classes into your project and Xcode will ask you if you wanna create a <#YourProjectName>-Bridging-Header header file. Choose yes and import all header files you need in that file. After that, in your playground, you can simply do import <#YourProjectName>-Bridging-Header after import UIKit and you will be able to use the classes you imported to your project.
Update: this is actually incorrect. Please see my comment below. Sorry for any confusion...