How to get CocoaPods-based project to work in the simulator? - ios

I'm trying CocoaPods for the first time, because I've inherited a project that relies on it for several libraries. Articles like this one make it sound like it should all Just Work, even in the simulator.
But it's not working for me — I get an "Undefined symbols for architecture i386" for every class defined in a pod library. Moreover,there are a bunch of ld warnings along the lines of "ld: warning: ignoring file blah/blah/Build/Products/Debug-iphonesimulator/SocketRocket/libSocketRocket.a, file was built for archive which is not the architecture being linked (i386)". I get one of these for each CocoaPods library.
How do I get Xcode to build the pod libraries for the simulator (or link the correct ones, if they're being built)?

OK, I've managed to make it work, though I don't know if it requires both of these steps:
Deleted the derived data, as suggested here
In the Pods project, changed "Build Active Architectures Only" to "No" for Debug as well (it was already set to No for Ad Hoc and Release), as suggested by some of the comments here.
I know that step 1 alone didn't do it... but I don't know whether step 2 by itself would have sufficed. Certainly both of them together did the trick for me.

Adding this answer in case it's helpful to anyone.
To my surprise, it was the simulator version that I was using; iPhone 5 wasn't supported. Xcode gave me no sign of this until I switched to an iPhone 6 simulator, which worked. When switching back to iPhone 5, Xcode then complained that "MyApp does not have an architecture that iPhone 5 can execute."
This is all true and I knew that, but I didn't think of it as the previous error Xcode was giving me was that -lPods-MyApp was missing.

Related

Could not inspect the application package when using device

I’m getting this error whenever I try to run my app on a device:
"App Installation Failed
Could not inspect the application package."
I realize that this can mean a million things and I have done days of research but nothing has worked yet. It works on the simulator.
What I’ve tried:
Renaming “Resources” folder in the Google pod (only place it existed)
Renaming “Resources” in Finder for Google and changing the path in the pods resource file
Delete derived data (through projects window and deleting the folder directly)
there are no weird characters in the product name (there is a space)
delete derived data, delete app, restart phone, cmd+shift+K, quit Xcode, restart computer
all software is up to date
there are no sample projects from third parties
the “capabilities” in the app match the entitlements in the app id
Other info:
Xcode 6.4
application supports iPhone and iPad (min version latest 8.4)
works every time on the simulator
always fails on the device (tested iPhone 6 and iPhone 5)
builds with out error
there is no run script printed (in “report navigator”) but there is for
the build (again no error)
valid architectures: arm64, armv7, armv7s, x86_64, i386
build valid arch only: Debug-Y, Release-N
This was working fine before and I did a bunch of code changes (not settings) before this happened out of the blue.
Odd but has been happening:
I’ve noticed that no matter how many times I switch the provisioning profile, it always switches back to automatic (kind of annoying but it isn’t my issue)
Fixed it myself. I was importing a framework in my bridging header that I previously removed and Xcode gave me no error I guess because I didn't call the framework anymore?
Steps:
remove the unused/nonexistent framework for bridging header
cmd+shift+k
quit Xcode
find your project's build folder and trash the contents of the Intermediates and Products folders
open your project and run
This may be overkill but it works now. I hope this helps.
For future reader:
Same issue, but different problem.
My problem in Cocoapods configuration.
I have update Cocoapods to latest version in main project, and in this version some configuration path has changed.
So, i need to make sure all my dynamic frameworks that use Cocoapods to be updated in same version to solve this issue.
Note:
My latest Cocoapods version is 1.2.1
Xcode v8.3.2
update -> pod update
In my case it was an accidentally included framework. Just had to remove it.

Xcode 6.01 Archive validation error: Invalid Segment Alignment

I have been working on an iOS project solely in Xcode. Deployment target is iOS 8.0. After updating to Xcode 6.x, building and testing on my iPhone 5s and iPhone 6 as well as the simulators works fine. However, when I create an archive and want to validate it, I get the following error:
Archive validation failed due to the issues listed below.
iTunes Store operation failed.
Invalid Segment Alignment. This app does not have proper segment alignment and should be rebuilt with the latest version of Xcode. Please contact Developer Technical Support if you need further assistance.
I have googled for the past couple of days and it seems that this problem mostly occurs in connection with other development tools, especially from Adobe. However, I have only used Xcode for development.
This is what I have tried so far:
Reinstalling Xcode 6.01
Turning Autolayout on and off
Set target from 8.0 to 7.1
Just submit the archive (no error message, but new version is not found in Testflight)
Unfortunately, none of this has worked. My questions:
What does the error message want to tell me?
Has anyone any idea how to solve this problem?
Thanks a lot!
I found the solution. XCode seems to have lost track of two of my files (XX.h and XX.c) This file name (with a .o extension) was in the summary of the 1st step of the validation.
I removed the references to both files, added them again and everything works fine. Hope that helps someone!
(Edit: sorry, cannot flag this answer as the right answer, will do so in two days when stackoverflow lets me)
More detailed instructions:
When pressing "Validate" in the Organizer, look at the "Summary" dialog that pops up
If there are any .o files listed in addition to your app, go back to Xcode and remove the corresponding .h AND .m files from your project (removing the reference is sufficient)
Re-add them by dragging and dropping them back into your project
Recompile and it should work (assuming you're not using Adobe Air components in your app)
(thanks a million for this post Fynh, your fix made it finally work for me!)
In my case I was submitting an app that include a framework I had built that was a universal framework - created using lipo (for use with both device and simulator).
After replacing the universal compiled framework with device compiled framework, validation was successful.
To fix this bug I had to go Targets / Build Phases / Expand Copy Bundle Resources and remove the empty.cpp file (my error was about a empty.o file)
Hope this helps someone

Xcode 6 GM won't compile for iOS device, but is fine in simulator - odd error message

I have a project that compiled just fine in XCode 6 beta, but now, in the GM, it won't compile for an iOS device, giving the error:
myController.m:393:9: No visible #interface for 'UIDevice' declares the selector 'initialize:'
at this line:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
It still compiles absolutely fine for the simulators; I've also tried these fixes:
Cleaned the whole project and re-built.
Deleted all Derived Data from ~/Library/Developer/XCode
Re-installed XCode
Checked XCode preferences and pointed Command Line Tools location to XCode 6 (XCode 5 is still installed on the machine and it was pointing there)
...but with no luck. Same error on compilation.
Help! We're on a tight timescale with iOS8 now approaching, and this is a real headache.
PS: We're also using Cocoapods in the workspace, for what it's worth.
OK, I solved this one after rather a lot of hair-pulling. The app in question is an iOS 8 app, with an embedded Today Extension.
It turned out that, when adding the Today Extension, XCode had added a build setting:
'Enable Modules (C and Objective-C': YES
Neither my project nor my containing app targets used this build setting, but setting it to YES caused issues to do with trying to link Frameworks automatically (and failing) and all sorts of related odd error messages that ultimately related to header files.
The problem was further compounded because there are source files that are members of both the containing app's target and also the Today Extension's target.
Hope this info helps somebody else.
Carl

Cordova 3.4, Xcode 5.1 and iOS 7.1

I was building my project perfectly but after updating iOS to 7.1, I was then forced to update Xcode 5.1 and now I'm getting error and warning messages:
4S 7.04 – builds – no error or warning messages
5S 7.1 – doesn’t build – mixture of error and warning messages:
26 x Value conversion issue
Implicit conversion loses integer precision:
12 x Linker build errors
Then I do the steps outlined in this blog post to remove linker errors – delete all conditional architecture and make sure arm64 is in the all the projects and targets: http://shazronatadobe.wordpress.com/2014/03/12/xcode-5-1-and-cordova-ios/
4S 7.04 – builds – warning messages:
12 x Format String Issue
Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
5S 7.1 – doesn’t build – warning messages:
26 x Value conversion issue
Implicit conversion loses integer precision:
12 x Format String Issue
Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
I think the warning messages are now affecting the badges as they are not reseting correctly
Are the warning messages relevant? And would they likely be affecting resetting the badges?
Okay, so I have gone back and forth with this for a while and I've got a few possible solutions for you.
Make sure in Xcode you are selecting both your project and the target within that project also and make sure your settings are setup like the forum post you mentioned.
Make sure you also change the settings on the CordovaLib project as well. Both the project and the target need to be changed, but it's slightly different. you also need to add i386 as a supported platform in the cordova project, but is not needed in yours.
Other things to check are.... Make sure you are using the right kind of provisioning profile... ie. Distribution for production phone builds and Development for team builds and testing on your device.
Check and make sure you are not missing a library you needed to import. You can usually tell if you are missing a library by the mach-o linker errors though.
Example: I removed a plugin from my phonegap project via command line. Well then I added it back and my project would not build using the 'phonegap build ios' command. I had to open the XCode version of my project within xcode then re-import the AudioToolbox library under the Linked files and then I was able to build again via command line.
Good luck, comment here if you need more help.
Please check my attached images might be it will helpful for you.

armv6 and armv7

I've got an app that I created that I'm trying to test on an older iphone 3g. I've used this phone many times for testing but this new app for some reason will not accept the build.
I've done some searching and found that I need to charge the architecture from "armv7" to "armv6", I did this in both the project and target. After doing that I get the following error when trying to build to the device (construction is the name of the app)
Could not launch "construction"
No such file or directory (/Users/Matthew/Library/Developer/Xcode/DerivedData/Construction-cqtujdbjhpvbkrehtfzwvuhvxdrs/Build/Products/Debug-iphoneos/Construction.app/Construction)
But I can build in the simulator at it works fine... any idea?
thank you so much - clearing UIRequiredDeviceCapabilities in Info.plist would have never appeared to me.
None of these solutions worked for me. I'm using XCode 4.5 and ML. What I ended up doing (and still need to test thoroughly), was to re-create my project, started clean and then moved all sources and libraries to the new project and chose my provisioning profile for this new project. In the copy, I also manually copied the contents of the old Info.plist file and pasted them onto the newly Info.plist replacing them all.
In my case, I'm using CorePlot and that library needs armv7 (according to linker), so I can't just go armv6.
What I'm trying to figure out is when (cheap) XCode changed some settings to not run as a debugger on the device. I'm guessing something in the 'project.pbxproj' file. Otherwise I can't explain why the newly created project works and the old one doesn't.
I know this solution might not work for everyone, as in my case, as would lose all svn changes.
I'll post any progress on this.
My next step is to add CorePlot and let the project build it and not use the prebuilt one.
None of these worked for me either. But this DID work...
DO THE USUAL THINGS:
I cleared the build directory (cmd-k),
cleared the DerivedData (see prefs|Locations),
deleted the app from my iPhone 5,
unplugged the iPhone, and
restarted Xcode.
AND LASTLY DO THIS:
Open Xcode Organizer. Click on Devices | (your device name) | Applications. And finally, delete your application from here (aka. delete the app from your device, AGAIN).
Build and run...
Sorry I answered my own question! I figure I should leave this up in case anyone else has the same problem... I didn't update the plist setting to armv6 before... I did have to delete the armv7 in the plist to make it work

Resources