Default frameworks missing in Xcode 6 beta - ios

While creating a new project in "Xcode 6 beta", I noticed that there are no frameworks attached.
In Xcode 5.x, when we created a new project, we had the following frameworks linked by default:-
Foundation
CoreGraphics
UIKit
XCTest
The frameworks that are linked when you create a new SingleViewController project in Xcode 5.x
The MISSING frameworks when you create a new SingleViewController project in Xcode 6 beta
I do understand that this is a beta release of the IDE. But it will help if we come to know whether these frameworks are now linked internally?
Thanks in advance.

In Xcode 6, the default for new projects is to use the module system (introduced in Xcode 5) to automatically link any frameworks you reference in code via import (Swift) or #import/#import statements (ObjC). Because the project template contains code that imports Foundation and UIKit (and a test case target that imports XCTest), you get those frameworks linked automatically.
As Alladinian commented, there's a switch to enable or disable this in the project settings, so you can turn it on for old projects, too. (Or turn it off if it gives you trouble.). Once your frameworks are automatically linked, you don't need to put them in Linked Frameworks & Libraries anymore.
And if you want to start using other frameworks in your project, you don't need to add them I'm the project settings, either—just import MapKit or CloudKit or AVFoundation or whatever in your source code and they'll automatically get linked.

Related

How to import Swift Package in App already added to Workspace of App

I am using Xcode 12.4, I created an app "App".
After that, I created a Swift Package "MyLibrary" via File > New ... > Swift Package ..., and chose the option to immediately add it to the workspace "App":
I want "App" to be an example app of how to use the Swift Package, so it seems nice that I can develop the package + example app in the same window and things are grouped together:
The problem seems to be that I can't import "MyLibrary" for example in the ViewController.swift:
import MyLibrary // no such module "MyLibrary"
Question: How can the app import the swift package?
After you have added the package to your project you need to add the library to your "App" build target.
Select the project in your project navigator then under General
Select the "App" target
Check if MyLibrary is listed under "Frameworks, Libraries and Embedded Content". If not then add it using the "+" button – Joakim Danielson 25 mins ago
See also Apples documentation

Convert swift Xcode project into importable cocoapods

I have a Xcode project and it's running well.
But now I want to convert my Xcode project into importable cocoapods, so I can import same cocoapods in multiple Xcode project and create new separate app with same features. (by changing some UI configuration only)
(Basically, I want to move whole app/project into cocoapods, including storyboards, assets and all files. so I can create another similar app by just re-branding UI)
Can someone please help me how to configure and setup for this kind of structure?
Thanks.

Adding a custom Framework to an Xcode project

I decided to try to make a Cocoa Touch Framework. Making it worked fine, but I am having trouble adding it to a project. After searching through a lot of SO posts and looking at Apple Forum threads I decided to try this from the Docs:
Add a framework bundle to a project in order to incorporate the
framework’s features into your product.
In the project navigator, select the project or group within a project
to which you want to add the framework.
Choose File > Add Files to “”.
Select the framework bundle, and click Add.
The frameworks you add this way are third-party-built bundles
containing the framework’s object code and runtime resources. See
related articles for information about linking to a framework without
adding it to the project.
After you add the framework, Xcode configures the targets in your
project to link them to the framework just added.
It still doesn't work. I am getting a No such module 'Scaffold' error for everything I try, I have checked spelling, but that is not it. Can someone explain how this works? I might just need clarification on how this is done.
Links I have looked at:
Create and import swift framework
Xcode error when I add a framework
Adding a framework to XCode 4
Xcode 5.1 compiler errors after adding a framework
Add a framework to an existing project without using cocoapods
What is the process for creating a Framework?
Hey I do not know if it is too late to answer this question, but due to the fact that I am facing same issues right know I would recommend you to check the Build Settings of the project where you import your framework
You should check the "Framework Search Path" and if the framework is at Swift and you import to an obj c project check YES to "Always embed swift standard libraries"
More or less the problem I think is in the Build Settings

Building a Swift Framework with Xcode 7 (Beta 3) to use as an Embedded Binary

Ever since Embedded Binaries were introduced in iOS 8, I have been wanting to port a lot of my common code into frameworks. I decided to wait one year before doing it and this year, with Xcode 7 Beta and iOS 9, I'm starting to do that just that.
I have started a Cocoa Touch framework project in Xcode 7 and I want to compile it into a usable framework. I can get it to compile my project into a .framework, but there's a few issues; namely, the framework doesn't appear to be importable into new projects (I will describe the steps I did for that shortly). Because of that, I'm not sure if my framework has any visible symbols.
This is what I have done to create the Framework:
Created my Framework as a Cocoa Touch Framework.
Went to my target's Build Phases, went to Headers, and added all my Swift files to the "Public" section, in hopes that will export all my simbols without having to mark them as public.
I tried to archive my project as a framework. Currently, it looks like Xcode 7 Beta 3 has a bug (going to report it later today) in which it generates corrupted archive files. For this reason I couldn't get my framework from the Organizer Window. To work around this, I changed the schema of the Run action in Xcode from Debug to Release, built it and grabbed it's generated .framework from my project's build/iphoneos-release directory. This was a quick test so I didn't need the frameworks generated for emulators.
And this is what I did to try to add the framework to a new project:
Created a "Frameworks" group (for organizational purposes) and dragged the framework there, selecting "yes" when it asked me if I want to copy the file to my project's directory.
Went to my target's settings, removed my framework from "Linked Libraries" (it was added there automatically), added it to Embedded Binaries instead. This added the framework to Linked Libraries again, so I had to remove it from there twice. Leaving the framework in Linked Libraries causes a linker error (can't find the framework - no idea why but I think it's irrelevant to my problem and something I should report to Apple as well), but once you remove it from there it seems to compile fine when you add it to Embedded Binaries.
Tried to import my framework in a file. Xcode complains there is "no such module".
Unfortunately, despite the fact that embedded frameworks have been around for around a year, I can't find much writing on the topic.
So my question is: Am I creating the framework correctly, making it possible that my framework/anything else is failing due to an Xcode 7 Beta bug? Or is there a different procedure to create a framework that I want to use as an Embedded Binary? I should probably mention that I want to make this library open source, and I think distributing a plain .framework file to the people who want to use it would be neat.
I Had the same issue on Xcode 7.
I solved it by editing the build settings of the project (the one which includes the framework).
By setting the Framework Search Paths field to $(PROJECT_DIR) or to the path to the directory that contains the .framework file it should help Xcode finding the module.

How to I import 3rd party frameworks into Xcode Playground?

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...

Resources