How to disable Xcode4.2 Automatic Reference Counting - xcode

Today, I have update my xCode to 4.2 version, And I want to disable the ARC, I also search with the google. but can't fix my problem. According the search results, In the target setting, I can't find the 'Objective-C Automatic reference counting' item, So have no chance to set it to NO. I find the item one by one, and also use the search field.
And one know the newest Xcode4.2 ,how to disable the ARC for the project, not for the specific file.
Thanks very much.

Click on you project, in the left hand organizer.
Select your target, in the next column over.
Select the Build Settings tab at the top.
Scroll down to "Objective-C Automatic Reference Counting" (it may be listed as "CLANG_ENABLE_OBJC_ARC" under the User-Defined settings group),
and set it to NO.
This is on Xcode 4.2 (Build 4D199).

In Xcode 4.2 beta, there were 2 places per target that you could toggle the use of ARC... now there seems to be NONE.
Also, the "Convert to ARC" menu item seems to have disappeared.
Now, yes, I suppose that the ARC stuff was never meant for Mac Developers, as 4.2 beta was iOS only, but not exactly sure what Mac developers who did play with the ARC stuff in their Mac Apps are supposed to do now....
File Radar Reports. Wait for 4.3? redo the app? Edit the .xcode XML manually? Not sure.

Disable ARC or enable MRC
You should operate by C flags
//enable ARC
-fobjc-arc
//disable ARC
-fno-objc-arc
You have three options:
Local - Compile Sources
Global - OTHER_CFLAGS
Global - CLANG_ENABLE_OBJC_ARC
[Under the hood]

Related

Xcode 7.1 beta 2 - How to unblock ''run'' - ''test'' - ''dubug'' in the tools ''Product'' and ''Debug'' of the toolbar?

Actually, I have just downloaded Xcode 7.1 beta 2.
Problem :
I would try to run and execute my program, but the icons in the tools seem inaccessible, blocked. Is there a specific way to unlock these icons?
I have tried to modify some things in the setting, but it doesn't work.
As you can see, I can't connect scheme with target. Have I made a mistake?
How from this place can I can the target?
I'm not sure of the actual definition of a '' target '', but among them, which one should I choose?
This will be the last thing I'll ask you today. It seems there's compilation, but I can't watch them. Are you able to explain me what is happening? Is there a way to run my program from the terminal and observe the results?
The problem is probably with missing target or scheme.
To Add target you have to click plus button
And choose a template, for example Commannd Line Tool for c++ application.
Then to add scheme you have to click
Then New Scheme... and connect scheme with target.

iOS 8 Today widget does not appear when running the project

I have an app with 2 targets and added a today widget. When I run it it doesn't appear on the today notifications Edit/ in the "Do not include" section, where it normally appears the first time with my other apps. Any idea what could be going wrong? I get the entitlements missing warning for the extension but i get this for the ones that work too ( have tried adding one, doesn't help).
Also if i try attach it as a process under the debug menu, it does not appear there at all/
I have tried deleting app from simulator and resetting etc, I have tried with another app that has multiple targets as i thought this may be the problem but the other one works.
Anyone else have a similar experience or can suggest anything?
Edit 6 Oct 2014: I still haven't found a solution, but my project does not use arm64. Could this be the issue ? i have tried removing arm64 from other projects but I think Xcode 6 doesn't allow it so I can't test it, does anyone know if this is a possibility?
In my case, the reason for the widget not being shown in the list of widget was a too high deployment target number. For the widget, I had 9.0. However, I downgraded my iPhone from 9.0 to 8.4 and forgot to change it for the widget.
After changing it to 8.4, the widget immediately appeared on the iPhone.
Make sure you're running the containing app not the extension in the simulator.
I have seen this issue when there is a mismatch in the bundleID between the app and the extension.
Example (Correct):
App bundleid: com.yourcompany.myapp
Ext bundleid: com.yourcompany.myapp.myextension
The extension needs to have the entire bundleID of the app, followed by its own name.
Make sure:
"Deployment Target" is same to containing app's (#vomako 's answer);
Bundle ID follows correct format: "com.yourcompany.myapp.myextension", while your containing app's is "com.yourcompany.myapp" (#RohitGupta 's answer);
While debugging, you need to run widget/extension scheme (not containing app's scheme here. But if archive to submit to App Store, use containing app's scheme);
"Build Settings"'s "WRAPPER_EXTENSION" is "appex".
Point 4 was not mentioned in all answers (even official doc), but happened in my case.
I created Today Widget for my existing project in a workspace, not works at all. However, when I create pure new project with Today Widget, it works well. Then I compare the Build Setting one by one and found this difference: The one created for my existing project is "app", not "appex".
After changing it to "appex", works.
Also, as tips, in order to pass App Review, you must:
Include the arm64 (iOS) or x86_64 architecture (MacOS) in widget/extension's Architectures build settings;
Specify “iPhone/iPad” (sometimes called universal) as the targeted device family for your app extension, no matter which targeted device family you choose for your containing app;
A containing app that links to an embedded framework must include the arm64 (iOS) or x86_64 (OS X) architecture build setting;
Always choose “Frameworks” as your Copy Files build phase destination (do not choose the “SharedFramework” destination instead).
In my case the Build phase "Embed App Extensions" of the app target was missing the appex file:

