How to keep the XCode 4 pbxproj file in sync in a CMake-controlled project? - xcode

We have a C++ project which is built using CMake (2.8.7) and versioned with Git. Two of our developers (DevA and DevB) use XCode 4.2. They can generate an XCode project using CMake's -G Xcode feature, no problem, and push/pull/commit changes through the IDE. The problem starts when the project gets restructured. If DevA adds a few files and commits/pushes, DevB can pull the changes (they are visible in the file system), but they won't be reflected in the XCode project setup. We thought that maybe putting the *.pbxproj file under version control could solve this; however, the file is full of absolute paths. So far the only "solution" we could find was to re-create the XCode project by running CMake -G Xcode every time the source tree gets reorganised, which is very tedious. Is there a simpler way? Thanks.

CMake registered a ZERO_CHECK target as the dependency for every "real" target in Xcode, its sole responsibility is to rerun CMake in "CMakeScripts/ReRunCMake.make" and update the Xcode artifacts if one of the CMakeLists.txt files was changed. If you do not see the changes reflected in Xcode, it is because Xcode won't watch its .xcodeproj directory for changes. The pragmatic solution is to close the project in Xcode and reopen it. At which point you could rerun "cmake -G Xcode .." anyway.
The same applies to Visual Studio 10 as well, except that it will ask you for every target whether you want to reload it. It works fine for smaller changes but not for adding / removing files.
I can live with it, as there is a point in a projects life, when the set of source files is not really changing anymore. At least that's my experience.

Related

Why I can't submit or validate project in Archives organizer (XCode)? [duplicate]

