XCode "File not found" error on parser, but compile fine - objective-c

I am currently experiencing an annoyance which has been following me for a couple of days.
I integrated the Facebook SDK framework to an iOS project and it did work fine. I played with that Framework in a "mm" file of my project without any trouble. Lately, I decided to move all the Facebook specific code in an helper class that would deal with all the Facebook integration to make my code cleaner. Since then, the XCode parser has been complaining on the line that import the framework SDK (FacebookSDK/Facebook.h) that the file could not be found ...BUT... the error goes away when I am compiling. And then, as soon as I edit again the source file, the error comes back.
I have verified that the Framework path was properly set. Again, the parser has no issue when this import is in another mm file that is within the same project/folder. In addition, in the problematic class, as soon as I type the name of the Framework on the import line, the auto-complete will propose me that FacebookSDK.
Rebooting XCode has no effect
Cleaning the project didn't help
Building the project fix the problem only until I edit the code again.
If you have clues, let me know!
Thanks,

Related

Invalid Binary Or Invalid Swift Support

After I send my app for approval to the app store I get the message 'Invalid Binary' in the iTunes Connect. Then I get the following message in an email from Apple:
Invalid Swift Support - The bundle contains an invalid implementation of Swift. The app may have been built or signed with non-compliant or pre-release tools. Visit developer.apple.com for more information.
My app is just a simple game application. No external programs are called. I have researched this message and went through and checked the following:
xcode is up to date - checked in app store
EMBEDDED_CONTENT_CONTAINS_SWIFT to YES or NO
send with the xcode app, not the application loader
did NOT build with the command line
(Xcode menu -> Preferences -> Locations tab - verified that the Command Line Tools matches Xcode version.
"Clean"ed the app, rebuilt and rearchived and then resent, same message
The app validates through the organizer fine
viewing the contents of the archive shows a SwiftSupport folder
I am only using one developer account and have never logged into any other developer account
I cannot find anything online that would help solve this problem.
I am running OS X Yosemite 10.10.1.
xcode version is 6.1.1 version 6A2008a - built, cleaned and sent with this version
I have also pressed the Option key and "Cleaned Build Folder" and resent, same message
I cannot find any other reason for this online or in any forums. Any help is greatly appreciated. Thank you for your time.
SOLUTION I FIND
Edit:
(1)
One you contact Apple and you wait long time … for reset iTunes connect because this problem coming in Apple . (Apple ask to send log of this problem)
(2)
An other solution, your create an other project application on iTunes connect and upload your work, this solution work fine, is the solution for me .
(3)
An other solution, you create a new project on Xcode, copy and paste your project in this other project.... (create new provisioning profile etc..) And upload your work in the same project application on Itunes Connect.
(4)
Step (2) + step (3), create a new project in Xcode and Itunes Connect.
(5)
Create a new project with the same name bundle identifier, it works perfectly !
See: Technical Q&A QA1881 Embedding Content with Swift in Objective-C.
It seems that you only need to set EMBEDDED_CONTENT_CONTAINS_SWIFT to YES "If you are building an app that does not use Swift but embeds content such as a framework that does".
What language is your app written in? If Swift yo do not need EMBEDDED_CONTENT_CONTAINS_SWIFT.
I ran into this problem the other day. Took some doing, but I finally figured out the problem ( for me at least). Everything I read online said the problem had to do with this setting:
EMBEDDED_CONTENT_CONTAINS_SWIFT
When this started failing, I had this set to NO. So I tried setting it to YES, and it still failed for the same reason. The GUI wouldn't let me remove this setting, I could only change it between YES and NO.
For what it's worth, my code has no EMBEDDED code, it's all just straight up SWIFT.
Anyway, so I decided to uninstall XCode and redownload it, hoping that would help.
While XCode was downloading, I fired up Beyond Compare, and compared my current project, with a backup from last week, to see what could have changed.
Beyond Compare found that a file deep inside the Projectname.xcodeproj file, changed ... a file called project.pbxproj file.
Inside this, was that line:
EMBEDDED_CONTENT_CONTAINS_SWIFT = NO;
This appeared in the current version of my project (that was failing). Interestingly enough, this line didn't exist at ALL in the old backup version from a week ago. I know that I didn't set this flag. There must have been something in Xcode that did it under the covers.
Anyway with that knowledge, Xcode finished downloading, and I reinstalled. Started it up, opened my project, and magically, Xcode REMOVED that line from the .pbxproj file, and now my project uploaded to itunesConnect sucessfully.
BottomLine: There's a bug in xcode that it may decide to add this line to your project for no reason, making your project invalid.
Solution: Editing the pbxproj file yourself and removing that line might work ... but reinstalling XCode seemed to clear up any confusion it had, and it removed it for me.
If you are submitting an app that has an AppleWatch extension, you can get this error if you try and submit the app using the Application Loader utility and a zip file. I got the error:
The bundle contains an invalid implementation of Swift. and
The bundle contains an invalid implementation of WatchKit.
I went through pretty much every solution for the first of the errors - but it was submitting via Xcode that fixed it.
well xcode 6.1 is a bit old and contains old swift. xcode 6.4 is the newest public one IIRC
"Check your code signing. I had this error when in automatic signing. I Put my dev profile for dev and production profile for release version and error is gone."
Link for the Quote
Sometimes this happens inadvertently.
To be safe, all components of your app should be built with the same version of Xcode and the Swift compiler to ensure that they work together.
I think you need to do a pod clean and install. I reckon one of your swift pods was created on a old version of Xcode, you updated Xcode and then tried to do a submission to the app store.
Read the apple swift blog about binary compatibility and frameworks
You will also want to specify that your embedded content contains swift in the build settings:
EMBEDDED_CONTENT_CONTAINS_SWIFT
Enable this setting to indicate that content embedded in a target's product contains Swift code, so that the standard Swift libraries can be included in the product.

Invalid resource directory CocoaTouch framework

I'm trying to compile a basic Cocoa Touch framework to test this new feature in iOS 8 but I'm encountering some problems. First of all the framework doesn't import any other frameworks or libraries and the deployment target is set to iOS 8 (regular project when trying to create an Cocoa Touch framework. I added two methods:
- addValue:toValue
- subtractValue:fromValue
Compiling the framework goes without any problems as long as I'm not trying to code sign it. When I import the framework in my TestFramework project and I press build I getting this as build result:
I'm running into a peculiar error which doesn't seem to affect anyone on the web because nobody has complained about this error yet. The error is as following:
Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
.../DerivedData/TestFramework-ethagmafcjzncuftipguwzdeiezh/Build/Products/Debug-iphoneos/TestFramework.app/Frameworks/BasicFramework.framework: replacing existing signature
.../DerivedData/TestFramework-ethagmafcjzncuftipguwzdeiezh/Build/Products/Debug-iphoneos/TestFramework.app/Frameworks/BasicFramework.framework: invalid resource directory (directory or signature have been modified)
I mentioned that this "invalid resource directory" is an known issue for MAC developers but I can't seem to find the right solution. Who can point me in the right direction?
EDIT: I found out that it definitely has something to do with the code signing. Probably I need to code sign the framework too but that's not possible because I encounter the same error.

UIKit.h not found error

I made a single view app for the ipad, with a movie, webview and button, and I get this error when I try and run it. I have restarted the application, and reinstalled it, but nothing is working. This error keeps coming up in my MoviePlayer_Prefix.pch file. Can someone help me out?
I have had the same issue with being unable to compile project due to UIKit.h not being found + "unable to load standard library for target..."
The solution for me was very simple - to quit (CMD+Q) and relaunch Xcode. I have found out that with Xcode opened, macOS seems to have removed command line tools for Xcode because it was preparing for a update and relaunching Xcode triggered the "install additional components" update and it made the problem disappear.
Like Faul Textor said, most likely your XCode updated to 12.1 but your Command Line Tools didn't. You need to quit XCode completely and then start it again and you should get a pop-up saying "Install Additional Components"
Sorry, this should have been a comment to his reply but I cannot do that.
It sounds like you removed the UIKit.framework from your project at some point. Check if it is listed in your project navigator. If it's not there, go to your project in the project navigator pane, select your target, go to the build phases tab, click on link binary with libraries, hit the plus button, find the UIKit.framework there and add it to your project.
EDIT:
This answer suggests that there mayb be an issue with your framework search paths build setting. Check that out and if the path is empty and it still doesn't work, a re-install of Xcode would fix it, I think.
Just wanted to add my two cents on not making a dumb-ass mistake - came across this answer hoping to solve same problem.
Turns out I had written #import "<UIKit/UIKit.h>" instead of #import <UIKit/UIKit.h>.
Thought I would add in case someone else makes a simple mistake like me.

PhoneGap template-based app failing to compile AdWhirl sources

Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I cant find it now :( - PhoneGap is a static framework).
The app works ok on its own.
Now trying to add in AdWhirl. AdWhirl comes as source files - no library of its own, although there are libraries for the specific ad services you use.
I have added the folders to the project, but it does not seem to compile the AdWhirl sources - if amend/break the AdWhirl code, I get no compile errors.
Where I have included/imported the AdWhirl headers into my app, I had to tweak the related imports in AdWhirl files to find their dependancies - seems to be related to issue above.
I can get it compiling with that hack - but then fails to link - missing AdWhirlView, which also seems to be due to first issue - not being compiled, so not available to link.
Under build phases/compile sources, I have just 2 items: main.m and AppDelegate.m - do I need to add the AdWhirl code into here?
Here is a sample project with just the AdWhirl stuff, no PhoneGap, but still has the issue :(
Thanks in advance for any tips/pointers.
Just wanted to post the answer here that I gave on Twitter. Seems like the issue is that Xcode is unhappy with folder references. Try reimporting the AdWhirl files into your project, but tell Xcode to add groups for folders, rather than folder references. (Incidentally, if anyone knows why Xcode is choking on the folder references, I'd love to hear about it.)
Then, you'll start getting errors about ARC and missing files pertaining to the Google Ads framework. So, you'll have to add the Google Ads files to quell the errors; then, you'll want to make sure ARC is disabled in your project. If you want to use ARC, then your best bet is to repackage AdWhirl as a static library that builds without ARC, and have that as a dependency in your workspace.

json-framework doesn't work with iPhone SDK 3.0

I can't seem to get my app to compile when using JSON-framework http://code.google.com/p/json-framework/ with iPhone SDK 3.0.
My app compiles fine for the simulator, but when I go to compile for my device I get a 'codesign error' code 1. I've followed all of the installation instructions correctly, and when I remove the 'Additional SDK' reference and 'Other Linker Flags: -Obj-C -ljson' it compiles just fine...but obviously I then can't use JSON in my app.
Any ideas?
You may want to just switch to the code version and not link in the static lib.
It should compile and work fine on 3.0.
On my own project, I too ran into this problem. I was not able to build my app for iPhone OS 2.x using the iPhone 3.0 SDK.
The fix was to set the following at the project level (Get Info):
BaseSDK to iPhone Device 3.0
iPhone Deployment Target to iPhone OS 2.x
Code Signing Resource Rules Path to the same 2.x plist (e.g. /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/ResourceRules.plist)
The last bit allows a distribution (app store) build to code sign correctly... Otherwise you'll encounter an error "object file format invalid or unsuitable" since the code signer by default will use the same resource rules as the BaseSDK (i.e. 3.0), which is unsuitable for a 2.x app.
Also, be sure to clear any of the above settings at the target level (again, via Get Info).
Phew.
Codesign error means you do not have a valid provisioning profile for the device you are trying to compile to, using the current built settings.
Can you build and deploy sample apps to your phone?
I started using the lovely json-framework for the iPhone but then suddenly found that if I compiled for anything greater than 2.1 for a device, that it would pop up with:
Codesign error: “object file format invalid or unsuitable”
It took me a long time to figure out what was going on, but thanks to a blog post, the fix is this:
On the project settings, on the build tab, search for “Code Signing Resource Rules Path” and set “$(SDKROOT)/ResourceRules.plist” as its value.
I’m not sure how it works as it looks like that is the path it already has, but hey, it seems to work!
that solves the codesign error i was getting, but now I cant compile on 3.0 for some other reason. i'm going to try to link to the code rather than the library.
Sounds like an issue you would want to discuss with the developers, see the support group.
It seems like the code signing isn't extending to the framework. Have you tried linking the framework differently?
And for French persons, here is a tutorial too here too (en Français)
But for your problem I think it's not about JSON but more with your key developer.