Xcode 5 equivalent of NS_BLOCK_ASSERTIONS in Build Settings

Until Xcode 5, Release builds could be prevented from including NSAssert statements and their variants, using the default Build Setting:
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
This setting can be found in project.pbxproj and is set in Xcode here:
(Note that this grab was taken from an Xcode 4 project converted to Xcode 5.)
Each target would inherit this setting in the Release build only. Obviously this was a good thing. Rather than crash immediately, the app would possibly struggle on regardless. Whereas for Debug builds, you want to know immediately when an NSAssert fails.
However, I am struggling to find the equivalent in Xcode 5.
Creating a new project using the default templates shows no equivalent setting:
My question is, what is the equivalent setting in Xcode 5, or does NS_BLOCK_ASSERTIONS have to be added manually to Other C Flags for the Release build?
It's got it's own setting field now! Enable Foundation Assertions. Set your debug as yes and your release as no, as shown in screen grab below.
Note: You need to click All in the top left in your build settings tab to see it, you can see in my screen grab the blue ALL in the top left.

How delete the config in Build Settings in a low level in XCode 4

In XCode 4.0.2 there is a good way to configure the program in Build Settings when you click in "Levels" format. Like this screen
The levels are in this way:
Target Settings
Project Settings
iOS Default Settings
So the XCode see if the Target have a config, if not see in project and if not use the iOS default.
The problem here is that when you set a config in a low level and than delete it, it's impossible use the config of a upper level.
Like in image. I set all targets to use Google in Current Project Version, but in this target I want it use stackOverflow and it work. But in the other Generated Versioning ... I first config with stackOverflow but change my mind and want to use the Project Settings. Now is impossible delete the Target Settings and I will have to enter it manually.
How can I delete the target setting to use the project setting?
In xcode 5 it worked right simple for me. I had the same situation as in the picture in the question. Some data in the project setting and an empty but green setting on target level.
You have to select the line e.g. with the mouse that is marked and afterwards press the delete button the green marking is gone from the target level. In my test it and it will never delete the setting on the highes level, so there is no risk.
Click the Combined button and change the build setting value. Now when you click the Levels button, you will see the target and project both have the new value for the build setting.
I just figured this out. It's a little sketchy, but it works, and does not feel dangerous to me (particularly if you're using version control).
In Xcode, delete the text from the target-level configuration. Make sure you still have it defined at the project level.
Look at a diff of the YourProjectName.xcodeproj/project.pbxproj so you can figure out the code-level name of the setting you just changed. For example, in Xcode, I deleted the text from my target-level configuration for "Other C Flags". My diff showed the OTHER_CFLAGS setting changing from OTHER_CFLAGS="mytargetlevelsetting" to OTHER_CFLAGS="". If you're using version control (which you should be), it'll be easy to get this diff.
Quit Xcode.
Open up YourProjectName.xcodeproj/project.pbxproj in a text editor. Find all the lines starting with the setting name you found in step 2. Delete all the ones where the value is an empty string, and keep all the rest. For example, I deleted all the lines that said OTHER_CFLAGS="", but kept all the lines that said OTHER_CFLAGS="settingiwanttokeep". If you don't see any where the value is an empty string, or all their values are empty strings, you probably didn't follow step 1.
When you reopen Xcode and look at your target's build settings again, the setting in question should be using the project-level configuration, not the target.

Increase the length of Xcode's "recent project" list?

I switch in Xcode between working on a lot of different projects frequently (some I'm actively working on, some are old projects where I'm looking up code I want to re-use or quote in SO answers :)), so that part of my "working set" of projects invariably ends up falling off the recent project list. I do use finder tabs for the full working set of current project folders, but I really like the fast switching available using the recent projects list.
Is there a way to increase the length of this list so that I can see more recently opened projects?
On a terminal window, for XCode 7 and above type the following command: (from Matteo Gaggiano):
defaults write com.apple.dt.Xcode NSRecentDocumentsLimit X
where X is the max number of projects in list.
For XCode version below 7, the following worked.
defaults write com.apple.Xcode NSRecentDocumentsLimit X
You could change the length of the list with the number of recent items in System Preferences -> General (Appearence on older macOS versions) as well. However that will change it for all apps.
You need to restart your machine for the change to kick in.
Do Hit Command + Spacebar   >   Type General   >   Follow the screenshot attached.
]

Resources