Maybe this is just me experiencing such an annoying "feature":
After upgrading from Xcode 6.0.1 to Xcode 6.1, things changed. Xcode 6.1 is forever indexing the project or compiling source files. The project is not a huge one. It just contains a bunch of Swift files and AWS SDK 2.0 Cocoapods in the workspace. I don't think it should prevent the whole to index and compile smoothly. I tried with some aws-sdk-ios-samples, just to see how Xcode 6.1 works on them, and it ended up in the same forever waiting.
What solutions I have tried so far:
Deleting "Derived Data" in the Organizer, and re-open and workspace. (fail to fix)
"Show Package Contents" on the .xcodeproj file and deleting .xcworkspace as in (Xcode 4 - slow performance)
None of them worked, unfortunately.
P.S. maybe I should try re-creating the project?
My computer settings:
MacBook Pro (Retina, 13-inch, Mid 2014), Memory 8 GB 1600 MHz DDR3, with Yosemite. (I think this is enough for running this small project.)
I tried many of the suggestions above including splitting files, installing Xcode 6.2 beta, and breaking string concatenation statements. What finally did it for me was splitting an array of dictionaries literal declaration I was using for test data into multiple .append statements.
// This causes indexing/building to hang...
var test = [ [ "a": false, "b": "c" ],
[ "a": false, "b": "c" ],
[ "a": false, "b": "c" ],
[ "a": false, "b": "c" ],
[ "a": false, "b": "c" ],
[ "a": false, "b": "c" ] ]
// This works fine.
var test = [ [ "a": false, "b": "c" ] ]
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
test.append([ "a": false, "b": "c" ])
Also, for what it's worth, the 6th entry in this array is what causes the issue for me; five works just fine.
The only working solution for me is to delete all the derived data (not only for the current project, just clean up the whole folder) and then restart Xcode.
Open File / Preferences in Xcode
Click on Locations on the far right of the pop up window
Click on the little arrow icon next to "/Users/Mac/Library/Developer/Xcode/DerivedData"....it takes you to an Xcode folder that contains a DerivedData folder (that contains all of the derived data from your previous projects.)
DELETE the DerivedData folder
Are you using CocoaPods? I ran across the same issue earlier today. (Using xCode 6.1.1)
To fix the issue, I deleted everything in ~/Library/Developer/Xcode/DerivedData, the Pods folder in my project directory, and <project>.xcworkspace.
I then opened terminal, navigated to my project directory, and ran pod install again.
Had the same issue today. Xcode 6.3.2, medium-sized Swift project. At one point it started indexing and it would never finish indexing. The code that caused this was a dictionary of type [String:[String]], so a string-key dict with string arrays as values. I had two of these with keys from A to Z and each of these 26 entries contain a string array with 5 to 10 strings.
Clearing derived data didn't help. Only commenting out those dicts made it go again.
Honestly, this is ridiculous! Apple needs to fix Xcode! It's already horribly slow when compiling Swift projects but bugs like this are a showstopper. I can't do my job properly with this!
For those still having this issue, this is a workaround I've come to enjoy which prevents you from having to enter the objects one by one:
// instead of this, which freezes indexing
let keys = [keyQ, keyW, keyE, keyR, keyT, keyY, ... keyM]
// and instead of this, which is ugly & lengthy
var keys = [KeyboardKey]()
keys.append(keyQ)
keys.append(keyW)
...
keys.append(keyM)
// use this:
var keys = [KeyboardKey]()
keys.appendContentsOf([keyQ, keyW, keyE, keyR, keyT, keyY, ... keyM])
For me, I tried all the above with no success; but all I had to do was to delete the derived data folder, then open up another random project, wait for it to index and now my original (malfunctioning) project works!
Do the development world a favour apple and make your swift compilers open source- so we are not all thwarted by your incompetence.
I am using Xcode Version 7.3 (7D175)
I think I might have figured out an underlying problem. There where two instances where I got stuck in the indexing phase:
I created a closure that I assigned to a variable and omitted the type signature. I think xcode had issues with that type inference step. If I remember correctly one of the arguments was a CGPoint, which has an overloaded constructor. My hypothesis is that there where too many possibilities of what my closure might accept as arguments.
I refactored a factory method such that instead of returning instances of one type, it could return instances of many types with a common base class. It appears that wherever I used the factory method, I had to cast the resulting object to a specific type (either with as? or by assigning it to a variable that accepts a specific type) Again the type inference step seems to be broken.
It seems like the same is going on with the dictionary declarations mentioned by earlier individuals. I filed a bug report with apple.
I've had this issue as well and solved it by removing/changing expressions with the "+" operator.
I changed this:
var mainArray = arrayOne + arrayTwo + arrayThree + arrayFour + arrayFive
To this:
var mainArray = arrayOne
mainArray += arrayTwo
mainArray += arrayThree
mainArray += arrayFour
mainArray += arrayFive
It solved the problem.
My machine is a maxed out MBP late 2013
I experienced this same issue after upgrading to 6.1. Xcode would get stuck compiling or indexing without generating a specific error message.
The issue was finally resolved by breaking some of the longer expressions in the swift files down into multiple shorter expressions. Part of my program combines many different string variables to form a longer string. Attempts to combine them in a single expression and using the addition assignment operator both failed. I was able to make it work by doing something similar to the following (simplified):
var a = "Hello"
var b = " "
var c = "World"
var d = "!"
var partA = a + b
var partB = c + d
var result = partA + partB
I got this idea from receiving the following error many times in the previous Xcode version
"Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions."
Hope this helps
I've struggled with the same problem. I've tried the two solutions mentioned ( deleting derived data and deleting .xcworkspace ) with no success. I also tried slowly commenting out most of the code bit by bit and removing the files until there was almost nothing left and the indexing was still stuck.
I did find a solution that worked for me, I've opened the project with an older Xcode Version 6.1 (6A1030) which had no problem indexing then got back to the latest Xcode Version 6.1 (6A1052d) which I was using before and indexing was fixed and continued to work well.
My conclusion is that this is a bug with Xcode Version 6.1 (6A1052d) which I hope will improve with future releases.
The problem does come back once in a while, the same fix works each time. I guess another solution would be to just stick with the older Xcode Version 6.1 (6A1030) but it won't work with devices running iOS 8.1 and it won't have the latest bug fixes.
I have tried this with Xcode 8.3.3. Here are my results:
You can write perfectly fine Swift code that will cause indexing to hang.
Once indexing hangs, it hangs. Changing the Swift code back to something that wouldn't cause indexing to hang doesn't help, it still hangs.
Closing the project and reopening doesn't help in that situation.
Quitting Xcode and restarting it helps. Indexing will not hang anymore (that is if you changed the code back to something that doesn't make it hang).
Restarting your Mac helps as well, although it isn't needed.
The hanging is caused by perfectly fine Swift code. An example that I had looked like
if let date = function1()
?? function2()
?? function3()
?? function4()
?? function5()
?? function6()
?? function7()
?? function8()
?? function9()
?? function10() {
return date
}
Indexing would hang. I commented out most of the "??" lines and it was fine (after quitting and relaunching Xcode). Uncommented one line after the other. With some number of lines it was fine, then uncommenting the next line would make it hang.
The only thing that helps apparently is changing your code.
On my Xcode the solution was to close all redundant windows. For some reason many open windows make Xcode very slow.
I had expressions like:
let x = (value as? Int) ?? someDefault
also
guard let x = (dateFormatter().string(from: Date()) + msg + "\n").addingPercentEncoding(...) else { ... }
So the point is to rewrite your file to contain only kindergarten level expressions and the indexing problem will go away.
Xcode 11.5 (11E608c) and still the same issues, 6 years after the original question.
I wish i could "mark" apple in this question so they can see this mess.
This is a large project( >1000 files) and i was under the clock so when i notice the freezing index i was with more than 100 files changed and can't go back.
I've tried everything:
clear Derived data and build
Restart xcode , restart mac
remove and add source
Searched for dictionaries literal's etc etc
The problem was an array creation:
private var overlayColors: [UIColor] = [UIColor(hex: "#b71c1c"), UIColor(hex: "#4a148c"),
UIColor(hex: "#880e4f"), UIColor(hex: "#1de9b6"),
UIColor(hex: "#f50057"), UIColor(hex: "#311b92"),
UIColor(hex: "#f44336"), UIColor(hex: "#651fff"),
UIColor(hex: "#d500f9"), UIColor(hex: "#3d5afe"),
UIColor(hex: "#bf360c"), UIColor(hex: "#0d47a1"),
UIColor(hex: "#006064"), UIColor(hex: "#2979ff"),
UIColor(hex: "#ff6f00"), UIColor(hex: "#1a237e"),
UIColor(hex: "#795548"), UIColor(hex: "#004d40"),
UIColor(hex: "#00e676"), UIColor(hex: "#01579b"),
UIColor(hex: "#33691e"), UIColor(hex: "#827717"),
UIColor(hex: "#76ff03"), UIColor(hex: "#ffc400"),
UIColor(hex: "#e65100"), UIColor(hex: "#00b0ff"),
UIColor(hex: "#ff3d00"), UIColor(hex: "#616161"),
UIColor(hex: "#263238"), UIColor(hex: "#ff1744")]
What helped me to discover the bad swift file was when xcode freezed indexing i did the following steps
open activity monitor -> "swift" process ->show process info -> open Files and Ports. This will give you a list of what files this process is running drilling down your list of possible bad files
Other handy tool is this script SOURCEKIT_LOGGING=3 /Applications/Xcode.app/Contents/MacOS/Xcode &> ~/Documents/xcode.log this will start Xcode with level 3 verbose and start logging in the log file.
Search in the log file the last entries for your swift files ex:
"my_project/Source/App/"
It's not a full solution but it's helpful to drill down and know where to look.
Finally, I "solved" the issue, though it is just a workaround.
I created another project and added files one by one to it. Then I spotted a "very long" viewcontroller.swift file. Then I broke its codes into modules and made those repeatedly used codes into functions in another swift file. And also, I took the suggestion online that long expression should be broken into shorter ones. Then, the indexing works and the compiling works.
So for now, I have it "solved".
BUT, I don't think this is right. Xcode IDE should be more than capable of handling my "very long" swift file, only 1500 lines. I believe this is definitely a bug (existing for a long time), although Xcode 6.1 is already an upgrade from Xcode 6.0.1.
For me, I deleted the Xcode app and downloaded it again and install it. That solved the issue, at least over now.
Xcode indexing usually for your code for suggestions and auto complete among other things like helping you in story boards and vice versa.
But to make faster your xcode project you can turn it off/on via terminal
Turn off indexing
defaults write com.apple.dt.XCode IDEIndexDisable 1
Turn on indexing
defaults write com.apple.dt.XCode IDEIndexDisable 0
But Better approach to use a speedy mac with good RAM.
If you don't mind reverting back to 6.0.1 until they figure it out, that's what worked for me. I was having the same issue with both 6.1 and 6.1.1. Now I'm good. I'll try 6.2 when it comes out.
You can find previous versions of apple software on their official dev site, here:
https://developer.apple.com/downloads/index.action
If you do this, make sure to delete your current copy of Xcode first.
I am using Xcode 6.1.1 with swift files on the same exact MacBook Pro.
As I kept adding rows into a 3D string array, Xcode all of sudden became unusable and now I can't do anything.
Will try to revert to 6.1 and hopefully the problem will go away.
I am seeing this in Xcode 6.3.2. I had really hoped that a year after release, they would have the compiler working, but alas.
If none of the above solutions work for, try checking your code for syntactic errors. In the process of refactoring, I extracted a closure but forgot to qualify the parameters:
let hangsInsteadOfError = { l, r in
return l.nameFirst < r.nameFirst
|| l.nameFirst == r.nameFirst && l.nameLast < r.nameLast }
let fixingErrorAvoidsHang = { (l:User, r:User) -> Bool in
return l.nameFirst < r.nameFirst
|| l.nameFirst == r.nameFirst && l.nameLast < r.nameLast }
If I have learned anything from working in Swift, it is to work incrementally, to avoid having to backtrack too much to find the offending code.
Is your indexing status an "Indicator circle" or "Progress bar"?
If it is an "Indicator circle", that means it already stuck at the beginning.
Open and check with your other projects, if they are all the same, that means it's a system issue.
Just restart your computer and everything will be fine.
I use Xcode 8.2 and also ended in this problem. It started after I defined a complex tuple variable -- an array of tuple with subarray of tuple. Things get really slow when the subarray of tuple has a property that is programmatically calculated.
As some other answers noted, the indexing takes forever, and I believe it is trying to infer the types the variable.
I solved the problem first by clearly define the variable with types included. When updating the property, I calculate it first then assign it to the tuple, instead of calculating in defining the variable.
Here is an example code.
var sectionTuples: [(section: String, rows: [(name: String, subtitle: String)])] = []
let subtitle1: String = "" // something calculated dynamically
let subtitle2: String = "" // something calculated dynamically
sectionTuples = [(
section: "Section 1", rows: [
(name: "name1", subtitle: subtitle1),
(name: "name2", subtitle: subtitle2)
])]
The bottom line is that don't let Xcode infer complex structures.
I was having the same issue. My Xcode is 8.2.1. But in my case, I wanted to create an array of dictionary with 33 key-value pairs.
I was doing in the following way which was stuck in indexing:
var parameter = [String : AnyObject]()
var finalArray = [parameter]
for item in listArray
{
parameter = ["A": item.a as AnyObject, "B": item.b as AnyObject, "C": item.c as AnyObject, ... , "Z": item.z as AnyObject]
finalArray.append(parameter)
}
Following worked for me:
var parameter = [String: AnyObject]()
var finalArray = [parameter]
for item in listArray
{
parameter["A"] = listArray.a as AnyObject
parameter["B"] = listArray.b as AnyObject
parameter["C"] = listArray.c as AnyObject
parameter["D"] = listArray.d as AnyObject
.
.
.
parameter["Z"] = listArray.z as AnyObject
finalArray.append(parameter)
}
You may wish to update to Xcode 6.1.1
It has been officially released and resolved for us the indexing problem. In the update description, it says that they have applied stability fixes so it is very likely that it will behave in a more stable fashion.
The Xcode 6.2 beta resolved the issue for me. Not lightning-fast, but at least it isn't indexing forever. The beta does not install over the top of your regular Xcode installation, so if you don't like the beta, you can just delete it.
Various Xcode downloads including the beta >
Related
There was a version of Leaf that I was using to load .html files instead of .leaf ones from my Vapor project, which would make syntax coloring for those same files done automatically.
The version of Leaf was 4.0.0-tau.1 and the one for LeafKit was 1.0.0-tau.1.1
When using this particular version, I could setup leaf in the configure.swift file this way:
/// Change the classic .leaf extension to .html for the syntax
/// coloring option of Xcode to work each time the app is being load up.
fileprivate func leaf(_ app: Application) {
if !app.environment.isRelease {
LeafRenderer.Option.caching = .bypass // Another issue from the update
}
let detected = LeafEngine.rootDirectory ?? app.directory.viewsDirectory
LeafEngine.rootDirectory = detected
LeafEngine.sources = .singleSource(
NIOLeafFiles(fileio: app.fileio,
limits: .default,
sandboxDirectory: detected,
viewDirectory: detected,
defaultExtension: "html"))
app.views.use(.leaf)
}
In this code, the LeafRenderer.Option.caching = .bypass and the code used with LeafEngine do not work anymore since having updated Leaf to 4.1.3 and LeafKit to 1.3.1.
How can I successfully make this code work as before with the updated Leaf and LeafKit frameworks?
You can use this Xcode plugin:
https://github.com/OmranK/VaporLeafPlugIn
It adds Vapor Leaf language support to Xcode IDE. Provides syntax highlighting for Leaf tags as well as HTML tags with auto-indentation all together.
At the moment the plugin supports Xcode up to 13.2 beta. Future Xcode versions will require small update (add new DVTPlugInCompatibilityUUID) but it can be easily handled even on already installed plugin.
I tried to change client page size in Azure server
it's default is 50 and I want to make it bigger
so i use Microsoft tutorial in this link
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-ios-how-to-use-client-library#querying
var client : MSClient?
let client = MSClient(applicationURLString: "AppUrl")
let table = client.tableWithName("TodoItem")
let query = table.query()
let pullSettings = MSPullSettings(pageSize: 3000)
but when I write
table.pullWithQuery(query, queryId:nil, settings: pullSettings) { (error) in
if let err = error {
print("ERROR ", err)
}
}
there are error "Value of type 'MSTable?' has no member 'pullWithQuery'"
what is the problem ?
is the function name changed ?
Two problems:
The documentation has not been updated for current versions of Swift
(an update request has been filed). The correct function name in modern Swift is pull rather than pullWithQuery.
The pullWithQuery function is on MSSyncTable, not MSTable. Pull is part of the offline sync system. The MSTable analog is read.
More details:
The SDK itself defines the function as MSSyncTable.pullWithQuery, but one of the features of Swift 3.0 is that it renames Objective C methods when it projects them into Swift to remove redundant arguments from the name, so verbWithX(X) becomes just verb(with:x) and pullWithQuery (MSQuery) becomes pull(with:MSQuery).
For more information on Swift 3 changes please see https://swift.org/blog/swift-3-0-released/ . I believe this particular change is SE-0005: Better Translation of Objective-C APIs Into Swift
If you download the Swift quickstart from your Azure Portal then you’ll get the correct modern pattern there:
self.table!.pull(with: self.table?.query(), queryId: "AllRecords")
or with your arguments:
self.table!.pull(with: self.table?.query(), queryId: nil, settings: pullSettings)
I am trying to add a Skeleton-templated view to a recent Vapor 2 app that, so far, only produces JSON output with a MySQL database. If I use the following minimal code:
get("viewTest")
{ req in
let params = try Node(node: [ "name": "nick"])
return try self.view.make("index",Node(node:params))
}
The file index.leaf exists in the Resources/Views folder and the documentation suggests that omitting the .leaf suffix is fine, but doing so gets:
[Data File Error: unable to load file at path /Users/test/Library/Mobile Documents/com~apple~CloudDocs/Apps/Vapor/testServer/Resources/Views/index]
However, if I put the suffix in explicitly, self.view.make("index.leaf",Node(node:params)), the contents of the file are output without being rendered:
#extend("base") #export("body") {#(name)}
I have tried putting the code directly into Main.swift and that makes no difference and putting it into a handler. I've also tried creating a new Vapor 2 project from scratch (using a fresh install of vapor) and it behaves the same. It seems odd that something so fundamental doesn't work out of the box.
It turns out that although the default renderer for Droplet is 'leaf', the default setting in Config is 'static'. Putting:
"view": "leaf"
into Config/drop.json fixed the problem.
I've never messed with iOS so this is all new to me. I'm trying to import SQLClient into an an existing Xcode project. (I need to fire off an INSERT from the iOS app.)
https://github.com/martinrybak/SQLClient
I've tried both installation methods listed by Martin via cocoapods and manual but I can't get either to work.
For option #1) everything worked fine until I tried pod install and was met with
Analyzing dependencies
[!] The dependency SQLClient (~> 0.1.3) is not used in any concrete target.
I was expecting the command to produce a file named SQLClient.xcworkspace. I wasn't sure if this new xcworkspace file was meant to replace my main project xcode file. But since it didn't work, I moved onto option #2.
For option #2 I wasn't sure where to put the contents. (Does Martin mean /SQLClient/SQLClient/SQLClient/SQLClient or /SQLClient/SQLClient/SQLClient?)
Was I supposed to copy just the files or the whole folder?
Do the contents go into my project at the same level as my original xcode project file or in a subfolder?
I've tried a couple variations but I admittedly don't know where the SQLClient files/folders should be placed in relation to my other project files.
I've tried messing with my bridge file as well but I've been unable to properly load it.
I have some time (2 days) to figure this out so I'm willing to learn but I need some guidance.
Here's a pic of my existing Xcode project and latest attempt to import SQLClient.
It looks like you have all the files in your project correctly.
Things to check.
If you said yes to create the bridge file when you dragged the object-c file into the project then you just need to add #import "SQLClient.h" to the bridge file. If you created the bridge file manually make sure it is added to Build Settings - Objective-C Bridging Header.
Make sure in your target - general - linked framework and libraries you have libiconv.tb and libfreetds.a
Swift 3
class testViewController: UIViewController, SQLClientDelegate {
// Handles errors from the SQLClient
func error(_ error: String!, code: Int32, severity: Int32) {
print("\(error!) \(code) \(severity)")
}
//MARK: Lifecyle
override func viewDidLoad() {
super.viewDidLoad()
let client = SQLClient.sharedInstance()!
client.delegate = self
client.connect("ServerNameOrIP", username: "cool", password: "cool", database: "database") { success in
client.execute("SELECT * FROM table", completion: { (_ results: ([Any]?)) in
for table in results as! [[[String:AnyObject]]] {
for row in table {
for (columnName, value) in row {
print("\(columnName) = \(value)")
}
}
}
client.disconnect()
})
}
}
}
Created a sample project here
I was able to get installation option #1 working after changing the pod file to include a target.
target "TargetName" do
pod 'SQLClient', '~> 0.1.3'
end
I downloaded SQLClient manually and it worked for me.You will get the steps to connect from swift project from here - https://github.com/salmasumona/Call-SP-from-iOS-project-using-SQLClient
SWIFT 5
enter image description hereThe best way to use Obj-C in a Swift project is to use a bridging header file, what I did with SQLCLient was to drag and drop the files from SQL client and then Xcode will ask if you want to create a bridging header file, select yes.
Inside the bridging header file, import "SQLClient.h", from here you can build the project and everything should compile. You can then create a SQLClient object like you did above and inside the .connect you make the sure the completion handler checks if it was successful then inside the closure you can call client.execute and from here if you put a SQL command as a string and use data as a variable inside the .execute completion block, if you print this data variable you will return all of the data from the SQL Server. It returns in JSON, so from here you can convert using JSON Serialization.
If you have any questions, please feel free to message me and I will return a screenshot of what my code looked like so that it may help you!
In the backend in the sitetree we gave some folders a special style (edit folder -> Behaviour -> Contain Plugin -> News). So that this folders get the class .t3-icon-pages-contains-news and are blue.
Now I copied different typo3 files into that installation, but use the same database. Everything works fine, but this folders dont have the class .t3-icon-pages-contains-news anymore. The Behaviour -> Contain Plugin is still set to news.
Any ideas where this is coming from?
You did not provide any code example so it is hard to figure out what is going wrong in your situation.
However, here a example how it should look like:
typo3conf/ext/myext/ext_tables.php or typo3conf/extTables.php
if (!$TCA['pages']['columns']['module']['config']['items']) {
$TCA['pages']['columns']['module']['config']['items'] = array();
}
$TCA['pages']['columns']['module']['config']['items'][] = array('your label', 'myext', 'EXT:myext/Resources/Public/Icons/FolderIcon.gif');
\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-myext', '../typo3conf/myext/Resources/Public/Icons/FolderIcon.gif');