I have a problem generating a iOS App archive from an application. The application compiles just fine and even works in the simulator. Now I wanted to make som ad hoc testing and cannot generate the iOS App Archive. When I click on the Product -> Archive it generates a generic xcode archive. Can anyone help me. I should mention, that I have already generated an iOS App Archive of this application. It has just stopped to generate iOS Archive for some reason. Thanks a lot.
Check Build Settings:
Skip install is NO for the main project target
Skip install is YES for framework (sub-projects) targets
In Build Phases for sub-projects, Copy Headers needs to be in Project, not Public (does not apply if building static library)
Installation Directory under Deployment is valid (/Applications for example)
This can happen if you've added a framework/library ... you need to edit the Target->Build Settings of that library and set the 'Skip Install' setting to 'Yes'. When you re-archive, XCode should start producing a 'iOS App Archive' again rather than a 'generic xcode archive'.
In addition of Skip Install to Yes and in case you opened another lib/framwork project within your app project you have to move headers (if any) from public to project in the Build Phase / Copy Headers.
I did the following to make it work for me:
I had a three20 static library, I used cocoapods to include the files within the main project
followed the skip install for all other sub projects/static libraries and switched the copy headers from public to project as stated above
most importantly: in each library your project uses go to build phases -> Copy Files and ensured that destination is changed from Absolute path to products directory. Note: see the hint below to narrow your search to find the library causing this error.
and that was it!
hint: to get an idea of the offending files that's causing your archive to create an archive file rather than an ipa do this:
Select the archive and click the Distribute button.
Select the 'Save Built Products' option.
Hit Next and Save.
Browse the created directory in Finder.
The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes.
in some cases usr/local/include will identify the culprit header files you need to move from Public to Project or the files that you have to change from absolute path to products directory (or even the files you forgot to set the skip install to yes flag). but that directory (ie usr/local/include) varies depending on your sublibrary directory structure. In many cases.. you will see all the files listed under Copy Files in step 3 above listed here. If you find them here, then you have a definite answer for the cause of your problem.
update to hint: to make life even more simpler.. whatever files appears under step 4 in hint above.. simply search for it in the global search of xcode.. and you should get immediate results for what you want.. for example, this was the content of my folder (following the steps in hint above):
So I could tell it has something to do with the crypto and ssl libraries.. searching for them:
made me realize that i forgot to set skip install to yes.
If you export the archive, open it and see /urs/local/include in Products try this suggestion:
In each pod, under Packaging, Private Headers Folder Path and Public Headers Folder Path is set to /usr/local/include. If I clear them then I get a valid archive.
Worked for me after upgrading my React Native app to 0.11.0, Xcode 7 and CocoaPods 0.39.0.beta.4.
If you're using CocoaPods as well as WatchKit or a Today Extension, there is an open issue on the CocoaPods repo explaining what your problem might be.
The solution for me was to remove the Copy Pod Resources phase from the WatchKit Extension and Today Extension targets under Build Phases. The project compiled and archived as expected once I did this.
Hope this helps someone, this had me stumped for an entire day!
If any of the above answers don't work, your issue is probably with cocoaPods. The latest update 0.38.1 messed things up for me, but then i downgraded to 0.37.1 and things returned to normal. Using Xcode 6.3.1
Later edit: updating to 0.38.2 will also fix this. More info about what caused this issue here: Cocoapods 0.38.1 failed to create valid Archive
Although I'm using Xcode5 and what sorted it for me was editing the Build Scheme - trying all of the above suggestions that were applicable didn't help in my case.
I had two targets, say, "App" and "App FREE". My problems with the generic archive happened when I was trying to Archive the FREE version, which I added after the 'normal' version of the app. In my case, when I selected its Scheme in the toolbar and chose Edit Scheme ... I saw that Build section had two targets, namely App and App FREE.
I unchecked all columns for App, leaving only App FREE's columns checked, and clicked OK. Next time I chose Product > Archive I got my App FREE instead of a Generic Archive. :)
If you have only single project, maybe this solution would be useful.
This problem had occurred, when I duplicated the target. As a result I had two targets parallel built. This was causing the issue. Generic IOS archive was built.
To turn the parallel built off go to
Manage schemes,
Edit scheme,
Build,
Remove the other target.
I had this problem after updating to iOS 9 and Xcode 7. Josh H's solution worked for me:
In each pod, under Packaging, Private Headers Folder Path and Public
Headers Folder Path is set to /usr/local/include. If I clear them then
I get a valid archive.
I also made a post install script for my Podfile to do this automatically!
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['PUBLIC_HEADERS_FOLDER_PATH'] = [""];
config.build_settings['PRIVATE_HEADERS_FOLDER_PATH'] = [""];
end
end
end
Just add it to the bottom of your Podfile and run pod install
I had this issue. In my case, it was caused by keeping a Mac app target as a dependency of the iOS app.
The reason it was setup like this was that the Mac app was a tool used to generate some data for the iOS app, which was then included in the bundle.
I had to remove that dependency and build the tool separately before making a build of the iOS app itself.
In my scenario I was getting the erroneous "Generic Archive" only after I began including Swift code in my predominantly Objective-C project. After lots of troubleshooting and examination of the archive file that Xcode was spitting out, I noticed that the SwiftSupport folder (with the required dylibs for the Swift runtime) was in a different place in my archive than from a vanilla brand-new Swift project app archive.
I found the Installation Directory build setting and noticed it was set to a custom path in my project. I simply deleted it (setting it to its generic value of /Applications) and the next Build -> Archive I did worked as expected and gave me a proper iOS App Archive.
TL; DR: Make sure your Installation Directory build setting is set to its default value of /Applications when including Swift code in your app, especially if you are starting with an older project file that may have some unexpected legacy build settings.
I have multiple project in my workspace, (GTL, Pods and my main project) and this is what worked for me:
Select the Project, there will be 2 types there, there's the Project and there's the Targets.
For projects that is not your main like GTL or PODS:
Projects:
Skip Install = NO
Installation Directory = /Applications
// For pods
Private Headers Folder Path = ""
Public Headers Folder Path = ""
Targets:
Skip Install = YES
Installation Directory = /Applications
// For pods
Private Headers Folder Path = ""
Public Headers Folder Path = ""
For the main project (which is usually named the same as your product name):
Projects:
Skip Install = NO
Installation Directory = /Applications
Targets:
Skip Install = NO
Installation Directory = /Applications
Check the ios deployment target on each projects and targets to make sure they are all the same.
Leaving this here to save others from the same journey.
I found I needed to remove the same Copy Pod Resources build phase from a static library target in my workspace too.
Addition to Alex L 's answer.
Point 3. Change 'Build Settings' -> 'Public Header Folder Path' to 'include/xxx' also works.
If none of the above helped you...after a lot of time.......
I deleted the value in the Info.plist for Bundle Version because I was happy enough with just Bundle Version Short 1.0. Bad. Don't do this.
*Note I actually did this by editing it in the UI on the right not realizing it would put an empty key in the Info.plist file. I think that makes it invalid. My bundle showed up as other items while archiving and had no icon, and I couldn't upload to anywhere.
This boils down to invalid values in the Info.plist. If it's not a valid archive, try unzipping an old archive and dropping in / overwriting your current one and see if it fixes it when rebuilding the archive.
Go to Build Settings and add
yourAppName/Resources/dist.plist to the Code Signing Entitlements
Press cmd + B with iOS Device or a Real Device selected as Build Target
When done -> scroll to "Products" folder and right-click on yourAppName.app
Choose "Show in Finder"
Create a folder with Name Payload (capital "P")
Copy yourAppName into your Payload Folder
Create a zip from your Payload Folder
Rename the zip to yourAppName.ipa
DONE
After trying just about everything:
Clean, Archive
delete DerivedData, Archive
restart Xcode (I was using XCode7), Archive
combinations of above...
I then noticed my boot partition was 'low on free disk space'... about 1GB or so.
I rebooted, then got about 18GB free.
Then opened Xcode and project, performed Archive... and surprisingly (after an hour of trying to build an Archive) I finally got a non Generic Archive.
No idea if its a free disk issue which fixed it or a reboot of the macOS that fixed it, but it worked for me.
If you have any .xcodeproj files in Project>Targets>Build Phases>target dependencies remove it from there and then build your ipa. It works for me. Cheers
You can get answer here : xcode is creating generic xcode archive instead of iOS App Archive
In my case, i had to move both FMDB and BlocksKit to static libraries. Previously they were built as subprojects. Remember you can use lipo to create universal libraries. When building the final products, the simulator code will be stripped automagically.
Another possible reason for this is to have references in "Target Dependencies" to projects for a different platform. In my particular case, I was working on a project that shares code for OSX and iOS. In one of the iOS targets, I had accidentally added an OSX target as dependency.
In order to be thorough, I am posting my solution.
I experienced the exact same problem trying to build an Archive of an iOS project in Xcode 5.1.1 (5B1008). None of the above suggestions fixed the problem, and most of them were irrelevant (I had not added any Frameworks, and did not have any Public entries in the Copy Headers section of my Build Phases).
In my case, fixing the problem consisted of simply closing my project, deleting any archives that I had previously made, going to Preferences > Accounts, removing my developer account, quitting Xcode, relaunching, re-adding my developer account, starting the Archive process again. This fixed my problem immediately.
One more solution, since all the above didn't work for me...
Changed the User Header Search Paths (I suppose Header Search Paths would work just as elegantly) to "$(BUILT_PRODUCTS_DIR)/BlocksKit".
Background:
In BlockKit, the developers have structured the headers in the main project differently than the structure on deployment. So, you can't reference the headers in the project, and must reference the headers copied into the build directory.
The way this worked for me in (Xcode 5) I had 2 targets and when I edited the scheme, on the left pane of the scheme editor, you will see the [BUILD, RUN, TEST, PROFILE XXX.APP, ANALYZE, ARCHIVE] from the BUILD pane, you will see your project targets listed in a list. At the far right end you will see the ARCHIVE selections, make sure only one target is selected for archiving.
I had 2 of my targets selected in my project, I checked only the target I wanted in the product, and it worked!
I solved this error by opening solely the app project in XCode, ie. not opening a workspace comprising the application and other projects/libraries/frameworks.
Having 2 separate project, a framework or shared library and an iOS application, I had to open 2 different XCode windows, each by directly opening the .xcodeproj file instead of the common .xcworkspace, in order to preperly build each.
As a nice side effect, XCode no longer rebuilds every target of every project after I do a Clean, resulting in shorted build times.
Background: I am creating an open source SDK, and a demo iOS application. I had both opened in a single workspace.
Setting Skip install to YES on the SDK targets would prevent anyone from creating an archive, as it would be empty, so this was not an option. Using Project instead of Public headers would lead to an archive missing the header files that should be distributed, so this was not an option either.
For it was because i was working in a workspace.
The project did archived but would ne be displayed in the organizer window.
I closed the workspace and open the project on its own.
The archived has been opened in the organizer ... hope it's help.
In my case, I had a custom script that was copying some temporary files into:
${TARGET_BUILD_DIR}/myTempDir
That meant that, after investigating the archive to inspect its contents, I found right next to the .app file a myTempDir folder. Once I modified the script to save elsewhere things were sorted.
Try setting $(PROJECT_NAME)Headers in Framework projet's Public Headers Folder Path. You have to go to build settings of the Library Target then edit the Public Headers Folder path as $(PROJECT_NAME)Headers.
If using Xcode 7 with cocoapods v.0.38.2. Try removing copy pod resources from your today extension target.
I encountered this problem after adding a OS X command line tool to my iOS app's project, and Skip Install was set to NO by default for the command line tool's target. Since you obviously can't install an OS X binary to an iOS device, archiving defaulted to a generic Xcode archive. Setting Skip Install to YES for this target fixed the problem.

