I debugged the following code with F6 in Xcode 6, and the sequence of execution is very interesting.
Here is the code - 7 lines, a breakpoint is set on line 1:
let request = AWSDynamoDBPutItemInput()
request.tableName = "blah"
let card = AWSDynamoDBAttributeValue()
card.S = "1234"
let email = AWSDynamoDBAttributeValue()
email.S = "notset"
request.item = ["card_number" : card, "email" : email]
When I F6'd through the code, it showed the following sequence (the numbers are line numbers):
1,2,4,2,3,4,6,4,5,6,7,6,7
Why is this? Is this something with Xcode or the language? Those classes are defined in Amazon's AWS SDK, not sure whether that matters, they are accessed through swift-objective-c bridging, could this be related to the bridging.
By the way, the net result of the execution is correct.
I think what you're observing is the effect of the compiler optimizations. It rewrites your code at compile time. For this reason it's normal to disable optimization (-Onone) on debug builds, but enable it (-Ofast or -Os) on release builds.
Finally I got a reply to my bug report from Apple, and sounds like it was a bug and got fixed in a beta version of XCode. If you are seeking for a fix, please try the beta:
We believe this issue has been addressed in the latest Xcode 6.3 beta, including iOS 8.3 SDK with Swift 1.2.
Please test with this release. If you still have issues, please include any relevant logs or information that could help us investigate.
This is a pre-release version of the complete Xcode developer toolset for Mac, iPhone, iPad, and Apple Watch. This release requires OS X Yosemite.
Xcode 6.3 - Build 6D520o
https://developer.apple.com/xcode/downloads/
You should open your project and targets configuration page, under the build settings tab, locating the "Apple LLVM 6.1- code generation" tag, change the optimization level for debug to be "None [-O0]", clean your project and you are done!
Related
I am developing a project for macOS. The project is very small so far, and it uses macOS storyboards, Swift and Objective-C. I noticed abnormal delays while building, even with a very small change to the codebase, and found out, in the Xcode Build log, that there is the last entry:
Register MyApp.app
That takes 31 seconds to execute. Does anybody know what it can be and how it can be made faster ? Many thanks for your help.
EDIT:
I expanded the entry in the log, it says:
RegisterWithLaunchServices /Users/fofo/Library/Developer/Xcode/DerivedData/Myapp-augvduoefsyddebwifpwnceelymu/Build/Products/Debug/MyApp.app
Thanks again
It usually helps to delete “DerivedData” folder
This is the umpteenth time I've tried to create an AUv3 plugin, all with various amounts of success (no complete joy, ever :/ )
It works in the app, but auval fails with
Bad Max Frames - Render should fail
ERROR: AudioUnitRender should have returned an error for too many frames but returned noErr
Current OS: 10.13.5
XCode: 9.4
created an AUv3 MacOS Instrument by creating a Cocoa Objective C app
added an AudioUnit app extension
added a Cocoa framework
etc. Details supplied if needed. (I made notes about my steps since I've never completely succeeded previously.) It is essentially the same as the Demo MacOS AUv3 instrument but I started the project from scratch. The only swift code is in SimplePlayEngine.swift. The rest is Objective C, Objective C++, and straight-up C++.
The only web search hit I found on this problem is add arg to prepareInputBufferList but there are two problems with this link:
Applying the change doesn't fix my problem
The demo AUv3 instrument builds and passes auval validation on my system with no modification.
I don't know if this is related but I find that NO breakpoint I set in the audiounit or related files (BufferedAudioBus.hpp) is ever hit. Since the audiounit functions in the app I must assume that the code is getting executed but something about the way it was built is wrong. (NSLog messages don't get printed either ... ??? (yes I know that when realtime rendering, printing to the console is a bad idea)).
I diffed between my AU source and the demo AU and the only changes are name changes. The "Build Phases" are comparable.
I know this is a pretty non-specific question, but I've run out of ideas. Does anyone have any ideas where to look to resolve the "Bad Max Frames" auval failure?
I am doing iOS game development using the cocos2d framework, and I tremendously envy the ability for Eclipse Java programmers to hot swap their code while they are debugging their application (i.e. change out variable values within a method and have the program live update as if you had a REPL without having to recompile).
This seems like something that would be absolutely tremendously helpful when it came to iOS development, where my development environment is (obviously) Xcode and the language I am programming in is Objective C. I have googled around but havent been able to find anything - so I thought I would ask the community.
Does anyone know if there a way to Hot Swap code in Xcode while programming in Objective C?
Thanks in advance
There is a great plugin which allow changing code in live, working APP. It is called InjectionPlugin.
As FAQ says:
How does it work? The Objective-C runtime allows you to load a new version of a class into an application using a bundle even if there is already an implementation linked into the application. Swizzling is used as the bundle is loaded to switch the existing class to use the methods of the new implementation. This can be done repeatedly and works for OSX and iOS applications and on iOS devices.
I made some small video which shows how to install and use this plugin
http://nomtek.com/developers/how-to-install-and-use-injection-plugin-for-xcode/
Hope it helps!
Not possible with the current tools.
Keep in mind that iOS applications are signed -- if you change a single byte you'd have resign the whole thing. One could imagine making it work using runtime's support for dynamically adding and removing methods. But that'd surely require adding some extra stuff to support it on the device, and that's something that malware could easily take advantage of. So it's probably not a feature you'll be likely to see anytime soon.
By the way, Xcode versions 1.x-3.x did have a "Fix and Continue" feature. You could edit as you were debugging, use the Fix and Continue command, and continue running the updated code. I believe it was removed at some point, perhaps due to some combination of: requiring that your project be configured to use "zero link" and perhaps some other things; being less than completely reliable; probably not supporting iOS; the switch to llvm; other changes in Xcode 4. Maybe it'll come back someday -- if you want it back, file a bug -- but again, I think supporting it on iOS would be a challenge.
If you're just talking about changing variable values then you can achieve that surreptitiously via lldb (or, presumably) gdb. Supposing you had:
- (void)uselessMethod
{
NSString *localString = #"I'm some local text";
NSLog(#"%#", localString);
}
And put a breakpoint on the NSLog, at that point you could ask lldb to evaluate a reassignment of localString as a means of performing it. E.g.
po localString = #"Hat"
If you then allow program execution to continue, you should find that the reassignment has stuck. Similarly you can call any method or perform any other sort of assignment.
I've just tested this against Xcode 4.3.2.
You can hot swap a variable value in Xcode by:
expression <variable> = <value>;.
By having a break point in the place where you wanna change the value and doing the command in Xcode console.
Example:
// Messages From Console
(lldb) expression graphFlag = #"X"; // Update variable value
(__NSCFConstantString *) $0 = 0x36f95718 #"X" // Xcode prints the updated value
(lldb) expression graphFlag; // Printing value through expression command
(__NSCFConstantString *) $1 = 0x36f95718 #"X" // Hot Swapped variable value
I'm new to Xcode and Objective C, but I'm digging my way through the IDE and noticing that it doesn't appear to do live syntax checking. If I make a typo, I have to build the project before Xcode will even mention that there's a problem. Worse still - since it's returning compiler errors, it's usually not even the (in)correct line that's highlighted!
Is there a setting that I'm missing, or is that just what I'm stuck with compiling to check for syntax errors?
Assuming you're using Xcode 4.*, go to Preferences -> General, select "Enable Live Issues".
Select Target from TARGETS Navigator, select Build Settings, LLMV CLL 4.2 - Language > change Precompile Prefix Header setting to "NO", re-open Project (Workspace). It's worked for me.
Make sure you're on the current release of Xcode 4. Despite the 4-ish-ness of its version number, it was a complete rewrite from the previous release, and the early editions of it were sketchy, especially in "code sense" features like syntax highlighting and live error checking.
I've been much happier with it in its last few releases.
Even with the simplest app (i.e no code, just labels) I get this warning in the system:console (not the Xcode one). I would guess its nothing to worry about, but just wanted to check to make sure?
SpringBoard[20558] Unable to create CFServerConnection.
Telephony state may be incorrect.
I am running iPhone-SDK_3, Xcode 3.2.1, Mac_SL_10.6.2
much appreciated
gary