Swift project in Xcode: Three different apps within same project - swift

I have two apps as an individual project written in Swift in Xcode: process1.app and process2.app. Also i have "installer" for those two apps named main.app which has GUI implemented.
I am not able to connect those three apps within same project, where and when user installs main.app, he is going to install process1.app and process2.app.
Can you give me some ideas how to connect all them within same project?

Your description of your project and problem is really vague.
It sounds like you should just scrap the three different targets and just use one target as a launcher for both process1.app and process2.app. If your launcher has a GUI, create buttons that launch each process. You can also modify your program to take command line arguments to launch process1, process2, or both from the command line.

Related

How can I debug in a framework in Xcode?

I have two projects, one is the networkLib for login and some other network function, the other is the usingLibDemo. So I have all the source code of both projects.
The networkLib project outputs a framework, called myNetKit.framework, which is used by usingLibDemo.
Now I successfully use myNetKit.framework to login, but sometimes it crashes, maybe in main() without stack information, but sometimes Xcode gives me the stack info like below:
So I know where it crashes:
But the Utils.m is not exposed, how Xcode gets the stack info and the crash line, and eventually open the source file for me? Because that I have the source code in my disk?
If so, how can I debug the myNetKit.framework step by step, when it is not crashed?
Thanks a lot for any tips.
If someone would have the same question in future (now I am using Xcode 8):
You can:
build your framework project (in this example "networkLib")
copy project output ("myNetKit.framework") to destination project ("usingLibDemo")
run destination project ("usingLibDemo") on your device
stop process
launch app from your device manually ("usingLibDemo")
open framework project and Attach to Process of your app (launched in step 5). In Xcode 8: Debug->Attach to Process-> Select name of your app.
Don't forget set some breakpoints in your framework project.
When the library is built with all symbols, it contains full paths to the each source file embedded in itself. You can actually see this if you open the .a with a hex viewer. With this in place, the XCode will know how to get to the source file.
Setting breakpoints is somewhat more challenging. You basically have to make XCode slowly discover source files from your library by stepping into methods in those file. Once XCode has opened the file, you can set the breakpoint anywhere in it.
It is a bit painful but it works and you do not have to make the library project a subproject if you do not want to.
The following works considering the scenario that you have the framework project separately and added a.framework to some project B.
Go to your project B, add a breakpoint anywhere.
Go to the breakpoint view(where all breakpoints can be seen as a list), right click your breakpoint and click move breakpoint to user.
Go to a.framework and repeat step 1 and 2 but for your framework project.
Now switch back to project B and run the project on simulator/device.
You'll now see program stopping at the breakpoints set in the framework as well.
You can also add the entire library (networkLib) project into your project and link the library dynamically by adding dependency in project settings. So you can have all the source code within your project. So you can debug it in run time.
Use XCode Workspace when you deal with multiple framework projects. When you use a workspace, breakpoints will work and you can find your crash without loads of back and forth debugging. It will be much easier to manage your frameworks in the long run.
You should debug the project networkLib which outputs the framework separately. The framework do not have app like structure so a framework file within other project can't be debugged.

Batch iphone application creation

I have built an application that show you information based on te images and database that are included in the bundle of this application. I want to build a whole set of these applications only with different images and databases, but I do not want to create an xcode project for each of these application. Because if I make a change in the application I will have to build all the apps again. I want to be able to build the application using a batch script and then duplicate this and build it for the other applications with a different database and different images. This is what I did so far. I have built the app and then copied the resulting build results. I cleaned these up a bit (for every action it has a cd statement and a setenv statement, which you only need once). But I can't get the thing to run because it uses built in function to execute certain statements, namely:
<com.apple.tools.product-pkg-utility>
and
builtin-infoPlistUtility
Can anybody help me to execute these command from a batch file?

Is there an API or any other method to automate the submission process?

I have a number of apps which are similar in functionality and UI. I create the user interface by picking up variables from a .plist file. For instance, I save the source of the API from where I pick up the data.
Creating a new app involves just changing the values in the .plist file and rebuilding the app, and finally submitting it to the App Store. Also, I need to create Ad-Hoc provision files and build test releases too.
I wish to automate this process. For this I need to:
Build the app through the command line interface.
Upload the binary and other required files/information (app icon, description, etc.) to iTunes Connect.
Any pointers where I should look?
It's 2016, and now we have the iTunesConnect Transporter command line tool with a quick start guide here.
Also, have a look at this OSS project that wraps the Transporter tools (and others) in a friendly way:
https://fastlane.tools
Building your Xcode projects can be automated by using the command line tool xcodebuild that Apple provides.
As far as automating the app creation process goes, Apple has not exposed this functionality outside of the Xcode GUI. You can still automate this and there are two options.
Use Automator to create a script
that replays all the actions a human
would perform to create a new
project. Parts of this replay
script like the project name etc.
can be customized and
programmatically fed to the script.
A disadvantage of this method is
that this will actually run on the
GUI and will be slow.
If you want to do it all through the
command line, you will have to
reverse engineer the contents of the
Xcode project file that has the
extension .xcodeproj. It's a
compressed file and contains a few
XML configuration files for the
entire project. There is no public
documentation on the contents of
these XML files.
For automating the submission process, you will need a script that talks to itunesconnect.apple.com. This is where you would submit your app to the App Store. Checkout this page for more info on iTunes Connect.
A browser automation tool will be helpful here though you could roll your custom script that talks to iTunes Connect over HTTP.
To summarize, the only thing that can be used readily out of the box is the xcodebuild tool. Everything else has to be reverse engineered.

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.

Editing a run script build phase in XCode

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.
// :)