two stage rotation runtime error

I'm getting this error in Xcode on runtime.
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation.
I do have
Other developers pulled the same code, and it works for them, not on my laptop. So I'm worried about making any changes. Any help?
Your version of iOS is higher than theirs. Because, a number of iOS methods (didAnimateFirstHalfOfRotationToInterfaceOrientation, etc) where deprecated, when you run the code you get the runtime warning but they don't see it. Note that you might all have the same actual iOS installed but their and your compilation targets may differ. This can happen with the same GIT code base if certain of your Xcode configuration files are not under version control. (It is common to configure GIT under Xcode to avoid some Xcode files; your configuration of GIT might have overdone files to avoid - leading to missing the target build specification.)
Ensure that project.pbxproj is under source control (and that xcuserdata is not). Both are located in the .xcodeproj folder (seen using 'Show Package Contents').

Why is Xcode's Search Navigator searching the wrong project's files?

I have a large Xcode project for a game I'm building. I recently switched versions of the animation framework I'm using (cocos2d), and to keep things clean, I went ahead and created a brand new Xcode project from scratch.
Afer creating the new project file, I made copies of all my source files in the filesystem, then symlinked them into the new project by dragging them into the Xcode Project Navigator. Everything worked fine.
But here's where it gets weird. Whenever I use the Xcode Search Navigator to do global text searches on my project, it searches files from the old project! And only files from the old project!
The only conceivable explanation I can come up with is that Xcode is somehow recognizing my filenames as being the same as were used in the old project, and has decided to ignore the newer versions in favor of the old ones. Is there any such cache or preference within Xcode that can do such a thing? Keep in mind the paths are different, since the new project's files all exist in a brand new directory. But the class names are the same.
In case this is relevant: I once created an Xcode Workspace that included the old version of this project (but not the new one.) I abandoned the workspace long ago as it was problematic, in favor of working with the project directly.
UPDATE: This appears to be an Xcode-related problem-- I have discovered I have the same lack of search-ability in all of my projects. I uninstalled Xcode (I had the version that was still using the Developer directory) and installed the latest version (4.3.3) that does not use the developer directory, but I am still seeing this problem.
I am curious if anyone knows a way to wipe out Xcode's cache of project code indexes, if such a thing exists, that might potentially "reset" its knowledge of my projects and thus fix the situation. Possibly something in the Library directory?
One last clue as to what might be happening: In addition to the search navigator failures, I noticed one of my projects was still using resources that no longer existed in the filesystem-- again, making me think Xcode has cached information about my projects somewhere and is now using outdated versions of my files that no longer exist. this post helped me solve that problem by resetting the simulator's content and settings, but the search issue persists.
Have you checked your Find Options? This same problem was biting me and then I remembered I had added a custom Scope in 'My Scope' that directed XCode to my other project. Changing this back to 'Workspace' fixed the problem.

