Showing posts with label xcode. Show all posts
Showing posts with label xcode. Show all posts

Friday, September 6, 2019

The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C

After adding Core Data to our Objective-C project and adding an Entity, the build started failing with the error:

The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C

It turns out that the default Code Generation language of Core Data is swift, even if the entire project is written in Objective-C.

To resolve the error, click on the added Entity and look at File Inspector.  There is a Code Generation section which you'll need to switch to Objective-C.  Alternatively you can add the SWIFT_VERSION in your build settings, but I could not find that in our project. (https://stackoverflow.com/questions/52950514/value-for-swift-version-cannot-be-empty)

Solution found on stack overflow: https://stackoverflow.com/questions/47743271/the-swift-language-version-swift-version-build-setting-error-with-project-in

Tuesday, January 10, 2017

Free up some space from Xcode

Xcode is a space hog.  This post is about how to free up some space.  I've gotten up to 10gb back by going through this.


~/Library/Developer/Xcode/DerivedData/*

Deleting everything within the DerivedData folder is fine.  This just means Xcode will have to rebuild intermediate files for you Apps.  You normally would delete some of this anyway when your build starts acting weird.

~/Library/Developer/Xcode/Archives/

Be careful deleting files in here.  If you submitted an archive to the App Store and still want to debug it, don't delete it.  otherwise, it's fine to delete.

~/Library/Developer/Xcode/iOS DeviceSupport

You can delete any ios versions you do not support anymore.


~/Library/Application Support/iPhone Simulator

This is the old directory used to store simulator data as of Xcode 6.  Safe to delete.

~/Library/Developer/CoreSimulator

It is safer to use the "Reset content and Settings" in the options menu of the Simulator.  Old versions of the simulator can be deleted here.

Try to run
xcrun simctl delete unavailable
in your terminal.
https://stackoverflow.com/questions/33419301/macos-xcode-coresimulator-folder-very-big-ok-to-delete-content

~/Library/Caches/com.apple.dt.Xcode

Caches can be deleted.  It'll be recreated anyway.

~/Library/Application Support/MobileSync/Backup

These are your device backup files.  You probably need them, but one time I found a 2-year old duplicate backup of my phone here.   It's safer to use iTunes to delete your device backups.  


Thursday, September 22, 2016

No Matching Provisioning Profiles found

Everything worked fine last week.  Updated to Xcode 8 and trying to upload to the App Store brought up this oh so common error:
No matching provisioning profiles found for "Applications/someapp.app..."

To solve this:


  1. open Xcode -> Preferences
  2. click on the Apple ID you're using to sign
  3. click on View Details
  4. Right click on the Provisioning Profiles and click on Show in Finder.
  5. Exit Xcode.
  6. Select all the files in finder and delete them.
  7. Re-open Xcode and rebuild (clean build first).  
  8. All should be good now.

Get rid of extra logs like "nw_connection_endpoint_report" in Xcode 8

Of course, the solution to this answer was found on Stack Overflow:
http://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-8-logs/39461256#39461256

Add the OS_ACTIVITY_MODE = disable in the Product > Scheme > Edit Scheme Environment variables.

Posting here in case problems arise from adding that variable and I need to take it off.  Some people in the SO post reported NS_Log not printing on device.  This may be because Xcode was in beta at the time.

Wednesday, September 21, 2016

Code signing is required for product type 'WatchKit App' in SDK

The error above appeared after updating to Xcode 8.  Everything built fine before, but now it built with the error:

WatchKit App requires a provisioning profile. Select a provisioning profile for the "Debug" build configuration in the project editor
Code signing is required for product type 'WatchKit App' in SDK 'iOS 10.0'

The solution is to make sure "Automatically managed signing" is checked for each target in the General tab.  If it is already checked, uncheck it and re-check it.

Monday, June 6, 2016

Xcode pod "library not found for"

After updating a pod and cleaning, we starting getting the following error:

library not found for -lAppirater

Apparently when updating pods, the Pod's project file gets completely changed.  Users on stackoverflow suggested setting your "Build Active Architecture Only" in the Pod's project settings to the same setting in your app's project setting.  After looking at that setting, we found that that setting did change in the Pod project.

http://stackoverflow.com/a/31429968/999816

Saturday, April 16, 2016

type metadata accessor for SomeClass

I had an existing app where I added Xcode 7's UI Testing.  When using some of my application-specific methods I got the following error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Quote", referenced from:
      type metadata accessor for __ObjC.Quote in MyUITest.o
ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

According to this guy, the "Allow testing Host Application APIs" checkbox needs to be set:
https://forums.developer.apple.com/thread/20609

What's weird is that I didn't even have that checkbox at all.  To even get that checkbox you need to set "Bundle Loader" and "Test Host" in your test target's "Build Settings".  

http://stackoverflow.com/a/35416945

However, now the tests crash on the XCUIApplication().launch() line with signal SIGKILL

logs:

    t =     0.01s         Launch com.company.aaa

    t =     0.03s             Terminate

Thursday, July 30, 2015

UITextView setting font in Storyboard not working

If you set the font size on a UITextView in storyboard and uncheck the Editable and Selectable options, the font size will not be honored when running the app.  For some reason (bug probably) the Editable or Selectable option need to be enabled.  You can disable it on viewWillAppear in code.

http://stackoverflow.com/questions/19113673/uitextview-setting-font-not-working-with-ios-6-on-xcode-5

Friday, July 10, 2015

Changing default size of Storyboard view in Xcode

The view size when opening Storyboard in Xcode is no longer an iPhone view.  This is because Storyboard is not focused on one device, but any device.  If you are prototyping you would probably want a specific device to view.  To do this, click on the wAny hAny at the bottom of the Storyboard.  Change it to your desired base values.

http://stackoverflow.com/a/30037266/999816

Friday, June 13, 2014

@synthesize of 'weak' property is only allowed in ARC or GC mode

Getting an error like "@synthesize of 'weak' property is only allowed in ARC or GC mode" when the project is already in ARC is pretty confusing.  I had imported and converted a non-arc class which started this problem.  After using Xcode's Edit -> Refactor -> Convert to Objective-C ARC on that class the errors started popping up for other classes that were originally in the project.  In the end i had to convert the whole project for the errors to go away.

Thanks to Buzzwig on this page
 http://stackoverflow.com/questions/12434127/refactoring-to-arc-results-in-synthesize-of-weak-property-is-only-allowed-in

Saturday, May 31, 2014

How to Assign specific compiler flags to specific files

I recently needed to add an ARC file to a non-arc enabled project.  There were compiler warnings saying the -fobjc-arc flag needed to be added for the file.  To do this in Xcode go to Targets -> Build Phases -> Compiler Sources.  Then find the file and add the flag.

http://stackoverflow.com/questions/8768176/how-to-add-arc-for-specific-file

Saturday, October 5, 2013

Cannot compile when including Google Analytics

The linker complains it can't find the following:
  • _llvm_gcda_emit_arcs
  • _llvm_gcda_emit_function
  • _llvm_gcda_end_file
  • _llvm_gcda_increment_indirect_counter
  • _llvm_gcda_start_file


  • Under the target build setting (be sure to select all)
    Set:
    • Apple LLVM complier
      • Instrument Program Flow: YES
      • Generate Test Coverage Files: YES

    http://stackoverflow.com/questions/12670204/ios-code-coverage-broken-in-xcode-4-5

    Sunday, July 14, 2013

    Unknown class in Interface Builder file

    This error can show up when using Storyboard or Interface Builder.  The problem is that no actual code references so the linker optimizes the class out of existence.  One solution to select the .m of the class that is giving you trouble.  Then show the file inspector (View->Utilities->Show file inspector) and check your target under the Target Membership section.

    More info here:
    http://stackoverflow.com/questions/1725881/unknown-class-myclass-in-interface-builder-file-error-at-runtime

    Saturday, June 22, 2013

    Extra Interface in Implementation file

    From Xcode 4.3 or so we started seeing implementation files with interfaces in them.  Kind of like:

    @interface ViewController ()

    @end


    @implementation ViewController

    end


    This is a class extension.  It is intended to declare private instance variables.  It was inrtoduced to tackle the problem with categories as they make the methods public and data hiding capability of classes is compensated.

    Source:
    http://stackoverflow.com/questions/11594391/why-is-there-interface-above-implementation
    http://stackoverflow.com/questions/10647913/declare-interface-inside-implementation-file-objective-c

    Monday, March 4, 2013

    Turn off Cocos debug messages

    Cocos2d displays a lot of messages in the debugger in debug mode so to turn them off (so you can find the actual NSLog message you are looking for):


    • In your project settings, set COCOS2D_DEBUG to 0.

    Saturday, October 6, 2012

    Unable to validate application for iOS App Store, armv6 architecture missing

    Ran into a problem building with Xcode 4.5 when submitting to the App Store.  Xcode 4.5 cannot build for devices running iOS lower than 4.3.  So to fix the error for this, simply change the deployment target to 4.3.  More explanation at stack overflow:

    http://stackoverflow.com/questions/12567539/unable-to-validate-application-for-ios-app-store-armv6-architecture-missing

    Tuesday, September 18, 2012

    Xcode Failed to Authorize Sender

    Mobile Device Framework update for Xcode failed to install after entering my macbook pro password. The reason seems to be an expired certificate as mentioned in the discussion below.  The fast fix seems to be to set your clock back a year, do the update, and then set the clock forward again.

    Some helpful links
    https://discussions.apple.com/thread/3847721?start=0&tstart=0
    http://support.apple.com/kb/HT5204?viewlocale=en_US
    https://discussions.apple.com/thread/3828439?start=0&tstart=0

    Wednesday, August 8, 2012

    Multiple build commands for output file

    This is easily caused when you add git based subprojects. Xcode isn't smart enough to ignore the .git subfolder even though you can't see it from finder, so it will get very confused that there are multiple files named "master" or "exclude", (standard git repo files). With Xcode4, go to the project (root of the left tree) then click your app target and expand "Copy Bundle Resources", then remove all the references to .git, you shouldn't need them baked into your app anyway.

    source: http://stackoverflow.com/questions/2718246/xcode-strange-warning-multiple-build-commands-for-output-file
    keywords: Multiple build commands for output file

    Thursday, June 28, 2012

    Unbalanced calls to begin/end appearance transitions for

    After adding a view controller using presentModalViewController and dismissing it with dismissModalViewControllerAnimated I started receiving a message saying "Unbalanced calls to begin/end appearance transitions for...".  It turns out there are a lot of reasons for this message (not an error or warning).  The solution that fixed it for me was to initialize the new view controller by calling initWithNibName instead of just init.  The documentation says init calls initWithNibName, but I guess Xcode has its own rules too.


    keywords: presentModalViewController "Unbalanced calls to begin/end appearance transitions"
    source: http://stackoverflow.com/questions/7886096/unbalanced-calls-to-begin-end-appearance-transitions-for-uitabbarcontroller-0x

    Tuesday, March 13, 2012

    -Wuninitialized is not supported without -O

    If you get the error above, it is telling you that you have uninitialized variables (-Wuninitialized) and apparently gcc can only figure things out if optimizations is turned on (that's the -O).  For debug builds optimizations are usually turned off.  So in Xcode 4, you'll need to go to your build settings, look for "Uninitialized Automatic Variables" and turn it off for Debug.

    Source: http://forum.soft32.com/mac/Wuninitialized-supported-ftopict45197.html