Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Generate iphone project files

4,470 views
Skip to first unread message

asdsad

unread,
Jan 7, 2011, 7:53:48 AM1/7/11
to gyp-developer
Is there a way to generate xcodeproj files from gyp that target the
iPhone?

Thomas Van Lenten

unread,
Jan 7, 2011, 9:41:46 AM1/7/11
to asdsad, gyp-developer


On Fri, Jan 7, 2011 at 7:53 AM, asdsad <v.a.s...@gmail.com> wrote:
Is there a way to generate xcodeproj files from gyp that target the
iPhone?

Xcode projects aren't any different between targeting iOS and Mac OS X.  All you need to do is set the SDK in your GYP files to the iOS SDKs instead, and the project will build an iOS binary instead.

TVL

Mark Dittmer

unread,
Jun 9, 2011, 4:49:58 PM6/9/11
to gyp-de...@googlegroups.com, asdsad
Could you elaborate on what is meant by "set the SDK"? I don't know how to instruct gyp to build for iPhone. It appears that without doing so, "SDKROOT = iphoneos" will not make it into the xproject file (while it is present in an iPhone project created using XCode). In fact, the current xproject output from gyp isn't setting SDKROOT at all, which is breaking linkage to some core iOS frameworks that should be in "$(SDKROOT)/System/Library/...".

What's the correct way of setting this up for an iOS project?

//Mark

Zakk Hoyt

unread,
Jun 9, 2011, 7:47:36 PM6/9/11
to gyp-de...@googlegroups.com, asdsad

Right, GYP doesn't support iOS as it is. I was hoping it would be a simple as changing the SDK and SDKROOT, etc.... Unfortuantely, the SDKs for OSX and iOS are kept in different root folders, among other problems:
iOS is in:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

OSX is in:
/Developer/SDKs/

So simply changing the name of the SDK will not work. I ended up overwriting the variable where the SDK is appended to include the entire path. The problem with this approach is that overwriting these variables would destroy the ability to generate Mac projects.

Unfortunately, there are other complications on top of that such as:
* architecture. GYP will generate xcodeproj files that build for i386 or x64.
* frameworks. Some frameworks share the same name between iOS and OSX but are not the same internally.

To put a solution in place for what we needed, I ended up making a script that is run after 'gclient runhooks'. This script crawls through the source tree and modifies the project.pbxproj files under every xcodeproj, replacing and adding strings. I wouldn't call it rock solid by any means, but it does spit out xcodeproj files that build for iOS. The one major obstacle that remains is the frameworks. Some frameworks share names between OSX and iOS, but are not the same internally. There is some sort of UID attached to the framework if you look in a pbxproj. I'm not sure how to handle those at the moment.

I've proposed the idea (internal to my group) of branching off of the gyp system and adding the proper behaviour. Currently, iOS is way down the list of priorities. Is this something that anyone would be used by anyone? What about Android? I haven't needed to make a build for that platform yet, but I don't recall seeing the string "android" in any of the gyp/gypi files (at least that I can remember). If this would actually be used, perhaps it is worth looking at .

-Zakk

Ryan Sleevi

unread,
Jun 9, 2011, 8:07:25 PM6/9/11
to gyp-developer

On Jun 9, 7:47 pm, Zakk Hoyt <zakkh...@google.com> wrote:
> Right, GYP doesn't support iOS as it is. I was hoping it would be a simple
> as changing the SDK and SDKROOT, etc.... Unfortuantely, the SDKs for OSX and
> iOS are kept in different root folders, among other problems:
> iOS is in:
> /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
>
> OSX is in:
> /Developer/SDKs/
>
> So simply changing the name of the SDK will not work. I ended up overwriting
> the variable where the SDK is appended to include the entire path. The
> problem with this approach is that overwriting these variables would destroy
> the ability to generate Mac projects.

Curious, how are you changing it? Looking at the Chromium gyp files,
there is a common.gypi that is force-included in every iteration (via -
I), http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=HEAD&view=markup

Apologies if I've misunderstood, but I think this may do what you
want.
This file sets the 'xcode_settings': { 'SDKROOT' and 'SYMROOT' }.
'SDKROOT' corresponds to the -isysroot flag. Does setting this
variable not work as expected? Could you explain how you're setting
it? It should be fairly easy to map from XCode settings to the
generator, if it's not sufficient, but I'm surprised that it wouldn't
already work.

>
> Unfortunately, there are other complications on top of that such as:
> * architecture. GYP will generate xcodeproj files that build for i386 or
> x64.
> * frameworks. Some frameworks share the same name between iOS and OSX but
> are not the same internally.

What do you mean? Again, looking at the Chromium gyp files,
http://src.chromium.org/viewvc/chrome/trunk/src/base/base.gypi?revision=HEAD&view=markup
, you'll see an entry
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
# etc
],
},


Again, apologies for not understanding, but what are you needing to do
differently? The GYP generator doesn't add any special flags, AFAICT,
but if you had an example XCode stanza that you need it should be
fairly easy to compare.

> To put a solution in place for what we needed, I ended up making a script
> that is run after 'gclient runhooks'. This script crawls through the source
> tree and modifies the project.pbxproj files under every xcodeproj, replacing
> and adding strings. I wouldn't call it rock solid by any means, but it does
> spit out xcodeproj files that build for iOS. The one major obstacle that
> remains is the frameworks. Some frameworks share names between OSX and iOS,
> but are not the same internally. There is some sort of UID attached to the
> framework if you look in a pbxproj. I'm not sure how to handle those at the
> moment.
>
> I've proposed the idea (internal to my group) of branching off of the gyp
> system and adding the proper behaviour. Currently, iOS is way down the list
> of priorities. Is this something that anyone would be used by anyone? What
> about Android? I haven't needed to make a build for that platform yet, but I
> don't recall seeing the string "android" in any of the gyp/gypi files (at
> least that I can remember). If this would actually be used, perhaps it is
> worth looking at .

I am tangentially interested in a solution for a similar problem to
MSVS, relating to how platforms are configured (x86, x64, win mobile,
etc). The current 'msvs_configuration_platform' stanza leaves a lot to
be desired in generating a single project file that can compile
multiple target, not to mention execute build rules or exclude files
based on the platform or configuration, within the UI itself. This
would seem to overlap with your desire for the xcode generator to do
the same.

Is there a reason you wouldn't be interested in developing this in the
open?
Message has been deleted

Navid Mitchell

unread,
Dec 22, 2012, 4:57:48 AM12/22/12
to gyp-de...@googlegroups.com, asdsad
Hello,

Has there been any movement on supporting both OSX and iOS projects with GYP? I assume this will need to be done at some point for WebRTC and libjingle. I am asking because I need to build libjingle for iOS and OSX both. I would prefer not to have two copies of all of my GYP files. Any information you can provide to get me moving in the right direction would be greatly appreciated. 

Thank you,
Navid 

Ryan Sleevi

unread,
Dec 22, 2012, 5:06:10 AM12/22/12
to Navid Mitchell, asdsad, gyp-developer

Can you explain what is missing?

Chrome for iOS is in the process of upstreaming patches to Chromium, and it did not require any patches to GYP, AIUI.

See http://www.chromium.org/developers/how-tos/build-instructions-ios for examples of how it builds. There is even a Chromium iOS bot that continually builds - also using GYP.

There should be nothing preventing you from building on iOS. If it doesn't, it is unlikely to be GYPs fault, but rather however the projects' individual GYP files are configured.

--
 
 
 

TJ Grant

unread,
Dec 26, 2012, 3:59:28 PM12/26/12
to rsl...@chromium.org, Navid Mitchell, asdsad, gyp-developer
Navid…

I think this is going to be the minimum of what you need to get an iOS project building.

This is set globally:

'conditions': [
['OS=="ios"', {
'xcode_settings': {
'SDKROOT': 'iphoneos',
}, # xcode_settings
}],  # OS=="ios"
],  # conditions

This is set in "target_defaults" in my case:

'conditions': [
['OS=="ios"', {
'xcode_settings': {
'TARGETED_DEVICE_FAMILY': '1,2',
'CODE_SIGN_IDENTITY': 'iPhone Developer',
'IPHONEOS_DEPLOYMENT_TARGET': '5.0',
'ARCHS': '$(ARCHS_STANDARD_32_64_BIT)',
},
}], # OS=="ios"
],   # conditions

And my gyp command line looks like this:

gyp All.gyp --depth=. -f xcode -DOS=ios --generator-output=../ios

Note that "ios" is never set from within GYP afaik, so you can set it this way, and make sure you duplicate whatever "mac" settings you need if you have conditionals set for "mac".

Best regards,

--
 
 
 

Reply all
Reply to author
Forward
0 new messages