Xcode creates archive instead of IPA

I am trying to create an ipa file (Product->Archive->Share) but Xcode produces just archive file.
It worked well few days ago. I was always getting working ipa but now I can't make it to produce ipa (when I click on share in archive I can't sign the code). I have added subproject into main project within few past days (CorePlot-CocoaTouch). I am no one hundred sure it can relates.
If you've added a static library, they get installed by default now. This is not okay for iPhone applications. Go to the project file and select the static library's target. Under Build Settings, go to the Deployment section and change the Skip Install setting to YES. Since Xcode 4, it is now NO by default, which will break your IPA (since the only binary you can install legally is the application binary itself).
You may have to switch from the Basic view to the All view to see this setting.
Since the answer that worked for me is buried in the comments, I thought I'd bring it to the top. In my case, changing the header files for the static library to Project fixed the issue.
To do this, select your library target, then go to Build Phases > Copy Headers and move the header files from Public to Project.
One who has tried all other answers and had no luck the please check this check box, hope it'll help (did the trick for me xcode 6.0.1)
In XCode 5 the same error occurs if you have multiple targets and wrong checkmarks in Manage Schemes. Then Xcode puts 2 binaries into 1 Generic Archive. This does not affect checked in files into e.g. git!
The other answers are all probably right, but didn’t help in my case. I spent hours on this and finally rebooted. Then I once more got the application archive I had gotten a week ago.
If you include a project that produces a static library, try checking the option "copy only when installing". This stopped Xcode from including the static library inside my application archive. I used Xcode 6.3.2.

