簡體   English   中英

在xcode 4.0(部署目標4.0)中運行在xcode 4.2(部署目標5.0)中創建的項目

[英]running a project created in xcode 4.2(deployment target 5.0) in xcode 4.0 (deployment target 4.0)

這是情況。 我在xcode 4.2中創建了一個項目,並將部署目標設置為5.0。 但是我想向后兼容我的代碼直到4.0。 現在我在xcode 4.2中沒有4.2或4.0的模擬器,所以我在xcode 4.0中運行我的代碼。 在這里,我有兩個錯誤:

  1. unknown "strong". I removed it by adding retain instead.
  2. unknown "@" in project, so I added below code in main.h 

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;

這就是我們通常在ARC或iOS5之前在main.h中編寫的內容

現在,我遇到的另一個問題是調用了main.h,但沒有調用AppDelegate,即從未調用過aplicationDidFinishLaunching。 然后我將上面的代碼修改為這樣

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.class));
[pool release];
return retVal;

現在,我沒有問題,構建成功,並且可以在兩個版本的xcode中進行編譯。 我只想知道為什么會發生這種情況,所以我可以繼續使用上面在xcode 4.2中編寫的主要定義的項目,因為這對我來說似乎並不好。

試試這個 那應該回答你的問題。

基本上,您首先需要針對iOS4,並且它應該與iOS5兼容。 問題是,當您首先從iOS5開始時,因為iOS4不知道新功能。 這似乎很痛苦,但是考慮一下是否有必要支持iOS4,我們現在有iOS6,iOS5在所有版本中占多數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM