Editing a run script build phase in XCode - iphone

In XCode I made a new run script build phase and want to do one of two things:
Edit it
Delete it
I can see how to add a new one, but not how to access the existing one?

In xcode project tree, click on targets, then pick the target for which you added script. Each time you add new script/event it will show up as a new grey folder in target's subtree. Pick folder named 'Run Script', right click, select 'Get info': script body will be in 'General' tab.
If you have multiple scripts, you probably would want to rename them in that target tree.

I realize this is really old (And the solution I'm mentioning might not have even existed when it was asked), but I came across it when looking into how to do the same thing, and thought it would be useful to put in my findings for anyone else. I've discovered that if you check the box for Run script only when installing on the run script screen, then it will only run when you do an Archive. I guess since there isn't an "Install" option for iOS apps, Archive gets treated as the same thing, at least for this purpose.

For people who have been searching for how to add a run script build phase, there is a simple step-by-step guide (with screenshots) at http://runscriptbuildphase.com. It shows both Xcode 4 and Xcode 3.

Found it!
In the XCode Build System Guide look at Adding and Deleting Build Phases.
In your XCode project, under Targets in the Groups and Files pane you can see the Run Script... double click to edit, delete to delete.
// :)

Related

How to manually add SSZipArchive to my project

First off, I'm a Mac OSX newbie, both using and programming, but it's been thrust upon me. My project is moving along nicely, but I need to unzip a file, and it looks like SSZipArchive seems like the way to go. I want to manually add it to my project, so that it stays all together in my source code control system. Others, esp. the release engineer, shouldn't need to do anything, and we need to have all the source code local.
I've tried a million ways and back, only to keep getting the dreaded "No Such module" error. I've researched for a couple days now, and still no closer. So I'm starting from scratch in a new project to say what I'm doing and to plead for some help here. All this is being done on an El Capitan laptop, using Xcode 7.3.1, with Swift 2.2.
Create a Cocoa Application project, calling it 'ziptest', using Swift, nothing else checked. Build it just for fun.
Drag 'n' Drop the SSZipArchive folder found in the master.zip downloaded from the SSZipArchive GitHub site into my project. I'm not sure where it should go, or if it matters - top level, between ziptest project icon and the ziptest group or inside the ziptest group. But I'll put it inside the ziptest group. Now I'm faced with a new question - for the "Added folders", do I want to "Create groups" or "Create folder references". I do copy the items, because, as I said, I want to add them to SCCS later. I saw somewhere here on Stackexchange to make sure it is Group, so that's what I'll do. Build again and it still works.
I know I need a "bridging header" file, so I'll create it. I thought at some point, Xcode asked if I wanted to create it, but the above step doesn't do that. After much experimention, I found that if I d'n'd the SSZipArchive.m/.h files directly, it asks me. It doesn't put anything into it, but at least it creates it and updates the Build Settings. But I do this now manually by right clicking on the ziptest group folder, select New File... and create an empty Header File called "ziptest-Bridging-Header.h", following the pattern from the Xcode created one, being sure to check off the ziptest Target.
I add:
#import "SSZipArchive.h"
to that file. And building still works.
I added ziptest-Bridging-Header.h as the Objective-C Bridging Header in the Build Settings. And building still works.
Now comes the moment of truth. I add:
#import SSZipArchive
to AppDelegate.swift and I get the dreaded No such module 'SSZipArchive'
What am I doing wrong?
Edited to add: Oh, I also added libz.dylib to the Build Phases -> Link Binary With Libraries part. Doesn't help, of course, because we haven't even gotten to the link phase yet.

Xcode 4 - renamed/deleted file, yet get 'file not found' error

I just used Xcode's refactoring tool to rename a core data class from Player to Person. After fixing about 100 errors resulting from using dot notation that Xcode missed in the rename, I got to the last one:
Player.m - Lexical or Preprocessor issue - 'Person.h' not found
Player.m no longer exists in the project, and shows up as deleted (empty icon) in the error. Obviously, since I got rid of it, I don't want it to exist anymore!
To fix this, I have tried re-adding an old copy of Player.h and Player.m, and also cleaning. I have checked the Build Phases->Compile Sources section, and Person.m is there, Player.m is not. Person.h does in fact exist.
Not sure if it matters, but I am using mogenerator to generate my core data classes. Also, this is my third xcdatamodel version. Versions 1 and 2 used Player.h.
Here is a screenshot of the error:
Try clean build, if that doesn't work, restart Xcode, if that doesn't, delete the DerivedData directory, maybe even reboot.
Xcode sometimes gets confused.
You can try to do a super clean (not sure what the real term is) by hitting Cmd+Alt+Shift+K. This performs a clean and removes everything from the build folder.
Well I had a very similar problem and solve it removing the missing compile source of my project settings. to do that follow these steps
Click at the project page. This page contains the general settings
of your app
Select Build phases.
In Build Phases section, select compile sources.
If there is missing some class or file or something that needs to be compiled.
Select water mark file and click the minus sign at the bottom of this section.
Just click and the project may run. I hope this help others.

Save for Enterprise or ad-hoc deployment not present

I am trying to build an IPA file for my app in view of some ad-hoc enterprise distribution. I have been looking at how to do this with Xcode 4.3.2, the version I am using at present, and I reached the point where in the organiser I should select the 'Save for Enterprise or ad-hoc deployment' option. The problem is that this option does not actually appear in the first place. In fact, I only have the 'Save Built Products' and 'export as Xcode archive' options.
I would imagine the issue lies in some configuration settings for my app, but have been unable to find any help over the web. Hence my question here :-)
Would appreciate some help in understanding what is wrong with my code.
Thanks in advance to anyone helping here.
Cheers.
If your project uses a third-party lib as a sub-project, there are a couple of settings that you may need to change so that xcode will recognize your app as a single–bundle rather than multiple products. Only single-bundle apps can be saved for enterprise or ad-hoc deployment, or submitted to the app store.
First, in the Build Settings tab of the third-party lib target, set the Skip Install setting to Yes.
Second, in the Build Phases tab of the third-party lib target, look in the Copy Headers phase and ensure that there are no headers in the Public or Private section (they should all be in the Project section).
I finally got around this. It turned out the issue was that I was using third-party libs by including their (source) Xcode project rather than as pre-compiled libs. For some reason Xcode sees them as distinct apps, and won't let me wrap all of them under one single IPA.
I removed the project, dropped the actual static libs and headers, produced the archive and...tadaaah: here I could sy my most wanted export option.
Thanks everyone for the help, a special thanks to The Saad who helped me finding out this.
well, I met the same problem when I was using GMGridView. I didn't use Diferdin's solution since I still want to keep the GMGridView project there.
My solution is: Go to GMGridView's target, click "Build Phases" -> "Copy Headers", then move all header files under "Public" and "Private" to "Project".
Redo the Product -> Archive, then you may find the option "Save for Enterprise or ad-hoc deployment not present".
This worked for me, hope it could be helpful to anyone who met the same problem as mine.
Also I believe the idea could also be applied to any other thrid-party projects.
Good luck!
Maybe you've done that already, but we have to be sure.
Did you specified in both product and target the code signing identity for adhoc distribution to be your new prov. profile?
Then did you try to archive your app ? (Product -> archive) If it's grayed, just specify the target to be iOS Device, even if no device is plugged.
If Archive is successful, you should have an archive in the organizer. Select it, and choose to distribute as usual.
I experienced the something today. There is no option to export the ad-hoc. so fix this, by "Validate Settings".
Go to your project targets,
Under the configuration list there will be a clock button called "Validate Settings". Click on it
and click "Perform Changes"
Build for Archiving again
To explain the issue, It looks like Xcode understand project's file as Mac Application instead of iOS App.
Hope this helps.
Just as a follow-up, I know several others have answered. I ran into this issue, and the answers in this post were very helpful. Some summarized responses:
For me, this wasn't a profile issue. I have completed a ton of adhoc and distribution app binary builds successfully, so I knew it wasn't a profile problem in my case.
I took one poster's advice, and did the project "validate settings", and it performed some recommended changes...but that didn't solve the issue.
the issue was in fact project libraries that were not making it into the primary bundle. In my case, I had some libraries, that had their own resource bundles. The key is, when you do an archive build, make sure and select the build, select "show in finder", and then "show package contents" to see what additional stuff is not making it into the main application bundle. That's how I located a couple additional resource bundles that were being bundled into some libraries that I didn't even need.
Helpful thing I found was to turn Skip Install off on your main project. If upon archiving you still see a package created (organizer pops up) then a sub-project is still creating a product. Turn off all the sub-projects Skip Install to NO and get your project to the point where an archive does not popup in Organizer. You can then safely turn Skip Install to YES on your main project and little sparkles of achievement will appear in your brain.

When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target

I searched for a long time on stackoverflow using every keyword I could think of to solve this. I am programming for iphone and I have a lite and paid version of my app. I followed the instructions here Creating Lite Versions of iPhone Games / Apps for duplicating the target. This works and now I am working on slimming down the lite version.
Main problem? Images. The lite version needs to have several hundred less images than the paid version. So, I made 2 groups in XCode. One "Folder Group" in Xcode - named "FreeImages" and another "ProImages". I want all FreeImages only to be included in the lite app and all FreeImages and ProImages to be in the paid app. I do not care that XCode considers these Groups to be Virtual Folders. I reversed the instructions to a point and have an environment flag (-D) set in XCode "PLUS_VERSION" I want XCode to basically do the following:
If (PLUS_VERSION)
{
copy contents of FreeImages *and* ProImages where normally they go
}
else
{
copy contents of FreeImages where they normally go.
}
Anyone know where to start to tell XCode to conditionally copy contents of groups into the target?
For each resource (or folder of resources) you want to direct to a specific target, you can click on the resource and inspect it (either via right-clicking and selecting Get Info or by clicking on the Inspect toolbar option). Within that info dialog will be a tab called Targets, where you can check the targets you want the resource (or even source code file) to be incorporated into, and uncheck the ones you don't.
Alternatively, I believe you can navigate to the target itself in Xcode, click on the triangle next to its name to expand the list of build phases, expand the Copy Bundle Resources build phase, and manually delete from the list there any resources you don't wish to have copied over into that target.

xcode build configurations search paths

my iphone app builds fine in debug configuration, but when i change it to release, i get hundreds of errors, starting with "CoreServices/CoreServices.h: No such file or directory" in AudioFileComponent.h - part of the AudioToolbox framework.
i can't find where in the project/build settings is responsible for this.. thanks for any help.
I would recommend the following:
Open up your debug target's build settings by right-clicking on the target, hitting "Get Info", and selecting the Build tab.
Select All (Command-A) so the entire contents of the Build setting panel is selected, then copy it to the clipboard.
Paste the contents of the clipboard to an empty text document
Repeat steps 1-3 for the release target of the same project
From there you can use a diff utility or some other method to compare the contents of the two files, which will show you the settings that differ between the two configurations. Some of them will make sense (e.g., optimization settings) whereas others will not. Most likely there is a setting that differs between the two that will resolve your problem.
Another thing you can do is build one of your source files in debug mode, and in the Build Results window copy the contents of the command line to a text editor. Repeat for release mode. Then, replace each space in the command line with a newline (\r). From there you should be able to do a rough side-by-side evaluation of the differences between the two compile instructions, and may be able to figure out what's missing from that.
In general this helps you get a better feel for exactly what XCode is doing under the hood to build your project, which is a good strategy to practice no matter what tool you are using for development.
i think the problem was because i had the audiotoolbox package in the wrong place, it wasnt in system/library/frameworks like it should have been. (this doesnt explain why it built ok in debug though)