Xcode can't find paths that are there

I have an xcode project that was created on another mac. That make was PROBABLY osx 10.5 using Xcode 3. (When I went to install xcode I could only get Xcode 4 AND was required to upgrade my mac to 10.6) anyway, I am experiencing problems compiling this project that compiles fine on the other computer.
I don't know why. The build always fails and I see it is looking for a path incorrectly.
The physical directory layout is like this
/path/devfolder/devfolderMainProject/mainproject.xcodeproj
/path/devfolder/helpinglibrary/helpinglibrary.xcodeproj
/path/devfolder/anotherlibrary/anotherlibrariesFiles/...
But when Xcode starts doing the stuff for the helping library, it returns linker errors and I can see it is looking for files in the wrong places
linker error /path/devfolder/helpinglibrary/../../anotherlibrary/anotherlibrariesFiles/src/correctfile.cpp does not exist
so I browse and see that the file definitely does exist, and that Xcode is looking too many directory up
../../
should just be
../
so that it only goes 1 directory up, how do I make it look in the right place?
Moving the folders around in finder breaks plenty of OTHER things, so I am not sure what to do here.
I suggest you to open the target properties. In the "Build" tab, look for the settings OTHER_LDFLAGS and LIBRARY_SEARCH_PATH. I have a project with a structure just identical to your one and I have edited these properties to inform the Xcode where to look for my libraries. Maybe you can have some wrong value in some of these settings.

Resources