How Do I create an Xcode Source Editor Extension? - swift

I would like to create an Xcode Source Editor Extension. A tutorial from this website shows a template for this in the new project menu. However, as of Xcode 11.5, this is missing from the list of templates. Is there still a way to do this?

As stated in the documentation,
begin by creating a new macOS project in Xcode. Add a new Xcode Source Editor Extension target to your project
In other words, first create a new project. Then create a new target in said project. That target being an Xcode Source Editor Extension.

Related

How to use frameworks imported with carthage in swift playground

i have a swift project with some frameworks added via carthage. Is it possible to use those frameworks in playground inside project and how to use it, because
import Argo
doesn't work :(
This stopped working at some point. Sigh
What I do now is
Create a macOS > Command Line Tool.
Create a Cartfile with github "ReactiveX/RxSwift" and run carthage update --platform iOS
Go to the command line tool target and add the frameworks from Carthage/Build/iOS in Linked frameworks and Libraries
Add the playground files.
At this point I’m able to run the playground files.
🤷🏻‍♂️
A playground has access to external frameworks if it is part of a workspace that builds a target configured to access those frameworks.
If you want to add a playground to an existing carthage project, you only need to save the project as a workspace (File > Save as Workspace…), build the target, and you are done.
If you just want to distribute a playground with third party frameworks, you need to create a dummy workspace. Here is a step by step example for a playground with the RxSwift framework:
Create a new Xcode project of type Cross-platform > Other > Empty. Name it RxPlayground. This will create this structure RxPlayground/RxPlayground.xcodeproj and open a blank Xcode.
Download RxSwift with Carthage
Create a Cartfile with this line: github "ReactiveX/RxSwift" "swift4.0"
Run Carthage with carthage update --platform iOS.
Add a playground to the project.
Click File > New > Playground…
Choose the iOS > Blank template and name it Rx.playground
Right click the project node and choose “Add Files to RxPlayground”.
Select the Rx.playground and add it.
Create a workspace
Click File > Save as Workspace…
Save as Rx.xcworkspace
Copy the frameworks to the products directory.
Close the project and open the Rx.xcworkspace
Create a Cross-platform > Other > Aggregate. Name it RxAggregate
Create a New Run Script Phase with the following content:
cp -rv "${SRCROOT}/Carthage/Build/iOS/" "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"
At this point, Xcode and the Finder look like this:
Note that Carthage/ and Cartfile.resolved appear when you run Carthage, Without them, your playground will be only a few Ks.
Lastly, build the project (⌘B). Now you can use the framework in your playground:
//: Playground - noun: a place where people can play
import RxSwift
_ = Observable<Void>.empty()
.subscribe(onCompleted: {
print("Completed")
})
Sometimes the first time you build (⌘B) Xcode doesn’t notice the new framework (sigh). What I do is click on the target and back to a source file, or re-open the project. I don’t have an explanation why this happens.
In order for the framework to work within a playground, the project that produces the framework must be included in the workspace for your project. So to make this work you need to follow these steps:
If your project is not inside a workspace, create a workspace for your project by choosing File > Save As Workspace in Xcode.
Drag the .xcodeproj file from the Carthage/Checkouts folder into your workspace.
Run the build action on your framework target.
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.
See more here:
https://github.com/richardnees/CarthagePlaygrounds
Based #Jano's great answer (thanks for that), I created a fully functional playground to interact with Carthage frameworks:
https://github.com/backslash-f/carthage-playground
I included the Charts framework as an example:
I tested with latest Xcode.
"Works on my machine." 👍🏻
Found how to do this without converting to workspace and adding .xcodeproj file from the Carthage/Checkouts folder into your project.
This works if you have some framework target that contains all sources you want to use in playground. This framework must be in "Embedded frameworks" of your main target.
Add Carthage .framework to your project from Carthage/Build/IOS
Drag and drop it from your project tree into "Embedded
frameworks" for your main target
Add Carthage .framework to your
framework target as Optional(In target Membership)
Add import
"Your framework target" into playground
That worked for me

how to include static library into another Project

I am using Xcode 4.2.1.
I do have a static library libSignatureLibrary.a (which is 58k in memory)!
and I Created a new project SingleViewBased and open Link Binary With Libraries click '+' added libSignatureLibrary.a which is stored at desktop i added in the application.
I open Target Dependencies Click '+' i can't see the libSignatureLibrary.a library into my project!
I don't know where i did the mistake!
Can any one give me solution to fix this issue.
Its simple,just copy this libSignatureLibrary.a physically to your project folder and from there just add it your project.It will work.

I have installed phoneGap lib but am unable to run the app

I have installed phonegaplib for ios, I created one test project using phoneGap based on application template, but in that, phoneGap.framework is in the red color. I think it is missing. So where can I get this frame work, can any one help me?
Are you sure you're following the official guide?
Create a PhoneGap project (Xcode 4)
Launch Xcode, then under the File
menu, select "New Project...".
Navigate to the "iOS" section, under
"Applications" - then in the right
pane, select "PhoneGap-based
Application"
Select the "Next" button, name your
project and company idenfifier, then
select the "Next" button again.
Choose the location where you want
the new project to be.
Run the project at least once to
create the "www" folder in your
project folder.
Drag and drop this "www" folder into
your project in Xcode, and add it as
a folder reference.
Modify the contents of the "www"
directory to add your HTML, CSS and
Javascript.
Reference 1: PhoneGap iPhone - Build and install the Installer Package
Reference 2: Video: PhoneGap Installer - Xcode 4 Template [HD]
Sounds like you are using XCode 4, which is not fully compatible with PhoneGap's default settings. Use this link to have PhoneGap generate a compatible project for you:
https://build.phonegap.com/generate

Error in Build - Missing SDK

I downloaded some Application samples from a website.
It used to work but when I went back to Xcode (After a couple of months) I tried them and it gives me this error.
error: There is no SDK with the name
or path 'iphoneos2.0'
I tried looking for a file called "iphoneos2.0"
and tried looking for a highlighted code but nothing.
Could anyone help me please?
The Base SDK of your downloaded app's Target has set to iphoneos2.0. Change the Base SDK of the Target from iphoneos2.0 to a iOS version which is available.
To change the Build Settings in (Xcode 3.2) - Goto Project -> Edit Project Settings menu. Or, Double-click the project name in the project tree in Xcode.
To change the Build Settings in (Xcode 4) - Select the project name in the project tree. It will open the Project Settings in the document area of Xcode.
In the project settings, search for Base SDK.

linking gdata to an xcode 4 project

I'm having major issues linking gdata to a project after upgrading from xcode 3.2.5 to xcode 4. I would like to know if anyone is having similar issues, and what did they do to resolve them. i am using gdata version 1.11 which is the latest on their site. The project works flawlessly on 3.2.5, thanks.
I have created a workspace for my project, and then added the gdata.proj to it. So I do have all the files linked by reference. But project files which include #import "GDataYouTube.h" do not see the file. I get "No Such File or Directory"
Good News... resolved and tested, all working follow these steps...
Open your project in xcode 4 from 3.2
click File -> Save As Workspace
in project navigator on the left, collapse your Project if you see all the files
below your collapsed project, in the empty space right click or control click -> Add Files to...
select the project file you wish to link to, leave Copy items unchecked, click Add
Now you will see 2 collapsed projects in your Project navigator, expand both
Now what I didn't know I had to still do
Drag the files or folders you want from the second project to your main, make sure your Main project target is selected in the options, and I also have group selected then click Finish
You are good to go, you might have some warnings about your second project and its targeted SDK. Fix those by clicking the project name in the Project Navigator -> Build Settings -> Base SDK to 10.6, Deployment Target to 10.5